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

thats cool.

no need to parse out the day, use the timer function statement and select the odd days from only on these days of the month.

1 Like

Doh! Sometimes we all need smacked in the head with the clue stick. So obvious.

Thanks!

1 Like

@949BFN thanks. did you want to do that for the piston devices 1 to 3 only? asking because i see this piston also turns on a TV and lights.

Hi @bangali. Yes - if you could just show me with one of the statements, I’m sure I’ll be able to figure it out. Or I’ll ask again if I don’t come right.

OK. understood, help me with why there is a check for image change at line 40 … what doea that do?

I use this DTH to set the time the piston has to run:

/**
 *  On/Off Alarm Tile
 */
metadata {
	definition (name: "On/Off Button Tile", namespace: "Test", author: "Test") {
		capability "Actuator"
		capability "Switch"
		capability "Sensor"
        capability "Image Capture"
        attribute "alarm", "string"
	}

    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 schedTime = timeToday(timer, tz)

    if(timer) {
    		log.debug "Alarm time set to: $timer"
    		sendEvent("name":"image", "value":schedTime)
            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")
}

It’s an adaptation of another forum member’s piston and handler.

you could insert an if after line 136 and set the piston state there for alarm not turned on

if input switch is off OR presence sensor is not present OR temperature sensor is greater than temperature threshold
set piston state = "{Alarm is OFF; Input switch is upper([inputswitch : switch}, Presence Sensor is upper([presencesensor : presence]) and Temperature is [temperaturesensor : temperature]}"
end if

is this along the lines of what you were thinking off?

you are welcome.

Yes, I think I understand what you suggest. Actually much simpler than what I had anticipated. Thanks a million for helping!

Alright if i have GE Smart Switches that are currently tied to a simple motion lighting automation can I make the switch stay on indefinitely using two clicks up or something of the sort? So something like this:

If motion is detected > turn on light > if motion sensor changes to inactive > wait 10 minutes > turn off

BUT IF

switch is turned on 2x (or something) then leave switch on.

?

@949BFN you are welcome.

thanks for pointing me to your DTH. this is exactly what i have been looking for to set an alarm via ST and use it in webcore for wake up alarms and such.

It is not my DTH - @Arnqvist is the author. He’s made it for a piston he designed to heat his vehicle. You can find it here.

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: