Global vs local const device and changing one light on motion in a group


#1

1) Give a description of the problem

  1. I would like to convert the const device local variable with a global variable so allow me to update across all holiday pistons.

  2. I would like to also override only one of the lights in the global variable when motion is detected.

2) What is the expected behaviour?

  1. Create a global variable to manage set of lights and call them in the piston.

  2. When my ring camera detects motion change the color of the flood light to white (part of the group of lights above) and after 20 minutes go back to the color for the piston attached (using the global variable).

**4) Post a Green Snapshot of the piston![image|45x37]


#2

Two thoughts come to mind…

  1. I’d put all Sunrise actions in it’s own piston.
    (and do the same with Sunset)
  2. For the remaining block, I would change line 49 to:
    IF Time is NOT between 3am and Sunset
    (intentionally inverted to avoid spanning midnight)

Once that logic has been split, then you can focus on aborting the loop during the 20 minutes following the doorbell… (typically set with a variable)

IE: Your Doorbell piston sets @global variable… and your loop here checks that variable before coloring any lights…


#3

Adding a device to a @global will NOT update any pistons that reference that @global. When we add a new device to our home, we will have to edit any piston that wants to use it.


#4

Wouldn’t the color though remain with whatever it was before the abort happened?


#5

I thought global list of devices are used for that purpose? So that I can reuse a variable in different pistons.


#6

Honestly, I have not studied your code… I was just trying to pass along some good pointers for a solid piston.


This part works…
but it will not force pistons to Subscribe to any new devices that you may add to a @global.
(IE: It works well as conditional checks, but not as triggers)

The logic behind this is:
a piston subscribes to devices during the “Save” process. Not at time of execution.


#7

Thanks!
This is confusing. Don’t the pistons look at the devices in the global variable and just call those up. Why wouldn’t they see new devices added to the global variable?


#8

My apologies. I am an idiot.

In your piston above, there is no lightning bolts next to that variable, so you should be OK. What I meant is: a piston won’t be able to trigger off of any new devices added to the @global.
(Unless you Edit/Save or Pause/Resume them, that is)

Make more sense?