Author Topic: Detect which scene triggered  (Read 159 times)

Offline enforces

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Detect which scene triggered
« on: August 12, 2017, 09:50:15 am »
The light is turned on with 3 different scenes.

1st scene: movement
2nd scene: Manual
3rd scene: only when night is and the TV is on

Scene 4: Turns off the light when the TV is turned off.

How to make a script luup to scene 4 will only work when the light is triggered by scene 3?

Offline jswim788

  • Sr. Member
  • ****
  • Posts: 474
  • Karma: +22/-2
Re: Detect which scene triggered
« Reply #1 on: August 12, 2017, 05:40:47 pm »
Here's one possibility: add a virtual switch that is only turned on by scene 3.  Then make scene 4 conditional on that virtual switch being true.  Scene 4 should also turn off the virtual switch when it runs.

Offline akbooer

  • Master Member
  • *******
  • Posts: 5112
  • Karma: +221/-67
  • "Less is more"
Re: Detect which scene triggered
« Reply #2 on: August 12, 2017, 05:59:16 pm »
You used to be able to put Lua code into individual triggers in UI5... not sure if that's still possible in UI7?

Anyway, if so, you can set a global variable to a unique value within each trigger code and then test which it is in the scene Lua itself.



As an aside, openLuup has a variable lul_scene, available for testing within the scene code, which gives the current running scene number.
« Last Edit: August 12, 2017, 06:06:31 pm by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline enforces

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Detect which scene triggered
« Reply #3 on: August 13, 2017, 05:52:42 pm »
jswim788 - It's works! Thanks. :)