Scene Timers Read in LUA
Moderator: leecollings
-
- 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
Hi,
it is possible to read out the Timers of a Scene in LUA and the Command(On/Off)?
Thanks
TimH
it is possible to read out the Timers of a Scene in LUA and the Command(On/Off)?
Thanks
TimH
- 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
This is a way to do a JSON call and translate the returned data:
Jos
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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- 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
Thank you. I will try it the next days.
-
- 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
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!
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!
- 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
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
This is a description for a Raspberry Pi so might need tweaking.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- 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
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?
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?
- 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
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
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- 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
HI.
error Message in domoticz:
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.
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'
But i Think i must change the locating Folder for the Library.
-
- 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
Bump...
Did you by any chance got this fixed ?
Did you by any chance got this fixed ?
-
- 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
Did you fix it?TimH wrote: ↑Wednesday 14 December 2016 18:38 HI.
error Message in domoticz:I have unpack the Files as indicated in the instructions and in the existing LUA-Folder from the Diskstation.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'
But i Think i must change the locating Folder for the Library.
-
- Posts: 118
- Joined: Saturday 31 August 2013 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Eindhoven (NL)
- Contact:
Who is online
Users browsing this forum: No registered users and 1 guest