Hi Toon experts!
Does anyone know if / where the Toon 2 's humidity sensor can be read remotely?
Is the humidity percentage visible at some sort of URL and can it be retrieved biy some json string (so I can show it in Domoticz)?
Thanks in advance...
monitoring Toon 2 humidity sensor
Moderators: marcelr, TheHogNL, Toonz
Re: monitoring Toon 2 humidity sensor
Oh, just found http://my.toon2.ip.adress/tsc/sensors:
{"temperature":18.1, "humidity":77.2, "tvoc":892, "eco2":2087, "intensity":0}
Now let's find out how to get the humidity value into Domotcz...
{"temperature":18.1, "humidity":77.2, "tvoc":892, "eco2":2087, "intensity":0}
Now let's find out how to get the humidity value into Domotcz...
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: monitoring Toon 2 humidity sensor
Maybe this will help you.
It is a Dzvents script (not tested, because it is a snip from my total Toon script)
viewtopic.php?p=100776&hilit=script#p100776
It is a Dzvents script (not tested, because it is a snip from my total Toon script)
viewtopic.php?p=100776&hilit=script#p100776
Code: Select all
local ToonTempHum = 588 -- Vochtsensor ID
return {
on = { timer = {'every minute'},
},
logging = { level = domoticz.LOG_ERROR, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(domoticz)
local ToonIP = domoticz.variables('UV_ToonIP').value -- IP address of your Toon
-- Vochtsensor
local handle3 = assert(io.popen(string.format('curl http://%s//tsc/sensors', ToonIP)))
local TSCsensors = handle3:read('*all')
handle3:close()
jsonTSCsensors = json:decode(TSCsensors)
-- Update the BoilerMoisture sensor to current value
local TSCsensors_hum = tonumber(jsonTSCsensors.humidity)
local TSCsensors_temp = tonumber(jsonTSCsensors.temperature)
domoticz.devices(ToonTempHum).updateTempHum(TSCsensors_temp,TSCsensors_hum).silent()
end
}
Re: monitoring Toon 2 humidity sensor
Wow, thanks.
I did some research and after lots of trial and error got this to update an perccentage switch.
But your script seems much nicer and combines temperature and humidity into one device...
local scriptVar = 'humidityRetrieved'
return
{
on =
{
timer =
{
'every 5 minutes' -- to trigger the request
},
-- devices =
-- {
-- 'JSONTrigger' -- to trigger the request during development / test
-- },
httpResponses =
{
scriptVar, -- must match with the callback passed to the openURL command
},
},
logging =
{
level = domoticz.LOG_INFO,
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer or item.isDevice
then
dz.openURL(
{
url = 'http://my-toon-ip/tsc/sensors',
method = 'GET',
callback = scriptVar, -- see httpResponses above.
})
else
if item.ok then
myJSON = ( item.isJSON and item.json ) or dz.utils.fromJSON(item.data) -- JSON to Lua table ( also when not recognized as JSON )
if _G.logLevel == dz.LOG_DEBUG then
dz.utils.dumpTable(myJSON) -- show structure of converted JSON -- ( only for debug )
end
local humidityValue = dz.utils.round(myJSON["humidity"], 0)
dz.log("Toon luchtvochtigheid = ".. humidityValue .. "%",dz.LOG_DEBUG)
-- update Toon Humidity device in DomotiZ
dz.devices('Toon luchtvochtigheid').updatePercentage(humidityValue)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
end
end
}
I did some research and after lots of trial and error got this to update an perccentage switch.
But your script seems much nicer and combines temperature and humidity into one device...
local scriptVar = 'humidityRetrieved'
return
{
on =
{
timer =
{
'every 5 minutes' -- to trigger the request
},
-- devices =
-- {
-- 'JSONTrigger' -- to trigger the request during development / test
-- },
httpResponses =
{
scriptVar, -- must match with the callback passed to the openURL command
},
},
logging =
{
level = domoticz.LOG_INFO,
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer or item.isDevice
then
dz.openURL(
{
url = 'http://my-toon-ip/tsc/sensors',
method = 'GET',
callback = scriptVar, -- see httpResponses above.
})
else
if item.ok then
myJSON = ( item.isJSON and item.json ) or dz.utils.fromJSON(item.data) -- JSON to Lua table ( also when not recognized as JSON )
if _G.logLevel == dz.LOG_DEBUG then
dz.utils.dumpTable(myJSON) -- show structure of converted JSON -- ( only for debug )
end
local humidityValue = dz.utils.round(myJSON["humidity"], 0)
dz.log("Toon luchtvochtigheid = ".. humidityValue .. "%",dz.LOG_DEBUG)
-- update Toon Humidity device in DomotiZ
dz.devices('Toon luchtvochtigheid').updatePercentage(humidityValue)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
end
end
}
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: monitoring Toon 2 humidity sensor
You need to use the Temp+Hum sensor type as a virtual switch
P.S. can you use <code> when posting a part of the script.
See </> button above the text box
P.S. can you use <code> when posting a part of the script.
See </> button above the text box
Code: Select all
Makes it more readable.....