Jump to content

Call a program from a scene


Eric

Recommended Posts

Posted

All;

 

I've introduced a bit of complexity in some of my code by adding an Amazon Echo,  which is working great.

 

I have programs running that get a single button to operate 4 scenes.   (Wish I could remember where I got the original program...somewhere in this forum, I think....a great idea by someone).

 

Press the button once you get scene 1. (A couple of flags get set to False - True)

 

Press again and you get scene 2.  (Button press and test for False - True)   Set Flags to True False.

 

Press again for scene 3.  (Button press and test for True - False)   Set Flags to False - False.

 

Press again for scene 4.  (Button press and test for False - False)  Set Flags to True - True.

 

Press again for scene 1 again.  (Button press and test for True - True)  Set Flags for False - True as in step 1.

 

Press twice fast to turn all of them off.  (Fast on or Fast Off goes to the off scene.  set Flags to True - True)  That means the first scene always comes first from an 'off'.

 

There's additional code to get the indicator lights to come on at the end of each call,  and a brief wait so I'm sure the flags get set right.   Works great....but now comes the Echo.

 

When I call any of these scenes from Echo, the flags don't get set because no buttons were pushed.  (If I could call the programs to set the flags from the scene itself,  that would help,  but I'm not sure if that is possible.)

 

I have written a program to detect each of the scenes and set the flags. (Basically if all the scene conditions are true, I set the flags).  The problem is that if I change the scene even a little....like make a light be 60 % instead of 50 %,  I have to change the detector program.  Anyone have an idea that is a bit more elegant ?

 

Thanks

Posted

A scene cannot call a program. Post your program.

Posted (edited)

Trying to recreate and guess what has operated a scene is not a reliable way to do this. Other devices could operate the same devices to the levels and trigger your detection program falsely.

 

One technique I use is to capture all the command combinations and set a state variable to different values like this.

 

If

   SwitchLinc is switched 'FastON'

Then

   $sVariable = $cLEVEL.FULLON  (permanently contains XX value)

 

If

   SwitchLinc is switched 'ON'

Then

   $sVariable = $cLEVEL.ON  (permanently contains YY value)

 

If

   SwitchLinc is switched 'Dim''

Then

   $sVariable = $cLEVEL.DIM  (permanently contains ZZ value)

 

 

Then I use a bank of programs to detect these levels and operate scenes, Hue bulbs, and RGBWW strips etc.

 

If

   $sVariable = $cLEVEL.DIM

Then

   set sceneXXX on

 

if

 $sVariable = $cLEVEL.ON

Then

   set sceneYYY on

   run Resource 'Turn Hues on Red'

   etc....

 

Advantages?

- any program can look at the level of settings by examining  $sVariable

- any program can borrow a light in the scenes (make bright to work on that side of the room) and then restore it by shoving the value back in the variable when you are done.

- multiple programs can trigger from the same $sVariable.

 

The initiate logic can alternate  from scene from the same button push style.

 

Here's one to alternate two levels of lighting from each tap on the switch.

 

If

     SwichLinc is switched 'FastOn'

   AND

     $sVariable = $cLEVEL.FASTON

Then

  $sVariable = $cLEVEL.TVMODE

Else

   $sVariable = $cLEVEL.FASTON

 

 

 

Making sense?

Edited by larryllix
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.5k
×
×
  • Create New...