[DEPRECATED Thread: visit community.webcore.co for assistance] webCoRE - Piston Design Help (ask your fellow members for assistance)

not modified DTHs before, trying to work with this one which was originally by @Arnqvist then adapted by @949BFN, now with some small changes i made. need help on if there is a way to show the alarm time on the ST things screen?

Thanks.

/**
 *  On/Off Alarm Tile
 */

metadata {
	definition (name: "On/Off Button Tile", namespace: "Alarm", author: "webCore Forums") {
		capability "Switch"
    attribute "alarm", "string"
	}
// accept time from settings
preferences {
input name: "timer", type: "time", title: "Alarm Time:", description: "Enter time", required: false
	}
	// simulator metadata
	simulator {
	}
	// UI tile definitions
	tiles {
		standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Off', action: "switch.on", icon: "st.Health & Wellness.health7", backgroundColor: "#ffffff", nextState: "on"
			state "on", label: 'On', action: "switch.off", icon: "st.Health & Wellness.health7", backgroundColor: "#00A0DC", nextState: "off"
		}
    valueTile("alarm", "device.alarm") {
			state "default", label:'Alarm: ${currentValue}'
		}
		main (["button", "alarm"])
		details (["button", "alarm"])
	}
}

def parse(String description) {
}

def updated() {
    def time = timer.substring(11,16)

if(timer) {
		log.debug "Alarm time set to: $timer"
        sendEvent("name":"alarm", "value":time)
} else {
		log.debug "No alarm time is set"
		}
}

def on() {
	sendEvent(name: "switch", value: "on")
}

def off() {
	sendEvent(name: "switch", value: "off")
}

Initial thought: If the switch is physically switched off/on quickly (say, switch was physically turned on and had been off for less than 5 seconds), set a variable. If it’s physically switched off, clear the variable. Check that variable when deciding whether to turn the switch off programmatically. Then you can make the light stay on by flicking it off/on, and return it to normal operation by turning it off when you’re done.

If this is a non dimmer switch then I am pretty sure you will be able to accomplish this when Ady completes the followed by condition. However this will not work with a GE dimmer switch

It was your mode selection / away piston. You didn’t use restrictions. I did, trying to get it to work.

I’m assuming that async allows the conditions / triggers to run independently (as if in different pistons)

Ok so looking at it again. You removed everything that would make it work. The switch is on is not even subscribed. So essentially that is just a followup piston. Meaning it would need something else to tell it when to run. Have you tried clicking the test button, does that work?

Taking a guess and that switch is your override control switch? If that is the case then take my original piston and leave it how it has all the ifs. Change the times to suit your needs and actions but leave the ifs. Then encompass everything in the if of your switch being on. make that change and try that.

So, I had a bit of a learning curve with WebCoRE, but I have to say now that I know what I am doing, I freaking LOVE this thing!!! Fantastic work guys, seriously, this thing rocks!

I could not get webcore to read a custom attribute string in an expression when I made the piston and DH. But it looks like its do-able now. Maybe it always was and I just did not manage. Anyways, to make it all more clean you could remove the ‘image capture’ capability from the DH and make a custom attribute. e.g attribute "alarm_time", "string"
And pass that instead of as an image from the image capture capability. Its just confusing now.

You could try removing “button” from the “main”-thing in the “Tiles”.

And that DH should not work with webcore anymore, please see this post for update:

@Arnqvist thank you for the help. so, i have change the DH to be as below only. i see in ST that it publishes an event when on, off or alarm time is set. my thinking was to try to use these events in webcore. is that not possible?

/**
 *  On/Off Alarm Tile
 */

metadata {
	definition (name: "On/Off Button Tile", namespace: "Alarm", author: "webCore Forums") {
		capability "Switch"
        attribute "alarm", "string"
	}
    // accept time from settings
    preferences {
    input name: "timer", type: "time", title: "Alarm Time:", description: "Enter time", required: false
	}
	// simulator metadata
	simulator {
	}
	// UI tile definitions
	tiles {
		standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Off', action: "switch.on", icon: "st.Health & Wellness.health7", backgroundColor: "#ffffff", nextState: "on"
			state "on", label: 'On', action: "switch.off", icon: "st.Health & Wellness.health7", backgroundColor: "#00A0DC", nextState: "off"
		}
        valueTile("alarm", "device.alarm") {
			state "default", label:'Alarm: ${currentValue}'
		}
		main (["button", "alarm"])
		details (["button", "alarm"])
	}
}

def parse(String description) {
}

def updated() {
        def time = timer.substring(11,16)

    if(timer) {
    		log.debug "Alarm time set to: $timer"
            sendEvent("name":"alarm", "value":time)
    } else {
    		log.debug "No alarm time is set"
    		}
}

def on() {
	sendEvent(name: "switch", value: "on")
}

def off() {
	sendEvent(name: "switch", value: "off")
}

Webcore will not be able to read the correct alarm-time unless you follow the instructions to update the DH in the post I linked in my previous post. The time will need to be formatted. I made that DH quickly to another user and don’t have it saved, if I had I could have sent it.
And you will need to send the formatted time to webcore, and the time stripped with the substring-function is the same time but for display in the tile.

Check my DH in this link:

The reason why this changes are need to be done is that webcore could not read the time in format XX:XX after an update a couple of days ago. Try this DH, and use the “alarm_formatted” attribute for passing time to webcore:

metadata {
	definition (name: "On/Off Button Tile", namespace: "Alarm", author: "webCore Forums") {
		capability "Switch"
        attribute "alarm", "string"
		attribute ”alarm_formatted”, ”string”
	}
    // accept time from settings
    preferences {
    input name: "timer", type: "time", title: "Alarm Time:", description: "Enter time", required: false
	}
	// simulator metadata
	simulator {
	}
	// UI tile definitions
	tiles {
		standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Off', action: "switch.on", icon: "st.Health & Wellness.health7", backgroundColor: "#ffffff", nextState: "on"
			state "on", label: 'On', action: "switch.off", icon: "st.Health & Wellness.health7", backgroundColor: "#00A0DC", nextState: "off"
		}
        valueTile("alarm", "device.alarm") {
			state "default", label:'Alarm: ${currentValue}'
		}
		main (["button", "alarm"])
		details (["button", "alarm"])
	}
}

def parse(String description) {
}

def updated() {
        def time = timer.substring(11,16)
        def tz = location.timeZone
        def formatTime = timeToday(timer, tz)


    if(timer) {
    		log.debug "Alarm time set to: $timer"
                    sendEvent("name":"alarm_formatted", "value":formatTime)
                    sendEvent("name":"alarm", "value":time)
    } else {
    		log.debug "No alarm time is set"
    		}
}

def on() {
	sendEvent(name: "switch", value: "on")
}

def off() {
	sendEvent(name: "switch", value: "off")
}

@Arnqvist got it. thank you, i understand now. did a small experiment. on alarm event i should be able to do a time($currentEventValue) to get time in a format that I can use with webcore. or am i missing something?

Read the time with this expression, only way I could get it to work: time(datetime(string([Alarm:alarm_formatted])))

But thats only necessary if you want to actually use the time for anything else but just displaying it as a string. Which I’m sure you would want to of course.

yeah, i am seeing the same problem. if printed as a string works fine. if passed to time() function doesn’t work.

tagging @ady624 so he knows of the issue. thanks.

You can use this expression to format the time to a string:

formatDateTime(time(datetime(string([Alarm:alarm_formatted]))), “HH:mm”)

But that is of course only if you have updated your DH to the one i posted to pass the formatted time to webcore.

thank you. but, its not a DH issue … the modified DH is sending everything as expected.

there is something in webcore that is not working as we think it should. so, anything i hack is going to be in webcore piston leaving the DH as it should be. at least i will try that first. :slight_smile:

Okey but believe me and save some hours… Its not sending the time as expected since it’s sending it in a format webcores datetime() can’t understand. You will need to format it in the DH with the timeToday() function.

See this post of how to get it to work. [DEPRECATED THREAD: visit community.webcore.co for assistance] WebCoRE - Example Pistons

In one of the notifications Im converting the time object to a string in XX:XX format.

don’t get me wrong, i believe you. i see now why you had to do this. webcore should be able to handle the value:time.

Yeah and it was able to read time in format XX:XX with the time() function a week ago. But not anymore. If you want your piston to work today, update the DH.