I have a simple need, and I must be searching for help with poorly chosen terms because it seems like something that would be fairly commonly used - I have two switches to control a fan and when both switches are off I want a delay before the fan is switched off. If either switch is turned on, then the delay should be cancelled. (I have one large inline fan ventilating two bathrooms)
In this particular case one of the switches is multibutton (hence wanting to know how to access one of the buttons) and the other is a simple switch that is directly connected to the fan.
Currently I have both switches triggering an action group that just executes a scene and so if one switch turns on the fan the other can turn it off , which is a bit of a pain if the first switch still wants it on. And there is no delay either.
My thought was to use a variable, change its state when either switch was turned on or off and use that to trigger a script that cheeks the state of the two switches to decide whether to turn on the fan, cancel a running delay, start a delayed turn-off or make toast. Something like
- Code: Select all
if ((on state of device "switch X button 3") or (on state of device "switch Y") <--- how do we actually do the "switch X button 3"?
then
send instead group instTurnOn using name "BFan"
remove delayed actions for device "BFan" <--- I think that's right; found it elsewhere on this forum
else
{trigger a trigger with a 5 minute delay to actually turn off the fan but I haven't got that far yet}
But I'll happily take advice on any decent way to get the end result; I'm not wedded to any other aspect.
Part of my problem in doing this is a complete lack of any experience in doing anything with AppleScript, but mostly its just that once I got Indigo set up two or three years ago I haven't had to do anything or even think about it, so one forgets anything learned.