Author Topic: Any way to retrieve the last run time of a scene?  (Read 264 times)

Offline Gabriel

  • Sr. Newbie
  • *
  • Posts: 40
  • Karma: +3/-0
Any way to retrieve the last run time of a scene?
« on: February 08, 2018, 11:37:20 am »
I am wondering how to retrieve the last run time of a scene in LUA code.
The following LUUP requests returns data of a scene, including the last_run variable, in a JSON format.
Code: [Select]
http://VERA_IP:3480/data_request?id=scene&action=list&scene=5
Based on this, I am looking for a way to retrieve the last_run value...

Offline akbooer

  • Master Member
  • *******
  • Posts: 5878
  • Karma: +251/-69
  • "Less is more"
Re: Any way to retrieve the last run time of a scene?
« Reply #1 on: February 08, 2018, 11:57:43 am »
Yes, you just need to decode the scene JSON returned by that request and the answer is in the last_run element...

Code: [Select]
local json = require "dkjson"
local _, info = luup.inet.wget "http://0.0.0.0:3480/data_request?id=scene&action=list&scene=5"
local x = json.decode (info)
print (x.last_run)
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 Gabriel

  • Sr. Newbie
  • *
  • Posts: 40
  • Karma: +3/-0
Re: Any way to retrieve the last run time of a scene?
« Reply #2 on: February 09, 2018, 02:56:21 am »
I did not know that there is a json parser ready to be loaded, thank you very much for your help! That is going to be quite useful (even though retrieving a vera-managed value from wget is awfully hackish :-) )

Is there a list of lua module available on the Vera?

Offline akbooer

  • Master Member
  • *******
  • Posts: 5878
  • Karma: +251/-69
  • "Less is more"
Re: Any way to retrieve the last run time of a scene?
« Reply #3 on: February 09, 2018, 03:29:07 am »
Not as far as I know.  You'd just have to try and see.  AFAIK it includes LuaSocket, LuaSec, LuaFileSystem, ...

The output of this should give a clue:

Code: [Select]
ls /usr/lib/lua
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.