Page 1 of 1
attempt to index a nil value
Posted: Thursday 04 June 2020 9:56
by Doornenburgweer
Since a couple of days I receive a error message in the error log:
Error: dzVents: Error: (3.0.2) ...moticz/scripts/dzVents/generated_scripts/Meteobridge.lua:114: attempt to index a nil value (field 'SOILA')
With the help of Waaren I created the next script:
Code: Select all
local url = 'http://www.website.com/domoticz.txt'
local scriptVar = 'get_meteoBridge'
return
{
on =
{
timer =
{
'every 5 minutes', -- change this to 5 minute after testing
},
devices =
{
'triggerhulp',
},
httpResponses =
{
scriptVar,
},
},
--logging =
--{
-- level = domoticz.LOG_DEBUG,
-- marker = scriptVar,
--},
execute = function(dz, item)
local temperatureBSensor = dz.devices(97) --indoor temperatuur
local temperatureSensor = dz.devices(82) --outside temperature
local rainSensor = dz.devices(83) -- rain
local windSensor = dz.devices(84) -- wind
local dewpointSensor = dz.devices(95) -- define as a combined Temperature, Humidity, Barometer sensor
local humiditySensor = dz.devices(96) -- Humidity sensor
local pressureSensor = dz.devices(86) -- barometer
local radiationSensor = dz.devices(89) -- radiation
local SoilATempSensor = dz.devices(90) -- soil temperature -5 cm
local SoilBTempSensor = dz.devices(91) -- soil temperature -10 cm
local SoilCTempSensor = dz.devices(92) -- soil temperature -15 cm
local SoilDTempSensor = dz.devices(93) -- grass temperature +10 cm
local SoilASensor = dz.devices(99) -- soil moisture -20 cm
local SoilBSensor = dz.devices(101) -- soil moisture -40 cm
local ETsensor = dz.devices(120) -- Evapotranspiration
local function windBearing2Direction(degrees)
local function between(value, center, variance)
variance = variance or 22.5
local value = tonumber(value)
return ( value >= (center - variance) or value <= (center + variance) )
end
if between(degrees, 45) then return 'NW'
elseif between(degrees, 90) then return 'W'
elseif between(degrees, 135) then return 'Sw'
elseif between(degrees, 180) then return 'S'
elseif between(degrees, 225) then return 'SE'
elseif between(degrees, 270) then return 'E'
elseif between(degrees, 315) then return 'NE'
end
return 'N'
end
local function humStatus(temperature, humidity)
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
else return dz.HUM_NORMAL end
end
function baroForecast(pressure)
if pressure == nil then return dz.BARO_NOINFO
elseif pressure < 1003 then return dz.BARO_RAIN
elseif pressure < 1013 then return dz.BARO_CLOUDY
elseif pressure < 1033 then return dz.BARO_PARTLYCLOUDY
end
return dz.BARO_SUNNY
end
if item.isHTTPResponse then
if item.ok then
rt = dz.utils.fromXML(item.data)
-- dz.log(item,dz.LOG_DEBUG)
-- dz.utils.dumpTable(rt)
-- get the values from the table and add missing values via weather functions
local temperatureB = tonumber(rt.logger.THB._attr.temp)
local temperature = tonumber(rt.logger.TH._attr.temp)
local dewpoint = rt.logger.TH._attr.dew
local rainTotal = rt.logger.RAIN._attr.total
local rainRate = rt.logger.RAIN._attr.rate
local windSpeed = rt.logger.WIND._attr.wind
local windBearing = rt.logger.WIND._attr.dir
local windChill = rt.logger.WIND._attr.chill
local windGust = rt.logger.WIND._attr.gust
local windDirection = windBearing2Direction(windBearing)
local humidity = tonumber(rt.logger.THB._attr.hum)
local humidityStatus = humStatus(temperature, humidity)
local pressure = tonumber(rt.logger.THB._attr.press)
local forecast = baroForecast(pressure)
local radiation = rt.logger.SOL._attr.rad
local soilmoistureA = tonumber(rt.logger.SOILA._attr.hum)
local soilmoistureB = tonumber(rt.logger.SOILB._attr.hum)
local SoilATemp = tonumber(rt.logger.SOILA._attr.temp)
local SoilBTemp = tonumber(rt.logger.SOILB._attr.temp)
local SoilCTemp = tonumber(rt.logger.SOILC._attr.temp)
local SoilDTemp = tonumber(rt.logger.SOILD._attr.temp)
local Evap = rt.logger.SOL._attr.evo
-- dz.log('Data from meteoBridge: ' ..
-- '\ntemperature: ' .. temperatureB ..
-- '\ntemperature: ' .. temperature ..
-- '\ndew: ' .. dewpoint ..
-- '\nrainTotal: ' .. rainTotal ..
-- '\nrainrate: ' .. rainRate ..
-- '\nrainrate: ' .. rainRate ..
-- '\nforecast: ' .. forecast
-- , dz.LOG_DEBUG)
-- update the weather sensors
dewpointSensor.updateTempHumBaro(dewpoint, humidity, humidityStatus, pressure, forecast)
pressureSensor.updatePressure(pressure)
humiditySensor.updateHumidity(humidity, humidityStatus)
rainSensor.updateRain(rainRate, rainTotal)
temperatureBSensor.updateTemperature(temperatureB)
temperatureSensor.updateTemperature(temperature)
windSensor.updateWind(windBearing, windDirection, windSpeed, windGust, temperature, windChill)
radiationSensor.updateRadiation(radiation)
SoilASensor.updateSoilMoisture(soilmoistureA)
SoilBSensor.updateSoilMoisture(soilmoistureB)
SoilATempSensor.updateTemperature(SoilATemp)
SoilBTempSensor.updateTemperature(SoilBTemp)
SoilCTempSensor.updateTemperature(SoilCTemp)
SoilDTempSensor.updateTemperature(SoilDTemp)
ETsensor.updateCustomSensor(Evap)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
return
end
dz.openURL(
{
url = url,
method = 'GET',
callback = scriptVar,
})
end
}
.
The data is "picked" from a file like this:
- Spoiler: show
- <logger>
<TH date="20200604094345" id="th0" temp="15.3" hum="83" dew="12.4"/>
<THB date="20200604094345" id="thb0" temp="25.5" hum="45" dew="[thbdew-act]" press="996.0"/>
<SOILA date="20200604094345" id="th10" temp="17.8" hum="69" lowbat="0"/>
<SOILB date="20200604094345" id="th11" temp="17.8" hum="69" lowbat="0"/>
<SOILC date="20200604094345" id="th12" temp="17.8" hum="255" lowbat="0"/>
<SOILD date="20200604094345" id="th13" temp="15.0" hum="255" lowbat="0"/>
<SOL date="20200604094345" id="sol0" rad="109.0" evo="0.1"/>
<WIND date="20200604094345" id="wind0" dir="317.0" gust="2.2" wind="0" chill="115.3"/>
<RAIN date="20200604094345" id="rain0" " daytotal="0.0" rate="0.0" total="204.2"/>
</logger>
The values for soil moisture A and B are uploaded, but it seems that I made a typo mistake, because the error log is filled with this error message.
Version:
Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 13:47:55
dzVents Version: 3.0.2
Python Version: 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 11:39
by waaren
Doornenburgweer wrote: ↑Thursday 04 June 2020 9:56
Since a couple of days I receive a error message in the error log:
Error: dzVents: Error: (3.0.2) ...moticz/scripts/dzVents/generated_scripts/Meteobridge.lua:114: attempt to index a nil value (field 'SOILA')
Can you add
as line 113 ? It will not solve the issue but will show what values are in the response.
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 15:38
by Doornenburgweer
Hi Waaren, see here the log
- Spoiler: show
- 2020-06-04 15:35:01.653 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-04 15:35:01.658 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-04 15:35:01.660 Status: dzVents: Info: Handling httpResponse-events for: "get_meteoBridge"
2020-06-04 15:35:01.660 Status: dzVents: Info: ------ Start internal script: Meteobridge: HTTPResponse: "get_meteoBridge"
2020-06-04 15:35:01.664 Status: dzVents: > SOL:
2020-06-04 15:35:01.664 Status: dzVents: > _attr:
2020-06-04 15:35:01.664 Status: dzVents: > date: 20200604153016
2020-06-04 15:35:01.664 Status: dzVents: > evo: 1.3
2020-06-04 15:35:01.664 Status: dzVents: > rad: 216.0
2020-06-04 15:35:01.664 Status: dzVents: > id: sol0
2020-06-04 15:35:01.665 Status: dzVents: > THB:
2020-06-04 15:35:01.665 Status: dzVents: > _attr:
2020-06-04 15:35:01.665 Status: dzVents: > dew: --
2020-06-04 15:35:01.665 Status: dzVents: > date: 20200604153016
2020-06-04 15:35:01.665 Status: dzVents: > press: 1001.7
2020-06-04 15:35:01.665 Status: dzVents: > hum: 56
2020-06-04 15:35:01.665 Status: dzVents: > id: thb0
2020-06-04 15:35:01.665 Status: dzVents: > temp: 11.2
2020-06-04 15:35:01.665 Status: dzVents: > RAIN:
2020-06-04 15:35:01.665 Status: dzVents: > _attr:
2020-06-04 15:35:01.665 Status: dzVents: > total: 170.0
2020-06-04 15:35:01.665 Status: dzVents: > date: 20200604153016
2020-06-04 15:35:01.665 Status: dzVents: > id: rain0
2020-06-04 15:35:01.665 Status: dzVents: > rate: 0.0
2020-06-04 15:35:01.665 Status: dzVents: > daytotal: 0.4
2020-06-04 15:35:01.665 Status: dzVents: > WIND:
2020-06-04 15:35:01.665 Status: dzVents: > _attr:
2020-06-04 15:35:01.665 Status: dzVents: > gust: 5.4
2020-06-04 15:35:01.665 Status: dzVents: > wind: 1
2020-06-04 15:35:01.665 Status: dzVents: > date: 20200604153016
2020-06-04 15:35:01.665 Status: dzVents: > chill: 13.9
2020-06-04 15:35:01.665 Status: dzVents: > dir: 142.0
2020-06-04 15:35:01.665 Status: dzVents: > id: wind0
2020-06-04 15:35:01.665 Status: dzVents: > TH:
2020-06-04 15:35:01.665 Status: dzVents: > _attr:
2020-06-04 15:35:01.665 Status: dzVents: > dew: 10.7
2020-06-04 15:35:01.665 Status: dzVents: > date: 20200604153016
2020-06-04 15:35:01.665 Status: dzVents: > hum: 81
2020-06-04 15:35:01.665 Status: dzVents: > id: th0
2020-06-04 15:35:01.665 Status: dzVents: > temp: 13.9
2020-06-04 15:35:01.666 Status: dzVents: Info: ------ Finished Meteobridge
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 15:44
by waaren
So the requested data is not in rt.logger. Maybe in another subtable of rt ?
can you change
to
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 17:11
by Doornenburgweer
I did ( in line 113) see here the result
- Spoiler: show
- 2020-06-04 17:05:11.204 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-04 17:05:11.209 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-04 17:05:11.210 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-06-04 17:05:11.957 Status: dzVents: Info: Handling httpResponse-events for: "get_meteoBridge"
2020-06-04 17:05:11.957 Status: dzVents: Info: ------ Start internal script: Meteobridge: HTTPResponse: "get_meteoBridge"
2020-06-04 17:05:12.007 Status: dzVents: > SOL:
2020-06-04 17:05:12.007 Status: dzVents: > _attr:
2020-06-04 17:05:12.008 Status: dzVents: > date: 20200604170051
2020-06-04 17:05:12.008 Status: dzVents: > id: sol0
2020-06-04 17:05:12.008 Status: dzVents: > evo: 1.5
2020-06-04 17:05:12.008 Status: dzVents: > rad: 165.0
2020-06-04 17:05:12.008 Status: dzVents: > WIND:
2020-06-04 17:05:12.008 Status: dzVents: > _attr:
2020-06-04 17:05:12.008 Status: dzVents: > gust: 4.0
2020-06-04 17:05:12.008 Status: dzVents: > chill: 13.7
2020-06-04 17:05:12.008 Status: dzVents: > dir: 5.0
2020-06-04 17:05:12.008 Status: dzVents: > id: wind0
2020-06-04 17:05:12.008 Status: dzVents: > wind: 2
2020-06-04 17:05:12.008 Status: dzVents: > date: 20200604170051
2020-06-04 17:05:12.008 Status: dzVents: > RAIN:
2020-06-04 17:05:12.008 Status: dzVents: > _attr:
2020-06-04 17:05:12.008 Status: dzVents: > daytotal: 0.4
2020-06-04 17:05:12.008 Status: dzVents: > total: 170.0
2020-06-04 17:05:12.008 Status: dzVents: > id: rain0
2020-06-04 17:05:12.008 Status: dzVents: > rate: 0.0
2020-06-04 17:05:12.008 Status: dzVents: > date: 20200604170051
2020-06-04 17:05:12.008 Status: dzVents: > TH:
2020-06-04 17:05:12.008 Status: dzVents: > _attr:
2020-06-04 17:05:12.008 Status: dzVents: > hum: 80
2020-06-04 17:05:12.008 Status: dzVents: > id: th0
2020-06-04 17:05:12.008 Status: dzVents: > temp: 14.0
2020-06-04 17:05:12.008 Status: dzVents: > date: 20200604170051
2020-06-04 17:05:12.008 Status: dzVents: > dew: 10.6
2020-06-04 17:05:12.008 Status: dzVents: > THB:
2020-06-04 17:05:12.008 Status: dzVents: > _attr:
2020-06-04 17:05:12.008 Status: dzVents: > press: 1001.5
2020-06-04 17:05:12.008 Status: dzVents: > hum: 55
2020-06-04 17:05:12.008 Status: dzVents: > id: thb0
2020-06-04 17:05:12.008 Status: dzVents: > temp: 11.0
2020-06-04 17:05:12.008 Status: dzVents: > date: 20200604170051
2020-06-04 17:05:12.008 Status: dzVents: > dew: --
2020-06-04 17:05:12.009 Status: dzVents: Info: ------ Finished Meteobridge
2020-06-04 17:05:12.009 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-04 17:05:12.015 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-04 17:05:12.015 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-06-04 17:07:39.632 Status: EventSystem: reset all events...
2020-06-04 17:07:39.633 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Stroomkosten.lua
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 17:20
by waaren
Doornenburgweer wrote: ↑Thursday 04 June 2020 17:11
I did ( in line 113) see here the result
Are you sure this is the result of dz.utils.dumpTable(rt) ?
I miss at least the subTable logger so I assume this is the result from the script as it was before your latest change.
Can you please doublecheck?
To prevent going back and forth also share the result of the log when you insert just before this dumpTable statement the line with
Code: Select all
dz.log(item,dz.LOG_FORCE) -- this will show the complete content of the HTTPResponse
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 19:51
by Doornenburgweer
I hope I understand you good
- Spoiler: show
- local url = 'http://www.website.com/domoticz.txt'
--local url = 'http://meteobridge:[email protected]. ... ataxml.cgi'
local scriptVar = 'get_meteoBridge'
return
{
on =
{
timer =
{
'every 5 minutes', -- change this to 5 minute after testing
},
devices =
{
'triggerhulp',
},
httpResponses =
{
scriptVar,
},
},
--logging =
--{
-- level = domoticz.LOG_DEBUG,
-- marker = scriptVar,
--},
execute = function(dz, item)
local temperatureBSensor = dz.devices(97) --indoor temperatuur
local temperatureSensor = dz.devices(82) --outside temperature
local rainSensor = dz.devices(83) -- rain
local windSensor = dz.devices(84) -- wind
local dewpointSensor = dz.devices(95) -- define as a combined Temperature, Humidity, Barometer sensor
local humiditySensor = dz.devices(96) -- Humidity sensor
local pressureSensor = dz.devices(86) -- barometer
local radiationSensor = dz.devices(89) -- radiation
local SoilATempSensor = dz.devices(90) -- soil temperature -5 cm
local SoilBTempSensor = dz.devices(91) -- soil temperature -10 cm
local SoilCTempSensor = dz.devices(92) -- soil temperature -15 cm
local SoilDTempSensor = dz.devices(93) -- grass temperature +10 cm
local SoilASensor = dz.devices(99) -- soil moisture -20 cm
local SoilBSensor = dz.devices(101) -- soil moisture -40 cm
local ETsensor = dz.devices(120) -- Evapotranspiration
local function windBearing2Direction(degrees)
local function between(value, center, variance)
variance = variance or 22.5
local value = tonumber(value)
return ( value >= (center - variance) or value <= (center + variance) )
end
if between(degrees, 45) then return 'NW'
elseif between(degrees, 90) then return 'W'
elseif between(degrees, 135) then return 'Sw'
elseif between(degrees, 180) then return 'S'
elseif between(degrees, 225) then return 'SE'
elseif between(degrees, 270) then return 'E'
elseif between(degrees, 315) then return 'NE'
end
return 'N'
end
local function humStatus(temperature, humidity)
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
else return dz.HUM_NORMAL end
end
function baroForecast(pressure)
if pressure == nil then return dz.BARO_NOINFO
elseif pressure < 1003 then return dz.BARO_RAIN
elseif pressure < 1013 then return dz.BARO_CLOUDY
elseif pressure < 1033 then return dz.BARO_PARTLYCLOUDY
end
return dz.BARO_SUNNY
end
if item.isHTTPResponse then
if item.ok then
rt = dz.utils.fromXML(item.data)
-- dz.log(item,dz.LOG_DEBUG)
dz.utils.dumpTable(rt)
-- get the values from the table and add missing values via weather functions
local temperatureB = tonumber(rt.logger.THB._attr.temp)
local temperature = tonumber(rt.logger.TH._attr.temp)
local dewpoint = rt.logger.TH._attr.dew
local rainTotal = rt.logger.RAIN._attr.total
local rainRate = rt.logger.RAIN._attr.rate
local windSpeed = rt.logger.WIND._attr.wind
local windBearing = rt.logger.WIND._attr.dir
local windChill = rt.logger.WIND._attr.chill
local windGust = rt.logger.WIND._attr.gust
local windDirection = windBearing2Direction(windBearing)
local humidity = tonumber(rt.logger.THB._attr.hum)
local humidityStatus = humStatus(temperature, humidity)
local pressure = tonumber(rt.logger.THB._attr.press)
local forecast = baroForecast(pressure)
local radiation = rt.logger.SOL._attr.rad
local soilmoistureA = tonumber(rt.logger.SOILA._attr.hum)
local soilmoistureB = tonumber(rt.logger.SOILB._attr.hum)
local SoilATemp = tonumber(rt.logger.SOILA._attr.temp)
local SoilBTemp = tonumber(rt.logger.SOILB._attr.temp)
local SoilCTemp = tonumber(rt.logger.SOILC._attr.temp)
local SoilDTemp = tonumber(rt.logger.SOILD._attr.temp)
local Evap = rt.logger.SOL._attr.evo
-- dz.log('Data from meteoBridge: ' ..
-- '\ntemperature: ' .. temperatureB ..
-- '\ntemperature: ' .. temperature ..
-- '\ndew: ' .. dewpoint ..
-- '\nrainTotal: ' .. rainTotal ..
-- '\nrainrate: ' .. rainRate ..
-- '\nrainrate: ' .. rainRate ..
-- '\nforecast: ' .. forecast
-- , dz.LOG_DEBUG)
-- update the weather sensors
dewpointSensor.updateTempHumBaro(dewpoint, humidity, humidityStatus, pressure, forecast)
pressureSensor.updatePressure(pressure)
humiditySensor.updateHumidity(humidity, humidityStatus)
rainSensor.updateRain(rainRate, rainTotal)
temperatureBSensor.updateTemperature(temperatureB)
temperatureSensor.updateTemperature(temperature)
windSensor.updateWind(windBearing, windDirection, windSpeed, windGust, temperature, windChill)
radiationSensor.updateRadiation(radiation)
SoilASensor.updateSoilMoisture(soilmoistureA)
SoilBSensor.updateSoilMoisture(soilmoistureB)
SoilATempSensor.updateTemperature(SoilATemp)
SoilBTempSensor.updateTemperature(SoilBTemp)
SoilCTempSensor.updateTemperature(SoilCTemp)
SoilDTempSensor.updateTemperature(SoilDTemp)
ETsensor.updateCustomSensor(Evap)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
return
end
dz.openURL(
{
url = url,
method = 'GET',
callback = scriptVar,
})
end
}
this the response what I see in the log
- Spoiler: show
- 2020-06-04 19:45:03.443 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-04 19:45:03.447 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-04 19:45:03.449 Status: dzVents: Info: Handling httpResponse-events for: "get_meteoBridge"
2020-06-04 19:45:03.449 Status: dzVents: Info: ------ Start internal script: Meteobridge: HTTPResponse: "get_meteoBridge"
2020-06-04 19:45:03.453 Status: dzVents: > logger:
2020-06-04 19:45:03.453 Status: dzVents: > THB:
2020-06-04 19:45:03.453 Status: dzVents: > _attr:
2020-06-04 19:45:03.453 Status: dzVents: > dew: --
2020-06-04 19:45:03.453 Status: dzVents: > temp: 10.5
2020-06-04 19:45:03.453 Status: dzVents: > press: 1002.0
2020-06-04 19:45:03.453 Status: dzVents: > hum: 54
2020-06-04 19:45:03.453 Status: dzVents: > date: 20200604194151
2020-06-04 19:45:03.453 Status: dzVents: > id: thb0
2020-06-04 19:45:03.453 Status: dzVents: > SOL:
2020-06-04 19:45:03.453 Status: dzVents: > _attr:
2020-06-04 19:45:03.453 Status: dzVents: > date: 20200604194151
2020-06-04 19:45:03.453 Status: dzVents: > evo: 1.9
2020-06-04 19:45:03.453 Status: dzVents: > rad: 232.0
2020-06-04 19:45:03.453 Status: dzVents: > id: sol0
2020-06-04 19:45:03.453 Status: dzVents: > RAIN:
2020-06-04 19:45:03.453 Status: dzVents: > _attr:
2020-06-04 19:45:03.453 Status: dzVents: > date: 20200604194151
2020-06-04 19:45:03.453 Status: dzVents: > total: 170.0
2020-06-04 19:45:03.453 Status: dzVents: > daytotal: 0.4
2020-06-04 19:45:03.453 Status: dzVents: > rate: 0.0
2020-06-04 19:45:03.453 Status: dzVents: > id: rain0
2020-06-04 19:45:03.453 Status: dzVents: > WIND:
2020-06-04 19:45:03.453 Status: dzVents: > _attr:
2020-06-04 19:45:03.453 Status: dzVents: > gust: 4.0
2020-06-04 19:45:03.453 Status: dzVents: > date: 20200604194151
2020-06-04 19:45:03.453 Status: dzVents: > wind: 2
2020-06-04 19:45:03.453 Status: dzVents: > chill: 11.5
2020-06-04 19:45:03.453 Status: dzVents: > dir: 346.0
2020-06-04 19:45:03.453 Status: dzVents: > id: wind0
2020-06-04 19:45:03.453 Status: dzVents: > TH:
2020-06-04 19:45:03.453 Status: dzVents: > _attr:
2020-06-04 19:45:03.453 Status: dzVents: > temp: 11.6
2020-06-04 19:45:03.454 Status: dzVents: > dew: 9.2
2020-06-04 19:45:03.454 Status: dzVents: > hum: 85
2020-06-04 19:45:03.454 Status: dzVents: > date: 20200604194151
2020-06-04 19:45:03.454 Status: dzVents: > id: th0
2020-06-04 19:45:03.454 Status: dzVents: Info: ------ Finished Meteobridge
Sorry, I hope I did it rigth.
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 20:18
by waaren
Almost
Please add this line as line 113
dz.log(item,dz.LOG_FORCE)
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 21:01
by Doornenburgweer
thanks I did this
- Spoiler: show
- 2020-06-04 20:45:01.547 Status: dzVents: Info: ------ Finished Meteobridge
2020-06-04 20:45:01.547 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-04 20:45:01.552 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-04 20:45:01.553 Status: dzVents: Info: Handling httpResponse-events for: "get_meteoBridge"
2020-06-04 20:45:01.553 Status: dzVents: Info: ------ Start internal script: Meteobridge: HTTPResponse: "get_meteoBridge"
2020-06-04 20:45:01.557 Status: dzVents: > logger:
2020-06-04 20:45:01.557 Status: dzVents: > SOL:
2020-06-04 20:45:01.557 Status: dzVents: > _attr:
2020-06-04 20:45:01.557 Status: dzVents: > date: 20200604204211
2020-06-04 20:45:01.557 Status: dzVents: > id: sol0
2020-06-04 20:45:01.557 Status: dzVents: > evo: 2.0
2020-06-04 20:45:01.557 Status: dzVents: > rad: 46.0
2020-06-04 20:45:01.557 Status: dzVents: > RAIN:
2020-06-04 20:45:01.557 Status: dzVents: > _attr:
2020-06-04 20:45:01.557 Status: dzVents: > date: 20200604204211
2020-06-04 20:45:01.558 Status: dzVents: > daytotal: 0.4
2020-06-04 20:45:01.558 Status: dzVents: > total: 170.0
2020-06-04 20:45:01.558 Status: dzVents: > id: rain0
2020-06-04 20:45:01.558 Status: dzVents: > rate: 0.0
2020-06-04 20:45:01.558 Status: dzVents: > THB:
2020-06-04 20:45:01.558 Status: dzVents: > _attr:
2020-06-04 20:45:01.558 Status: dzVents: > date: 20200604204211
2020-06-04 20:45:01.558 Status: dzVents: > hum: 54
2020-06-04 20:45:01.558 Status: dzVents: > press: 1002.1
2020-06-04 20:45:01.558 Status: dzVents: > dew: --
2020-06-04 20:45:01.558 Status: dzVents: > id: thb0
2020-06-04 20:45:01.558 Status: dzVents: > temp: 10.2
2020-06-04 20:45:01.558 Status: dzVents: > WIND:
2020-06-04 20:45:01.558 Status: dzVents: > _attr:
2020-06-04 20:45:01.558 Status: dzVents: > date: 20200604204211
2020-06-04 20:45:01.558 Status: dzVents: > wind: 1
2020-06-04 20:45:01.558 Status: dzVents: > dir: 5.0
2020-06-04 20:45:01.558 Status: dzVents: > id: wind0
2020-06-04 20:45:01.558 Status: dzVents: > gust: 2.7
2020-06-04 20:45:01.558 Status: dzVents: > chill: 11.5
2020-06-04 20:45:01.558 Status: dzVents: > TH:
2020-06-04 20:45:01.558 Status: dzVents: > _attr:
2020-06-04 20:45:01.558 Status: dzVents: > date: 20200604204211
2020-06-04 20:45:01.558 Status: dzVents: > hum: 85
2020-06-04 20:45:01.558 Status: dzVents: > dew: 9.1
2020-06-04 20:45:01.558 Status: dzVents: > id: th0
2020-06-04 20:45:01.558 Status: dzVents: > temp: 11.5
2020-06-04 20:45:01.559 Status: dzVents: !Info: {["trigger"]="get_meteoBridge", ["isGroup"]=false, ["_contentType"]="text/xml", ["headers"]={["Date"]="Thu, 04 Jun 2020 18:45:00 GMT", ["ETag"]=""192-5a74680be8f03"", ["Accept-Ranges"]="bytes", ["Content-Type"]="text/xml", ["Last-Modified"]="Thu, 04 Jun 2020 18:42:13 GMT", ["Content-Length"]="402", ["Server"]="Apache/2.4.43 (Unix)"}, ["data"]="<logger>
2020-06-04 20:45:01.559 <TH date="20200604204211" id="th0" temp="11.5" hum="85" dew="9.1"/>
2020-06-04 20:45:01.559 <THB date="20200604204211" id="thb0" temp="10.2" hum="54" dew="--" press="1002.1"/>
2020-06-04 20:45:01.559 <SOL date="20200604204211" id="sol0" rad="46.0" evo="2.0"/>
2020-06-04 20:45:01.559 <WIND date="20200604204211" id="wind0" dir="5.0" gust="2.7" wind="1" chill="11.5"/>
2020-06-04 20:45:01.559 <RAIN date="20200604204211" id="rain0" daytotal="0.4" rate="0.0" total="170.0"/>
2020-06-04 20:45:01.559 </logger>
2020-06-04 20:45:01.559
this is the script
Code: Select all
bla[bla file from internet website
local scriptVar = 'get_meteoBridge'
return
{
on =
{
timer =
{
'every 5 minutes', -- change this to 5 minute after testing
},
devices =
{
'triggerhulp',
},
httpResponses =
{
scriptVar,
},
},
--logging =
--{
-- level = domoticz.LOG_DEBUG,
-- marker = scriptVar,
--},
execute = function(dz, item)
local temperatureBSensor = dz.devices(97) --indoor temperatuur
local temperatureSensor = dz.devices(82) --outside temperature
local rainSensor = dz.devices(83) -- rain
local windSensor = dz.devices(84) -- wind
local dewpointSensor = dz.devices(95) -- define as a combined Temperature, Humidity, Barometer sensor
local humiditySensor = dz.devices(96) -- Humidity sensor
local pressureSensor = dz.devices(86) -- barometer
local radiationSensor = dz.devices(89) -- radiation
local SoilATempSensor = dz.devices(90) -- soil temperature -5 cm
local SoilBTempSensor = dz.devices(91) -- soil temperature -10 cm
local SoilCTempSensor = dz.devices(92) -- soil temperature -15 cm
local SoilDTempSensor = dz.devices(93) -- grass temperature +10 cm
local SoilASensor = dz.devices(99) -- soil moisture -20 cm
local SoilBSensor = dz.devices(101) -- soil moisture -40 cm
local ETsensor = dz.devices(120) -- Evapotranspiration
local function windBearing2Direction(degrees)
local function between(value, center, variance)
variance = variance or 22.5
local value = tonumber(value)
return ( value >= (center - variance) or value <= (center + variance) )
end
if between(degrees, 45) then return 'NW'
elseif between(degrees, 90) then return 'W'
elseif between(degrees, 135) then return 'Sw'
elseif between(degrees, 180) then return 'S'
elseif between(degrees, 225) then return 'SE'
elseif between(degrees, 270) then return 'E'
elseif between(degrees, 315) then return 'NE'
end
return 'N'
end
local function humStatus(temperature, humidity)
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
else return dz.HUM_NORMAL end
end
function baroForecast(pressure)
if pressure == nil then return dz.BARO_NOINFO
elseif pressure < 1003 then return dz.BARO_RAIN
elseif pressure < 1013 then return dz.BARO_CLOUDY
elseif pressure < 1033 then return dz.BARO_PARTLYCLOUDY
end
return dz.BARO_SUNNY
end
if item.isHTTPResponse then
if item.ok then
rt = dz.utils.fromXML(item.data)
-- dz.log(item,dz.LOG_DEBUG)
dz.utils.dumpTable(rt)
-- get the values from the table and add missing values via weather functions
local temperatureB = tonumber(rt.logger.THB._attr.temp)
local temperature = tonumber(rt.logger.TH._attr.temp)
local dewpoint = rt.logger.TH._attr.dew
local rainTotal = rt.logger.RAIN._attr.total
local rainRate = rt.logger.RAIN._attr.rate
local windSpeed = rt.logger.WIND._attr.wind
local windBearing = rt.logger.WIND._attr.dir
local windChill = rt.logger.WIND._attr.chill
local windGust = rt.logger.WIND._attr.gust
local windDirection = windBearing2Direction(windBearing)
local humidity = tonumber(rt.logger.THB._attr.hum)
local humidityStatus = humStatus(temperature, humidity)
local pressure = tonumber(rt.logger.THB._attr.press)
local forecast = baroForecast(pressure)
dz.log(item,dz.LOG_FORCE)
local radiation = rt.logger.SOL._attr.rad
local soilmoistureA = tonumber(rt.logger.SOILA._attr.hum)
local soilmoistureB = tonumber(rt.logger.SOILB._attr.hum)
local SoilATemp = tonumber(rt.logger.SOILA._attr.temp)
local SoilBTemp = tonumber(rt.logger.SOILB._attr.temp)
local SoilCTemp = tonumber(rt.logger.SOILC._attr.temp)
local SoilDTemp = tonumber(rt.logger.SOILD._attr.temp)
local Evap = rt.logger.SOL._attr.evo
-- dz.log('Data from meteoBridge: ' ..
-- '\ntemperature: ' .. temperatureB ..
-- '\ntemperature: ' .. temperature ..
-- '\ndew: ' .. dewpoint ..
-- '\nrainTotal: ' .. rainTotal ..
-- '\nrainrate: ' .. rainRate ..
-- '\nrainrate: ' .. rainRate ..
-- '\nforecast: ' .. forecast
-- , dz.LOG_DEBUG)
-- update the weather sensors
dewpointSensor.updateTempHumBaro(dewpoint, humidity, humidityStatus, pressure, forecast)
pressureSensor.updatePressure(pressure)
humiditySensor.updateHumidity(humidity, humidityStatus)
rainSensor.updateRain(rainRate, rainTotal)
temperatureBSensor.updateTemperature(temperatureB)
temperatureSensor.updateTemperature(temperature)
windSensor.updateWind(windBearing, windDirection, windSpeed, windGust, temperature, windChill)
radiationSensor.updateRadiation(radiation)
SoilASensor.updateSoilMoisture(soilmoistureA)
SoilBSensor.updateSoilMoisture(soilmoistureB)
SoilATempSensor.updateTemperature(SoilATemp)
SoilBTempSensor.updateTemperature(SoilBTemp)
SoilCTempSensor.updateTemperature(SoilCTemp)
SoilDTempSensor.updateTemperature(SoilDTemp)
ETsensor.updateCustomSensor(Evap)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
return
end
dz.openURL(
{
url = url,
method = 'GET',
callback = scriptVar,
})
end
}
Re: attempt to index a nil value
Posted: Thursday 04 June 2020 21:17
by waaren
OK. The values that you need to update these variables
Code: Select all
the local soilmoistureA = tonumber(rt.logger.SOILA._attr.hum)
local soilmoistureB = tonumber(rt.logger.SOILB._attr.hum)
local SoilATemp = tonumber(rt.logger.SOILA._attr.temp)
local SoilBTemp = tonumber(rt.logger.SOILB._attr.temp)
local SoilCTemp = tonumber(rt.logger.SOILC._attr.temp)
local SoilDTemp = tonumber(rt.logger.SOILD._attr.temp)
and with these variables these sensors.
Code: Select all
SoilASensor.updateSoilMoisture(soilmoistureA)
SoilBSensor.updateSoilMoisture(soilmoistureB)
SoilATempSensor.updateTemperature(SoilATemp)
SoilBTempSensor.updateTemperature(SoilBTemp)
SoilCTempSensor.updateTemperature(SoilCTemp)
SoilDTempSensor.updateTemperature(SoilDTemp)
Are not in the response from your weatherstation and can therefore not be used by dzVents. Do you have reason to believe they should be available in your weatherstation?
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 8:30
by Doornenburgweer
Sorry, I had the idea I sent you a response, but I guess I made a mistake. But your last reply is too difficult for me to understand. I am sure I did something wrong, but what and when I started with this script I had no error in the error log.
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 8:50
by waaren
Doornenburgweer wrote: ↑Saturday 06 June 2020 8:30
Sorry, I had the idea I sent you a response, but I guess I made a mistake. But your last reply is too difficult for me to understand. I am sure I did something wrong, but what and when I started with this script I had no error in the error log.
OK. Using a different approach then...
What do you see when you use
http://meteobridge:[email protected]. ... ataxml.cgi in your browser?
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 9:12
by Doornenburgweer
Thanks, I changed this upload file to
- Spoiler: show
- <logger>
<TH date="20200606090650" id="th0" temp="10.8" hum="86" dew="8.6"/>
<THB date="20200606090650" id="thb0" temp="21.6" hum="46" dew="[thbdew-act]" press="997.4"/>
<SOILA date="20200606090650" id="th10" temp="14.4" hum="64" lowbat="0"/>
<SOILB date="20200606090650" id="th11" temp="15.0" hum="37" lowbat="0"/>
<SOILC date="20200606090650" id="th12" temp="15.0" hum="255" lowbat="0"/>
<SOILD date="20200606090650" id="th13" temp="9.4" hum="255" lowbat="0"/>
<SOL date="20200606090650" id="sol0" rad="54.0" evo="0.1"/>
<WIND date="20200606090650" id="wind0" dir="213.0" gust="4.0" wind="0" chill="110.8"/>
<RAIN date="20200606090650" id="rain0" " daytotal="0.8" rate="0.0" total="222.8"/>
</logger>
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 9:37
by waaren
Doornenburgweer wrote: ↑Saturday 06 June 2020 9:12
Thanks, I changed this upload file to
- Spoiler: show
- <logger>
<TH date="20200606090650" id="th0" temp="10.8" hum="86" dew="8.6"/>
<THB date="20200606090650" id="thb0" temp="21.6" hum="46" dew="[thbdew-act]" press="997.4"/>
<SOILA date="20200606090650" id="th10" temp="14.4" hum="64" lowbat="0"/>
<SOILB date="20200606090650" id="th11" temp="15.0" hum="37" lowbat="0"/>
<SOILC date="20200606090650" id="th12" temp="15.0" hum="255" lowbat="0"/>
<SOILD date="20200606090650" id="th13" temp="9.4" hum="255" lowbat="0"/>
<SOL date="20200606090650" id="sol0" rad="54.0" evo="0.1"/>
<WIND date="20200606090650" id="wind0" dir="213.0" gust="4.0" wind="0" chill="110.8"/>
<RAIN date="20200606090650" id="rain0" " daytotal="0.8" rate="0.0" total="222.8"/>
</logger>
Does this reply means your script is now working again?
If not then please let the below script execute at least once and send the complete log of this run.
Code: Select all
local url = 'http://meteobridge:[email protected]/cgi-bin/livedataxml.cgi'
local scriptVar = 'get_meteoBridge'
return
{
on =
{
timer =
{
'every 5 minutes', -- change this to 5 minute after testing
},
devices =
{
'triggerhulp',
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local temperatureBSensor = dz.devices(97) --indoor temperatuur
local temperatureSensor = dz.devices(82) --outside temperature
local rainSensor = dz.devices(83) -- rain
local windSensor = dz.devices(84) -- wind
local dewpointSensor = dz.devices(95) -- define as a combined Temperature, Humidity, Barometer sensor
local humiditySensor = dz.devices(96) -- Humidity sensor
local pressureSensor = dz.devices(86) -- barometer
local radiationSensor = dz.devices(89) -- radiation
local SoilATempSensor = dz.devices(90) -- soil temperature -5 cm
local SoilBTempSensor = dz.devices(91) -- soil temperature -10 cm
local SoilCTempSensor = dz.devices(92) -- soil temperature -15 cm
local SoilDTempSensor = dz.devices(93) -- grass temperature +10 cm
local SoilASensor = dz.devices(99) -- soil moisture -20 cm
local SoilBSensor = dz.devices(101) -- soil moisture -40 cm
local ETsensor = dz.devices(120) -- Evapotranspiration
local function windBearing2Direction(degrees)
local function between(value, center, variance)
variance = variance or 22.5
local value = tonumber(value)
return ( value >= (center - variance) or value <= (center + variance) )
end
if between(degrees, 45) then return 'NW'
elseif between(degrees, 90) then return 'W'
elseif between(degrees, 135) then return 'Sw'
elseif between(degrees, 180) then return 'S'
elseif between(degrees, 225) then return 'SE'
elseif between(degrees, 270) then return 'E'
elseif between(degrees, 315) then return 'NE'
end
return 'N'
end
local function humStatus(temperature, humidity)
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
else return dz.HUM_NORMAL end
end
function baroForecast(pressure)
if pressure == nil then return dz.BARO_NOINFO
elseif pressure < 1003 then return dz.BARO_RAIN
elseif pressure < 1013 then return dz.BARO_CLOUDY
elseif pressure < 1033 then return dz.BARO_PARTLYCLOUDY
end
return dz.BARO_SUNNY
end
if item.isHTTPResponse then
if item.ok then
rt = dz.utils.fromXML(item.data)
dz.log(item,dz.LOG_DEBUG)
-- get the values from the table and add missing values via weather functions
local temperatureB = tonumber(rt.logger.THB._attr.temp)
local temperature = tonumber(rt.logger.TH._attr.temp)
local dewpoint = rt.logger.TH._attr.dew
local rainTotal = rt.logger.RAIN._attr.total
local rainRate = rt.logger.RAIN._attr.rate
local windSpeed = rt.logger.WIND._attr.wind
local windBearing = rt.logger.WIND._attr.dir
local windChill = rt.logger.WIND._attr.chill
local windGust = rt.logger.WIND._attr.gust
local windDirection = windBearing2Direction(windBearing)
local humidity = tonumber(rt.logger.THB._attr.hum)
local humidityStatus = humStatus(temperature, humidity)
local pressure = tonumber(rt.logger.THB._attr.press)
local forecast = baroForecast(pressure)
local radiation = rt.logger.SOL._attr.rad
local soilmoistureA = tonumber(rt.logger.SOILA._attr.hum)
local soilmoistureB = tonumber(rt.logger.SOILB._attr.hum)
local SoilATemp = tonumber(rt.logger.SOILA._attr.temp)
local SoilBTemp = tonumber(rt.logger.SOILB._attr.temp)
local SoilCTemp = tonumber(rt.logger.SOILC._attr.temp)
local SoilDTemp = tonumber(rt.logger.SOILD._attr.temp)
local Evap = rt.logger.SOL._attr.evo
dz.log('Data from meteoBridge: ' ..
'\ntemperature: ' .. temperatureB ..
'\ntemperature: ' .. temperature ..
'\ndew: ' .. dewpoint ..
'\nrainTotal: ' .. rainTotal ..
'\nrainrate: ' .. rainRate ..
'\nrainrate: ' .. rainRate ..
'\nforecast: ' .. forecast
, dz.LOG_DEBUG)
-- update the weather sensors
dewpointSensor.updateTempHumBaro(dewpoint, humidity, humidityStatus, pressure, forecast)
pressureSensor.updatePressure(pressure)
humiditySensor.updateHumidity(humidity, humidityStatus)
rainSensor.updateRain(rainRate, rainTotal)
temperatureBSensor.updateTemperature(temperatureB)
temperatureSensor.updateTemperature(temperature)
windSensor.updateWind(windBearing, windDirection, windSpeed, windGust, temperature, windChill)
radiationSensor.updateRadiation(radiation)
SoilASensor.updateSoilMoisture(soilmoistureA)
SoilBSensor.updateSoilMoisture(soilmoistureB)
SoilATempSensor.updateTemperature(SoilATemp)
SoilBTempSensor.updateTemperature(SoilBTemp)
SoilCTempSensor.updateTemperature(SoilCTemp)
SoilDTempSensor.updateTemperature(SoilDTemp)
ETsensor.updateCustomSensor(Evap)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
return
end
dz.openURL(
{
url = url,
method = 'GET',
callback = scriptVar,
})
end
}
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 10:07
by Doornenburgweer
See here my log file
- Spoiler: show
- 2020-06-06 10:00:05.852 ", ["isTimer"]=false, ["statusText"]="OK", ["isJSON"]=false, ["protocol"]="HTTP/1.1", ["isVariable"]=false, ["isXML"]=false, ["isHTTPResponse"]=true, ["statusCode"]=200, ["_contentType"]="text/plain", ["isDevice"]=false, ["trigger"]="get_meteoBridge", ["ok"]=true, ["headers"]={["Content-Length"]="709", ["Last-Modified"]="Sat, 06 Jun 2020 07:57:11 GMT", ["Upgrade"]="h2,h2c", ["Connection"]="Upgrade", ["Date"]="Sat, 06 Jun 2020 08:00:00 GMT", ["Server"]="Apache", ["Accept-Ranges"]="bytes", ["Content-Type"]="text/plain"}, ["isCustomEvent"]=false, ["isHardware"]=false, ["isSecurity"]=false, ["isSystem"]=false, ["callback"]="get_meteoBridge", ["baseType"]="httpResponse", ["isGroup"]=false}
2020-06-06 10:00:05.852 Status: dzVents: Debug: get_meteoBridge: Data from meteoBridge:
2020-06-06 10:00:05.852 temperature: 21.6
2020-06-06 10:00:05.852 temperature: 10.4
2020-06-06 10:00:05.852 dew: 8.5
2020-06-06 10:00:05.852 rainTotal: 222.8
2020-06-06 10:00:05.852 rainrate: 0.0
2020-06-06 10:00:05.852 rainrate: 0.0
2020-06-06 10:00:05.852 forecast: rain
2020-06-06 10:00:05.853 Status: dzVents: Info: get_meteoBridge: ------ Finished Meteobridge
2020-06-06 10:00:05.853 Status: dzVents: Info: ------ Start internal script: SGL Davis weerstation: HTTPResponse: "get_meteoBridge"
2020-06-06 10:00:05.858 Status: dzVents: Info: ------ Finished SGL Davis weerstation
2020-06-06 10:00:05.860 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-06-06 10:00:18.852 Status: dzVents: Info: Handling httpResponse-events for: "openUV_Response"
2020-06-06 10:00:18.910 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-06-06 10:00:19.046 Status: dzVents: Info: Handling httpResponse-events for: "get_meteoBridge"
2020-06-06 10:00:19.046 Status: dzVents: Info: get_meteoBridge: ------ Start internal script: Meteobridge: HTTPResponse: "get_meteoBridge"
2020-06-06 10:00:19.054 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Binnentemperatuur kantoortje: Temperature device adapter
2020-06-06 10:00:19.055 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Temperatuur Davis: Temperature device adapter
2020-06-06 10:00:19.056 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Regen Davis: Rain device
2020-06-06 10:00:19.058 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Wind Davis: Wind device adapter
2020-06-06 10:00:19.059 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Barometer en dauwpunt: Temperature+humidity+barometer device adapter
2020-06-06 10:00:19.061 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Buiten RV: Humidty device adapter
2020-06-06 10:00:19.062 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Barometer: Pressure device adapter
2020-06-06 10:00:19.064 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Davis zonnestraling: Solar radiation device adapter
2020-06-06 10:00:19.065 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Bodem temp -20 cm: Temperature device adapter
2020-06-06 10:00:19.066 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Bodem temp -10 cm: Temperature device adapter
2020-06-06 10:00:19.068 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Bodem temp -11 cm: Temperature device adapter
2020-06-06 10:00:19.069 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Gras temperatuur: Temperature device adapter
2020-06-06 10:00:19.071 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Bodemvocht -40 cm: Soil Moisture device
2020-06-06 10:00:19.072 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for Bodemvocht -20 cm: Soil Moisture device
2020-06-06 10:00:19.074 Status: dzVents: Debug: get_meteoBridge: Processing device-adapter for ET Doornenburg: Custom sensor device adapter
2020-06-06 10:00:19.077 Status: dzVents: Debug: get_meteoBridge: {["ok"]=true, ["isScene"]=false, ["xml"]={["logger"]={["RAIN"]={["_attr"]={["id"]="rain0", ["total"]="182.2", ["rate"]="0.0", ["date"]="20200606095534", ["daytotal"]="0.0"}}, ["SOL"]={["_attr"]={["id"]="sol0", ["rad"]="770.0", ["date"]="20200606095534", ["evo"]="0.5"}}, ["THB"]={["_attr"]={["id"]="thb0", ["dew"]="--", ["press"]="1000.7", ["temp"]="8.8", ["date"]="20200606095534", ["hum"]="52"}}, ["WIND"]={["_attr"]={["id"]="wind0", ["wind"]="3", ["chill"]="11.2", ["dir"]="151.0", ["date"]="20200606095534", ["gust"]="8.0"}}, ["TH"]={["_attr"]={["id"]="th0", ["dew"]="7.7", ["temp"]="12.6", ["date"]="20200606095534", ["hum"]="72"}}}}, ["trigger"]="get_meteoBridge", ["isXML"]=true, ["isSystem"]=false, ["statusCode"]=200, ["isCustomEvent"]=false, ["isHTTPResponse"]=true, ["isVariable"]=false, ["isTimer"]=false, ["isJSON"]=false, ["baseType"]="httpResponse", ["isSecurity"]=false, ["isDevice"]=false, ["statusText"]="OK", ["_contentType"]="text/xml", ["callback"]="get_meteoBridge", ["isHardware"]=false, ["isGroup"]=false, ["data"]="<logger>
2020-06-06 10:00:19.077 <TH date="20200606095534" id="th0" temp="12.6" hum="72" dew="7.7"/>
2020-06-06 10:00:19.077 <THB date="20200606095534" id="thb0" temp="8.8" hum="52" dew="--" press="1000.7"/>
2020-06-06 10:00:19.077 <SOL date="20200606095534" id="sol0" rad="770.0" evo="0.5"/>
2020-06-06 10:00:19.077 <WIND date="20200606095534" id="wind0" dir="151.0" gust="8.0" wind="3" chill="11.2"/>
2020-06-06 10:00:19.077 <RAIN date="20200606095534" id="rain0" daytotal="0.0" rate="0.0" total="182.2"/>
2020-06-06 10:00:19.077 </logger>
2020-06-06 10:00:19.077
2020-06-06 10:00:19.077 ", ["protocol"]="HTTP/1.1", ["headers"]={["Server"]="Apache/2.4.43 (Unix)", ["Last-Modified"]="Sat, 06 Jun 2020 07:55:36 GMT", ["ETag"]=""194-5a765b3f7aa06"", ["Content-Length"]="404", ["Date"]="Sat, 06 Jun 2020 08:00:18 GMT", ["Content-Type"]="text/xml", ["Accept-Ranges"]="bytes"}}
2020-06-06 10:00:19.077 Status: dzVents: Info: get_meteoBridge: ------ Finished Meteobridge
. I hope I did this rigth.
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 11:19
by waaren
Doornenburgweer wrote: ↑Saturday 06 June 2020 10:07
See here my log file. I hope I did this rigth.
I still see that the httpResponse from the http call from the script is different then what you get when entering the same URL in your browser.
Can you set the log level of dzVents in
[settings][setup][other] to
- settings.png (6.59 KiB) Viewed 2346 times
And show the full log of both executions of the script?
(First run trigger by the timer is for sending the URL, second run triggered by the httpResponse is for interpreting the data)
Re: attempt to index a nil value
Posted: Saturday 06 June 2020 12:37
by Doornenburgweer
I change the timer to 1 minute, Could not find something to "second run triggered by the httpReponse". See here the error log:
- Spoiler: show
- 2020-06-06 12:25:01.982 Error: dzVents: Error: (3.0.2) get_meteoBridge: An error occurred when calling event handler Meteobridge
2020-06-06 12:25:01.982 Error: dzVents: Error: (3.0.2) get_meteoBridge: ...moticz/scripts/dzVents/generated_scripts/Meteobridge.lua:111: attempt to index a nil value (field 'SOILA')
2020-06-06 12:30:10.856 Error: dzVents: Error: (3.0.2) get_meteoBridge: An error occurred when calling event handler Meteobridge
2020-06-06 12:30:10.856 Error: dzVents: Error: (3.0.2) get_meteoBridge: ...moticz/scripts/dzVents/generated_scripts/Meteobridge.lua:111: attempt to index a nil value (field 'SOILA')
2020-06-06 12:35:01.625 Error: dzVents: Error: (3.0.2) get_meteoBridge: An error occurred when calling event handler Meteobridge
2020-06-06 12:35:01.625 Error: dzVents: Error: (3.0.2) get_meteoBridge: ...moticz/scripts/dzVents/generated_scripts/Meteobridge.lua:111: attempt to index a nil value (field 'SOILA')