Humidity dummy sensor

Moderator: leecollings

Post Reply
Swokey
Posts: 3
Joined: Friday 13 May 2016 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Humidity dummy sensor

Post by Swokey »

I'm trying to update an dummy sensor with the current humidity from a Cresta TX320

I'have the following lua script:

Code: Select all

--script_device_Tempdroogkast.lua
local sensorcr = 'Cresta' --name of the sensor that gets created when you add t$
local idx = 189 --idx of the humidity sensor you created for scrapping the temp$
commandArray = {}

if devicechanged[sensorcr] then
   sCrestaTemp, sCrestaHumidity = otherdevices_svalues[sensorcr]:match("([^;]+)$
   sCrestaHumidity = tonumber(sCrestaHumidity)
   commandArray['UpdateDevice'] = idx .. '|0|' .. (sCrestaHumidity)
   print("Droogkast luchtvochtigheid is " .. sCrestaHumidity .. "% ");
end
return commandArray
----------

The log file gives me the following back:
2016-05-13 08:52:36.065 LUA: Droogkast luchtvochtigheid is 63%
2016-05-13 08:53:19.067 EventSystem: Script event triggered: /home/swokey/domoticz/scripts/lua/script_device_humdroogkast.lua

So the script is executed, but the 'last seen' of the device (189) is then also 8:53 only the humidity is 0%

Any idea why the humidity isn't updated?
Last edited by Swokey on Friday 13 May 2016 15:26, edited 1 time in total.
Swokey
Posts: 3
Joined: Friday 13 May 2016 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidity dummy sensor

Post by Swokey »

I'm also trying to do it with JSON, but i don't understand how to add that in LUA.

When I execute the following url (http://192.168.2.21:8080/json.htm?type= ... &nvalue=25) within a browser the dummy sensor is updated.

How can I add this (with variable sCrestaHumidity) to LUA?
Swokey
Posts: 3
Joined: Friday 13 May 2016 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Humidity dummy sensor

Post by Swokey »

I solved it with JSON, see below code for someone who is looking for the same:

Code: Select all

--script_device_Tempdroogkast.lua
local sensorcr = 'Cresta' --name of the sensor that gets created when you add the Cresta device (and that contains multiple values like temperature, humidi$
local idx = 189 --idx of the virtual temperature sensor you created for scrapping the temperature
commandArray = {}

if devicechanged[sensorcr] then
   sCrestaTemp, sCrestaHumidity = otherdevices_svalues[sensorcr]:match("([^;]+);([^;]+)")
   sCrestaHumidity = tonumber(sCrestaHumidity)
   commandArray['OpenURL'] = 'http://192.168.2.21:8080/json.htm?type=command&param=udevice&idx=189&nvalue='..sCrestaHumidity..''
   print("Droogkast luchtvochtigheid is " .. sCrestaHumidity .. "% ");
end
return commandArray
User avatar
AlwinHummels
Posts: 7
Joined: Sunday 22 November 2015 20:25
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Dordrecht, The Netherlands
Contact:

Re: Humidity dummy sensor

Post by AlwinHummels »

Looks very impressive, can ik also reverse? To dummy temp only? I use it for my refrigeratorson 😃 so I only need the temperature.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest