cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Switch in the Script Editor

Index
Community Member

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.

1 Recommended Answer

Prafulla
Googler
Googler

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. 

View Recommended Answer in original post

5 REPLIES 5

join
Community Member

unlock

Index
Community Member

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.

Prafulla
Googler
Googler

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. 

Index
Community Member

Hi!

Thanks for the answer.

I hope that feature is in the works. This would enable many more use cases. 🙂

Mayilong
Community Member

Yes, it would be very useful. At the moment you need to use another device to keep a state.