Can you try this dzVents script ?
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
local scriptVersion = '0.201909021700'
local scriptVar = 'thermometerIP_' .. scriptVersion
--[[
this dzVents script is used to collect data from ether thermometer Because there is no known API / JSON interface at the time this script was created, it uses a call to the Web Gui and interprets the returned XML code.
Before activating the script:
please read the GETTING STARTED section of the dzVents wiki.
change xxx.xxx.xxx.xxx in this script to the IP of your IP thermometer
define a dummy hardware in domoticz if not already done
define virtual sensor temp/humidity for this dummy hardware
and change the name in the device declarations
]]--
return
{
on =
{
timer = { 'every 5 minutes' },
httpResponses = { scriptVar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
-- ********** local settings below this line *************
-- change to IP of your thermometer
local thermometerIP = 'xxx.xxx.xxx.xxx'
-- Change devicename below to reflect your device name.
-- You can also use idx but if you do don't use the surrounding quotes.
local temperatureHumidity = dz.devices('xmlTempHum')
-- ********** No changes necessary below this line *************
-- this function will call the webpage
local function getThermometerXML()
local url = 'http://' .. thermometerIP .. '9050/fresh.xml'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processXML(xmlData)
local extractedData = {}
for word in string.gmatch(xmlData,"(\" val=\"%d+.%d*)") do -- loop over all 'words' in the data and extract " val="##.##
extractedData[#extractedData + 1] = word:gsub('\" val=\"','') -- put value (after removing " val=" from the found 'word')
end
return extractedData
end
local function updateDevice(values)
local function humidityStatus(temperature, humidity) -- as used in domoticz source
humidity = tonumber(humidity)
temperature = tonumber(temperature)
if humidity <= 30 then return dz.HUM_DRY
elseif humidity >= 70 then return dz.HUM_WET
elseif humidity >= 35 and humidity <= 65 and temperature >= 22 and temperature <= 26 then return dz.HUM_COMFORTABLE end
return dz.HUM_NORMAL
end
temperatureHumidity.updateTempHum(values[1], values[2], humidityStatus(values[1],values[2]))
end
-- main
if item.isTimer then
getThermometerXML()
elseif item.ok then -- statusCode == 2xx
updateDevice(processXML(item.data))
else
dz.log('Could not get (good) data from ' .. thermometerIP,dz.LOG_ERROR)
dz.log(item.data,dz.LOG_DEBUG)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki