06-14-2023 08:27 PM
Is there some kind of virtual switch/toggle or a way to store a state between individual runs of routines?
I'm having a fan which I have paired via IR with a SwitchBot Hub Mini. This fan and the SwitchBot Hub Mini don't have a On/Off state. I'm only able to toggle the state. Therefore neither the SwitchBot Hub Mini nor Google Home isn't aware of the current state of the fan.
I would like to add to add this fan to my Bedtime routine. It should turn off if it's on.
Since Google Home isn't aware of the current state, it would just toggle the state. That leads to turning it on if it's off and turning it off if it's on.
With the new Script Editor, is it somehow possible to have some kind of virtual switch/toggle or a way to store a state? That way I could set the switch to on when I turn on the fan and set the switch to off when I turn off the fan. Then I could use the state of this switch in a condition of the Script Editor.
Answered! Go to the Recommended Answer.
06-15-2023 08:48 PM
Hi @Index - Script editor currently does not support global variables to store the state. We do have an example that synchronizes states of two switches (https://developers.home.google.com/automations/example-scripts#synchronize_two_switches) but that still requires understanding of the state.
06-14-2023 08:56 PM
unlock
06-14-2023 09:02 PM
Could you elaborate a bit further? Are you suggesting using the lock/unlock state of some device to store the current state? As far as I can see only actual lock devices have this state, namely my Nuki look for my frontdoor.
06-15-2023 08:48 PM
Hi @Index - Script editor currently does not support global variables to store the state. We do have an example that synchronizes states of two switches (https://developers.home.google.com/automations/example-scripts#synchronize_two_switches) but that still requires understanding of the state.
06-15-2023 09:14 PM
Hi!
Thanks for the answer.
I hope that feature is in the works. This would enable many more use cases. 🙂
03-11-2024 11:40 AM
Yes, it would be very useful. At the moment you need to use another device to keep a state.