Scene Timers Read in LUA

Moderator: leecollings

Post Reply
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Scene Timers Read in LUA

Post by TimH »

Hi,

it is possible to read out the Timers of a Scene in LUA and the Command(On/Off)?

Thanks

TimH
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Scene Timers Read in LUA

Post by jvdz »

This is a way to do a JSON call and translate the returned data:

Code: Select all

-- LUA to get GASMETER usage
-- Load necessary Lua libraries
http = require "socket.http";
socket = require "socket";
https = require "ssl.https";
JSON = require "JSON";
--~ --Get Scene Timers
local t, jresponse, status, decoded_response,idx
-- ### update the next 2 lines ##########################################
idx=9     -- IDX of the Scene
t = "http://192.168.xx.xx:8080/json.htm?type=scenetimers&idx="..tostring(idx)
-- ###################################################################
jresponse, status = http.request(t)
decoded_response = JSON:decode(jresponse)
result = decoded_response["result"]
--
-- List all SceneTimers
--
if result == nil then
	print(os.date("%X").." No scene timers found for IDX "..idx)
else
	for i = 1, #result do
	record = result[i]
		if type(record) == "table" then
			day = record["d"]
			value = record["v"]
			print(os.date("%X").." "..i..
			"  Active="..record["Active"]..
			"  Cmd="..record["Cmd"]..
			"  Date="..record["Date"]..
			"  Hue="..record["Hue"]..
			"  Level="..record["Level"]..
			"  Randomness="..record["Randomness"]..
			"  Time="..record["Time"]..
			"  Type="..record["Type"]..
			"  idx="..record["idx"]
			)
		end
	end
end
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Scene Timers Read in LUA

Post by TimH »

Thank you. I will try it the next days.
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Scene Timers Read in LUA

Post by TimH »

Hello,

i have tried your Script but i got some failure with the libraries.
I use a Synology Diskstation to run Domoticz and this don't have the libraries.
Searching the Internet don't look good for Synology Lua Libraries.

Have anybody the right libraries or a idea where i can fount them?

Thanks!
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Scene Timers Read in LUA

Post by jvdz »

The libraries can be found here: https://www.domoticz.com/wiki/Remote_Co ... _Libraries
This is a description for a Raspberry Pi so might need tweaking.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Scene Timers Read in LUA

Post by TimH »

Hi,

thank you for the Link.
I tried to translate it to Synology but i get failure.

Where are defined the Folder, where the location of the Libraries?
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Scene Timers Read in LUA

Post by jvdz »

I think the error message, you get about not being able to find the require("LIB"), is telling you in which directories it was looking for these functions? at least that is what I seem to remember happening for me on a raspberry.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Scene Timers Read in LUA

Post by TimH »

HI.
error Message in domoticz:

Code: Select all

2016-12-14 08:14:03.753 Error: EventSystem: in READOUT: [string "-- LUA to get GASMETER usage..."]:3: module 'socket.http' not found:
no field package.preload['socket.http']
no file '/usr/local/share/lua/5.2/socket/http.lua'
no file '/usr/local/share/lua/5.2/socket/http/init.lua'
no file '/usr/local/lib/lua/5.2/socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http/init.lua'
no file './socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket/http.so'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
I have unpack the Files as indicated in the instructions and in the existing LUA-Folder from the Diskstation.
But i Think i must change the locating Folder for the Library.
wervisser
Posts: 29
Joined: Monday 28 November 2016 18:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Scene Timers Read in LUA

Post by wervisser »

Bump...

Did you by any chance got this fixed ?
niki_lauda
Posts: 118
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Scene Timers Read in LUA

Post by niki_lauda »

TimH wrote: Wednesday 14 December 2016 18:38 HI.
error Message in domoticz:

Code: Select all

2016-12-14 08:14:03.753 Error: EventSystem: in READOUT: [string "-- LUA to get GASMETER usage..."]:3: module 'socket.http' not found:
no field package.preload['socket.http']
no file '/usr/local/share/lua/5.2/socket/http.lua'
no file '/usr/local/share/lua/5.2/socket/http/init.lua'
no file '/usr/local/lib/lua/5.2/socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http/init.lua'
no file './socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket/http.so'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
I have unpack the Files as indicated in the instructions and in the existing LUA-Folder from the Diskstation.
But i Think i must change the locating Folder for the Library.
Did you fix it?
niki_lauda
Posts: 118
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Scene Timers Read in LUA

Post by niki_lauda »

wervisser wrote: Monday 20 March 2017 23:47 Bump...

Did you by any chance got this fixed ?
Did you fix it?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest