Author Topic: A function that returns the calling scene number?  (Read 331 times)

Offline tlough1

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
A function that returns the calling scene number?
« on: July 22, 2018, 04:47:01 pm »
I need to be able to take action within a function based on the ID number of the scene that called the function?

I realise I could set a variable to the scene number before calling the function. But does anyone know a way to obtain this from Vera itself? - a neater solution.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: A function that returns the calling scene number?
« Reply #1 on: July 22, 2018, 05:05:04 pm »
AFAIK, there is no good way.  This is simply another thing which Vera/MiOS forgot.

In my own emulation of MiOS, openLuup, I implemented a variable lul_scene, in the same spirit as lul_device, because I could find no valid alternative.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline tlough1

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: A function that returns the calling scene number?
« Reply #2 on: July 23, 2018, 07:47:19 am »
Thanks, that's what I suspected - unless anyone comes up with a better way, I will need to set a variable before the function call.


Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: A function that returns the calling scene number?
« Reply #3 on: July 23, 2018, 10:25:44 am »
There used to be Lua code that could be run for individual triggers.  I believe that UI access to that may have gone away, but I think that it is still functional within the system.  It can be set by defining the scene in JSON and running an HTTP request.  Might help.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline therealdb

  • Full Member
  • ***
  • Posts: 243
  • Karma: +6/-0
  • Automate all the things!
Re: A function that returns the calling scene number?
« Reply #4 on: July 23, 2018, 12:29:23 pm »
I simply define a global table and reference the ids this way.
Then I call my function passing the id. Something like scenes.frontdooropen.
Tricky but working OK for me and not related to scene ids at all.
Vera Edge EU, Fibaro FGRM 222 (14), Fibaro FGS 223 (26), Fibaro FGS 222 (6), Fibaro UBS (2), Fibaro+N Plug (3), NeoCoolCam Door Sensor (3), PIR (2) & Plugs (2), Nest (3), Home Server running my own integrations, Harmony Hub, OpenSprinkler, Personal Weather Station, Sonoff TH & more

Offline tlough1

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: A function that returns the calling scene number?
« Reply #5 on: July 24, 2018, 02:32:49 pm »
My other potential method is to have multiple functions, one for each scene I wish to reference - just name them differently.