eddieb wrote: ↑Tuesday 27 August 2019 21:30
as you can see, all rows like
<input name="inTemp" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="24.9" maxlength="5" />
contain data which I would like to use in domoticz. In this line the indoor temp = 24.9 degrees
Please state your domoticz / dzVents versions
Find below a first dzVents prototype based on test data.
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."
1st. step: change your IP to the actual one and see if the scripts executes without errors and save the relevant loglines
2nd. step: (if no errors in 1st step): change testHTM in the 2 for loops to item.data and see if the scripts executes without errors and save the relevant loglines
If anything is not clear yet do not hesitate to ask.
Code: Select all
local scriptVar = 'ambiantWeather'
return
{
on =
{
timer = { 'every minute' },
httpResponses = { scriptVar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local ambiantWeatherStationIP = 'xxx.xxx.xxx.xxx' -- change to IP of your weatherstation
local function getambiantWeatherStationData()
local url = 'http://' .. ambiantWeatherStationIP .. '/livedata.htm'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processHTM()
local shortFieldNames = {
inTemp="Indoor Temperature",
inHumi="Indoor Humidity",
AbsPress="Absolute Pressure",
RelPress="Relative Pressure",
outTemp="Outdoor Temperature",
outHumi="Outdoor Humidity",
windir="Wind Direction",
avgwind="Wind Speed",
gustspeed="Wind Gust",
dailygust="Max Daily Gust",
solarrad="Solar Radiation",
uv="UV",
uvi="UVI",
pm25="PM2.5",
rainofhourly="Hourly Rain Rate",
eventrain="Event Rain",
rainofdaily="Daily Rain",
rainofweekly="Weekly Rain",
rainofmonthly="Monthly Rain",
rainofyearly="Yearly Rain",
}
local testHTM = '"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>LiveData</title><link href="axcss0.css" rel="stylesheet" type="text/css" /></head><body><table width="800" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td colspan="2" align="right" bgcolor="#0088F7"> </td></tr><tr><td colspan="2" bgcolor="#FFFFFF"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="20" height = "80"> </td> <td ><img src="img/1.jpg" width="74" height="80" ></td> <td width="10"> </td> <td class="txtstyle_1" >AmbientWeather 4.5.7</td> </tr></table></td></tr><tr> <td colspan="2" align="right" bgcolor="#60B7FF"> </td></tr><tr><td colspan="2" align="left" bgcolor="#C0C0C0"><table width="20" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="bscsetting.htm">Local Network</a></div></td><td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="weather.htm">Weather Network</a></div></td><td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="station.htm">Station Settings</a></div></td><td bgcolor="#EDEFEF"><div class="menuitem_1"><a href="livedata.htm">Live Data</a></div></td><td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="correction.htm">Calibration</a></div></td> </tr></table></td></tr><form name="livedata" method="POST" onsubmit="return chkForm(0);"> <tr><td colspan="2" bgcolor="#EDEFEF"> </td></tr> <tr><td colspan="2" bgcolor="#EDEFEF"><div class="subitem_1">Live Data</div></td></tr> <tr><td width="448" bgcolor="#EDEFEF"><div class="item_1">Receiver Time:</div></td><td width="352" bgcolor="#EDEFEF"> <input name="CurrTime" disabled="disabled" type="text" class="item_2" style="WIDTH: 120px" value="20:34 8/27/2019" maxlength="16"/></td></tr><tr><td width="448" bgcolor="#EDEFEF"><div class="item_1">Indoor Sensor ID and Battery </div></td><td width="352" bgcolor="#EDEFEF"><input name="IndoorID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0x17" maxlength="5" /><input name="inBattSta" disabled="disabled" type="text" class="item_2" style="WIDTH: 100px" value="Normal" maxlength="12" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Outdoor Sensor ID and Battery</div></td><td bgcolor="#EDEFEF"> <input name="Outdoor1ID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0xef" maxlength="5" /><input name="outBattSta1" disabled="disabled" type="text" class="item_2" style="WIDTH: 100px" value="Normal" maxlength="12" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Outdoor2 Sensor ID and Battery</div></td><td bgcolor="#EDEFEF"> <input name="Outdoor2ID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0x--" maxlength="5" /><input name="outBattSta2" disabled="disabled" type="text" class="item_2" style="WIDTH: 100px" value="- -" maxlength="12" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Indoor Temperature</div></td><td bgcolor="#EDEFEF"><input name="inTemp" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="24.9" maxlength="5" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Indoor Humidity</div></td><td bgcolor="#EDEFEF"><input name="inHumi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="59" maxlength="3" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Absolute Pressure </div></td><td bgcolor="#EDEFEF"><input name="AbsPress" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1012.90" maxlength="6" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Relative Pressure </div></td><td bgcolor="#EDEFEF"><input name="RelPress" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1010.90" maxlength="6" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Outdoor Temperature</div></td><td bgcolor="#EDEFEF"><input name="outTemp" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="22.9" maxlength="5" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Outdoor Humidity </div></td><td bgcolor="#EDEFEF"><input name="outHumi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="87" maxlength="3" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Wind Direction </div></td><td bgcolor="#EDEFEF"><input name="windir" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="166" maxlength="5" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Wind Speed </div></td><td bgcolor="#EDEFEF"><input name="avgwind" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0.0" maxlength="5" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Wind Gust </div></td><td bgcolor="#EDEFEF"><input name="gustspeed" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0.0" maxlength="5" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Max Daily Gust </div></td><td bgcolor="#EDEFEF"><input name="dailygust" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="20.2" maxlength="5" /></td></tr> <tr><td bgcolor="#EDEFEF"><div class="item_1">Solar Radiation </div></td><td bgcolor="#EDEFEF"><input name="solarrad" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0.00" maxlength="12" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">UV </div></td><td bgcolor="#EDEFEF"><input name="uv" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1" maxlength="12"></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">UVI </div></td><td bgcolor="#EDEFEF"><input name="uvi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0" maxlength="3"></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">PM2.5</div></td><td bgcolor="#EDEFEF"><input name="pm25" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="----" maxlength="8" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Hourly Rain Rate</div></td><td bgcolor="#EDEFEF"><input name="rainofhourly" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0.00" maxlength="8" /></td></tr><tr><td bgcolor="#EDEFEF"><div class="item_1">Event Rain</div></td><td bgcolor="#EDEFEF"><input name="eventrain" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="8.70" maxlength="8" /></td></tr> <form name="Rain_1" method="POST" onsubmit="return chkForm(0);"> <tr> <td bgcolor="#EDEFEF"><div class="item_1">Daily Rain</div></td> <td bgcolor="#EDEFEF"><input name="rainofdaily" type="text" class="item_2" style="WIDTH: 80px" value="8.70" maxlength="8" /><span id="rainofdaily_msg" class="errMsg0"></span></td> </tr> <tr> <td bgcolor="#EDEFEF"><div class="item_1">Weekly Rain</div></td> <td bgcolor="#EDEFEF"><input name="rainofweekly" type="text" class="item_2" style="WIDTH: 80px" value="8.70" maxlength="8" /><span id="rainofweekly_msg" class="errMsg0"></span></td> </tr> <tr> <td bgcolor="#EDEFEF"><div class="item_1">Monthly Rain</div></td> <td bgcolor="#EDEFEF"><input name="rainofmonthly" type="text" class="item_2" style="WIDTH: 80px" value="58.80" maxlength="8" /><span id="rainofmonthly_msg" class="errMsg0"></span></td> </tr> <tr> <td bgcolor="#EDEFEF"><div class="item_1">Yearly Rain</div></td> <td bgcolor="#EDEFEF"><input name="rainofyearly" type="text" class="item_2" style="WIDTH: 80px" value="475.80" maxlength="8" /><span id="rainofyearly_msg" class="errMsg0"></span></td> </tr> <tr> <td colspan="2" bgcolor="#EDEFEF"> </td> </tr> <tr align="center"> <td colspan="2" bgcolor="#EDEFEF"><input name="Apply" type="submit" class="item_2" style="WIDTH: 60px; HEIGHT: 24px;" onclick="setSubmitType(1)" value="Apply" /> <input name="Cancel" type="reset" class="item_2" style="WIDTH: 60px; HEIGHT: 24px;" value="Cancel" /></td> </tr> </form> <tr><td colspan="2" bgcolor="#EDEFEF"> </td> </tr><tr><td colspan="2" align="center" bgcolor="#EDEFEF"> <input name="rain_Default" type="button" class="item_2" style="WIDTH: 110px; HEIGHT: 24px;" onclick="raindef()" value="Rain Reset"><input id="refresh_st" type="button" class="item_4" style="WIDTH: 110px; HEIGHT: 24px;" onclick="uiCtrl(this.value);" value="Refresh" /><input id="refresh_sp" type="button" class="item_2" style="WIDTH: 110px; HEIGHT: 24px;" onclick="uiCtrl(this.value);" value="Stop Refresh" /></td></tr></form><tr><td colspan="2" bgcolor="#EDEFEF"> </td></tr><tr><td colspan="2" bgcolor="#C0C0C0"> </td></tr></table> <script src="axjs0.js" type="text/javascript"></script><script language="JavaScript" type="text/javascript"><!--var rfTaskRuningFlag = 0, rfTimeId;uiCtrl("Refresh"); function uiCtrl(uiCmd) { if (uiCmd=="Refresh"){ document.getElementById("refresh_st").disabled = true; document.getElementById("refresh_sp").disabled = false; rfTaskRuningFlag = 1; rfTaskState = 0; rfTimeId = setInterval("ss()", 16000); }else if (uiCmd=="Stop Refresh"){ document.getElementById("refresh_st").disabled = false; document.getElementById("refresh_sp").disabled = true; rfTaskRuningFlag = 0; clearInterval(rfTimeId); } } function ss() { if (rfTaskRuningFlag) { window.location.reload(); } } --> </script></body></html>"'
local lines = {}
local counter = 0
for s in string.gmatch( testHTM, "[^%s, ]+" ) do
if string.find(s,'name=') then
dz.log(s:gsub('name=',''),dz.LOG_DEBUG)
lines[counter] = {}
lines[counter].name = s:gsub('name=','')
counter = counter + 1
end
end
counter = 1
for s in string.gmatch( testHTM, "[^%s, ]+" ) do
if string.find(s,'value=') then
dz.log(s:gsub('value=',''),dz.LOG_DEBUG)
if lines[counter] == nil then lines[counter] = {} end
lines[counter].value = s:gsub('value=','')
counter = counter + 1
end
end
dz.utils.dumpTable(lines)
end
if item.isTimer then
getambiantWeatherStationData()
elseif item.ok then -- statusCode == 2xx
dz.log(item.data,dz.LOG_DEBUG)
processHTM(item.data)
else
dz.log('Could not get (good) data from ' .. scriptVar,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