NEWS
Turn on switch at certain time when other switch turned on
-
Hi, I want to make script that will turn on SWITCH2 when SWITCH1 is already turned on and is between SUNSET or DUSK and 23:59 or until SUNRISE next day.
Then turn off SWITCH2 5 minutes later after SWITCH1 is turned off.
I created this but it's not working:
-
@sekino
You need to swap the Trigger / if/else logicBuild it like this:
Trigger on switch, has been changed
Inside the trigger the Block If time is in range use the "write" block to set the state, and add a "timeout 5 minutes - disable switch 2" block.If you take a close look at the Blockly system section where the triggers are located, you will find a block which just shows "object id". You can grab that one and use inside the "write" block, since you can change it to "state value", which is the value of the state which fired the trigger.
I can build a sample blockly when i get home later.
A. -
@sekino
OK.. seems i didn't read all you wanted to do correctly earlier. When trying to build the blockly, i ran into an issue which is unclear in your description:What i read from above:
- If sunset comes AND switch 1 is already on, you want switch 2 to be turned on, and turned off after 5 minutes.
- If switch 1 is turned on during night time, you want the same to happen ?
Here is a blockly set which does that:
Code to import behind the spoiler
-
@Asgothian I will make it in points:
- If sunset comes AND switch 1 is already on, I want switch 2 to be turned on
- If switch 1 is turned on during night time, I want the same to happen (immediatelly)
- turn off SWITCH2 > 5 minutes later after SWITCH1 is turned off.
-
@sekino The script is already in the post above. It should do just that.
A.
-
@Asgothian I will try and let you know if works, for now I would like to ask what logic is behind : ObjectID is greater/less than last ... if values are true or false ???
should I keep variables Sw1IsOn and Sw1IsOnAtNight ? Or should I changed them for states of my Sw1?
-
@sekino sagte in Turn on switch at certain time when other switch turned on:
Or should I changed them for states of my Sw1?
no, You should online exchange objectID with your states
-
@sekino sagte in Turn on switch at certain time when other switch turned on:
@Asgothian I will try and let you know if works, for now I would like to ask what logic is behind : ObjectID is greater/less than last ... if values are true or false ???
should I keep variables Sw1IsOn and Sw1IsOnAtNight ? Or should I changed them for states of my Sw1?
as @Homoran said - only replace the object id's.
Triggering for greater than and lesser than enables you to not have to check true or false value later.
In JS, true > false, so a trigger on "greater than before" will only activate when the object value changes from false to true.
A.
-
@Asgothian @Homoran Thank you all! Working great!