We have moved at community.getvera.com

Author Topic: Get the device that triggers the scene  (Read 2010 times)

Offline psykokwak

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
Get the device that triggers the scene
« on: June 12, 2012, 10:25:40 am »
Hi all,
I have a scene that can be called by large number of devices (using triggers) and in the scene Luup code I would like to retrieve the device that triggers the scene.
I tried with "lul_device" but returned nil :/

Is there a way to do that ?

Offline garrettwp

  • Master Member
  • *******
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Get the device that triggers the scene
« Reply #1 on: June 12, 2012, 10:31:00 am »
I'm not sure if possible without parsing the logs.

- Garrett

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Get the device that triggers the scene
« Reply #2 on: June 12, 2012, 10:44:46 am »
There are two LUA code sections in a scene: The event trigger LUA code, and the scene's LUA code. The event trigger LUA code is naturally run before the scene's LUA code.

So set a global flag in the Event LUA code section?

Offline garrettwp

  • Master Member
  • *******
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Get the device that triggers the scene
« Reply #3 on: June 12, 2012, 10:58:44 am »
He would have to add lua code for each trigger to either log the trigger or notify the of the trigger via some notification. Can be tedious.

- Garrett

Offline psykokwak

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
Re: Get the device that triggers the scene
« Reply #4 on: June 12, 2012, 11:06:25 am »
Can be tedious.

Agree with you but it works.
On each trigger luup code I put "luup_device = xxx" where "xxx" is the device id that triggers
The luup_device variable exists in the luup scene code.

Maybe there is a better solution...

Offline psykokwak

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
Re: Get the device that triggers the scene
« Reply #5 on: June 12, 2012, 11:07:52 am »
Can be tedious.

Agree with you but it works.
On each trigger luup code I put "lul_device = xxx" where "xxx" is the device id that triggers
The lul_device variable exists in the luup scene code.

Maybe there is a better solution...

Offline djcampbell

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Get the device that triggers the scene
« Reply #6 on: December 29, 2014, 03:46:42 am »
Hi.  UI7 has taken away the option to include separate lua code for each device (although, oddly, existing code entered in UI5 still seems to work).   Did anyone come up with a more elegant Sutton to working out which device triggered a particular scene?

David

Offline aa6vh

  • Hero Member
  • *****
  • Posts: 642
  • Karma: +15/-0
Re: Get the device that triggers the scene
« Reply #7 on: December 29, 2014, 10:57:09 am »
Hi.  UI7 has taken away the option to include separate lua code for each device (although, oddly, existing code entered in UI5 still seems to work).   Did anyone come up with a more elegant Sutton to working out which device triggered a particular scene?

I believe this has been reported as a bug, so hopefully the UI7 interface will be fixed soon so that LUA code can again be added to the trigger.

Which is why I have not upgraded to UI7.