LUA Script Data from ext. Rest not usable Topic is solved

Moderator: leecollings

Post Reply
mrox
Posts: 11
Joined: Wednesday 18 October 2017 19:26
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

LUA Script Data from ext. Rest not usable

Post by mrox »

Hi,

i have a really strange problem. I dont know if im right in LUA or Blocky board, but lets start. I have the following LUA script, that gets me data every minute from a REST:

Code: Select all

commandArray = {}
now=os.date("*t")

-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
--      change the 5 below
if now.min % 1 == 0 then
   local stringVorlauf = assert(io.popen("curl -s http://10.168.2.60:8088/rest/devices/Vorlauf/attributes/Temp/value" , 'r'))
   local vorlauf = stringVorlauf:read('*all')
   
   local stringKollektor = assert(io.popen("curl -s http://10.168.2.60:8088/rest/devices/Kollektor/attributes/Temp/value" , 'r'))
   local kollektor = stringKollektor:read('*all')

   print("Pool Wasser: "..vorlauf)
   print("Pool Kollektor: "..kollektor)
   
   commandArray[1] = {['UpdateDevice'] = 18 .. '|0|' .. vorlauf}
   commandArray[2] = {['UpdateDevice'] = 19 .. '|0|' .. kollektor}
   
end
return commandArray
This is working fine, and i can see in the logfile the following entrys:

Code: Select all

2017-10-19 11:16:53.346 EventSystem: Script event triggered: Pool2
2017-10-19 11:16:55.108 LUA: Pool Wasser: 10.5
2017-10-19 11:16:55.108 LUA: Pool Kollektor: 10.5
When im using Blocky with these values, to say: If Temperature is higher then X set Y = ON, it will not work. If im using the temperature i get from Weather Underground it will work. So i expect that my LUA script is the problem. Do you guys have some idea?
SweetPants

Re: LUA Script Data from ext. Rest not usable

Post by SweetPants »

Can you try:

local cmd_vorlauf = string.format("%d|0|%.2f", 18, vorlauf)
local cmd_kollektor = string.format("%d|0|%.2f", 19, kollektor)

commandArray[1] = {['UpdateDevice'] = cmd_vorlauf}
commandArray[2] = {['UpdateDevice'] = cmd_kollektor}
mrox
Posts: 11
Joined: Wednesday 18 October 2017 19:26
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LUA Script Data from ext. Rest not usable

Post by mrox »

Many thanks! I understand now what was wrong. Thank you very much!
SweetPants

Re: LUA Script Data from ext. Rest not usable

Post by SweetPants »

mrox wrote: Saturday 21 October 2017 21:38 Many thanks! I understand now what was wrong. Thank you very much!
Your welcome, can you close/mark solved this topic?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest