My "vacation lights" turning on at wrong time


#21

Local variables are confined within the piston
Global variables are confined within the instance


#22

This is useful. Is there somewhere I can read about what the ‘async with A’ statement is doing?


#23

If I was to the piston above (gmuuv) & added 5-6 devices would they all turn on & off at the same time.
Mike


#24

yes. just add them to the deviceList variable. in fact thats the entire reason why i used a variable for devices instead of using a single device directly. :slight_smile:


#25

dont know if there is a formal writeup :slight_smile:

but the async tells webcore to execute the next action without waiting for the current action to complete.

the A shows up when you set Task Scheduling Policy to allow multiple wait timers. i am also happy to add that in this case that setting is completely unnecessary and must be a leftover from where i was doing something, some other way. :smile:


#26

Thanks! On the other point about the deviceList variable, I had the same question because what I’d like is to have all the devices in a list and for the piston to then select two of them at random and turn them on for half an hour then switch off and select two others from the list to turn on. Is it something I can change this piston to do or am I better off trying to write one from scratch?


#27

sure thing. i had posted a snippet somewhere here to do something similar in a different piston. let me see if i can find it. combining this example with that snippet would work.

here’s the snippet that you will need to inset in the first every block. change VacLights, RandomLight1 and RandomLight2 to your variables and have them defined. you can remove the portion for RandomLight3 since you only want to pick 2 lights randomly.


#28

Perfect, many thanks @bangali! I will try this out and let you know… :slight_smile:


#29

The async with hung me up when I migrated to webcore.

Makes sense now though. :slight_smile:


#30

cool.