I have had no issues with a script I wrote and now, all of a sudden, I get errors and I have no clue why, or how to solve it.
Enclosed are the log, the script and an overview of what the HTTPrequest retruns.
Is there anyone who can help me? It ran fine, until 1505 local time today and now it keeps giving this error.
All other scripts run fine...
Thanks for your help!
log:
Code: Select all
2020-05-25 16:10:03.902 Error: dzVents: Error: (3.0.7) here_wx_fc: An error occurred when calling event handler Wx - Here Wx fc
2020-05-25 16:10:03.902 Error: dzVents: Error: (3.0.7) here_wx_fc: /home/pi/domoticz/dzVents/runtime/Utils.lua:119: attempt to compare number with string
- Spoiler: show
Code: Select all
local response = 'here_wx_fc' local wind1 = 245 return { on = { devices = {}, timer = {'every 5 minutes'}, variables = {}, scenes = {}, groups = {}, security = {}, httpResponses = {response}, customEvents = {}, system = {}, }, data = {}, logging = { marker = response, level = domoticz.LOG_DEBUG }, execute = function(domoticz, triggeredItem) function Wind_Chill(T,V) value = (13.12 + (0.6215 * T) - (11.37 * (V^0.16)) + (0.3965 * T * (V^0.16))) return value end function cardinal_heading(degree) if degree < (0+(22.5/2)) or degree > (360-(22.5/2)) then value = 'N' elseif degree >= (0+(22.5/2)) and degree < ((1*22.5)+(22.5/2)) then value = 'NNE' elseif degree >= ((1*22.5)+(22.5/2)) and degree < ((2*22.5)+(22.5/2)) then value = 'NE' elseif degree >= ((2*22.5)+(22.5/2)) and degree < ((3*22.5)+(22.5/2)) then value = 'ENE' elseif degree >= ((3*22.5)+(22.5/2)) and degree < ((4*22.5)+(22.5/2)) then value = 'E' elseif degree >= ((4*22.5)+(22.5/2)) and degree < ((5*22.5)+(22.5/2)) then value = 'ESE' elseif degree >= ((5*22.5)+(22.5/2)) and degree < ((6*22.5)+(22.5/2)) then value = 'SE' elseif degree >= ((6*22.5)+(22.5/2)) and degree < ((7*22.5)+(22.5/2)) then value = 'SSE' elseif degree >= ((7*22.5)+(22.5/2)) and degree < ((8*22.5)+(22.5/2)) then value = 'S' elseif degree >= ((8*22.5)+(22.5/2)) and degree < ((9*22.5)+(22.5/2)) then value = 'SSW' elseif degree >= ((9*22.5)+(22.5/2)) and degree < ((10*22.5)+(22.5/2)) then value = 'SW' elseif degree >= ((10*22.5)+(22.5/2)) and degree < ((11*22.5)+(22.5/2)) then value = 'WSW' elseif degree >= ((11*22.5)+(22.5/2)) and degree < ((12*22.5)+(22.5/2)) then value = 'W' elseif degree >= ((12*22.5)+(22.5/2)) and degree < ((13*22.5)+(22.5/2)) then value = 'WNW' elseif degree >= ((13*22.5)+(22.5/2)) and degree < ((14*22.5)+(22.5/2)) then value = 'NW' elseif degree >= ((14*22.5)+(22.5/2)) and degree < ((15*22.5)+(22.5/2)) then value = 'NNW' end return value end function hour_correct(hour) if hour > 24 then value = hour-24 elseif hour <= 24 then value = hour end return value end function humidity_status(percentage) if percentage < 30 then value = domoticz.HUM_DRY elseif percentage >= 30 and percentage < 40 then value = domoticz.HUM_COMFORTABLE elseif percentage >= 40 and percentage < 70 then value = domoticz.HUM_NORMAL elseif percentage >= 70 then value = domoticz.HUM_WET end return value end local global = domoticz.helpers local api = domoticz.variables('Here_api').value local FC1_wind = domoticz.devices(245) local FC1_vis = domoticz.devices(248) local FC1_hum = domoticz.devices(250) local FC3_wind = domoticz.devices(246) local FC3_vis = domoticz.devices(249) local FC3_hum = domoticz.devices(251) if triggeredItem.isTimer then domoticz.openURL({ url = 'https://weather.ls.hereapi.com/weather/1.0/report.json?product=forecast_hourly&name=Amsterdamt&apiKey='.. api, method = 'GET', callback = response, }) elseif triggeredItem.isHTTPResponse and triggeredItem.ok and triggeredItem.isJSON then local FC = triggeredItem.json.hourlyForecasts.forecastLocation local hour = tonumber(domoticz.time.hour) local minutes = tonumber(domoticz.time.minutes) local initial = 1 local time_index_1 = FC.forecast[initial].localTime local uur = tonumber(string.sub(tostring(time_index_1), 1,2)) -- 20 local verschil = 1+hour-uur -- 1+00-20 =-19 if verschil < 0 then verschil = 1+24 -verschil end if minutes > 35 then verschil = verschil+1 end local FC_1 = initial+verschil local FC_3 = FC_1 + 2 local daylight1 = FC.forecast[FC_1].daylight local description1 = FC.forecast[FC_1].description local skyDescription1 = FC.forecast[FC_1].skyDescription local temperature1 = FC.forecast[FC_1].temperature local temperatureDesc1 = FC.forecast[FC_1].temperatureDesc local comfort1 = FC.forecast[FC_1].comfort local humidity1 = FC.forecast[FC_1].humidity local dewPoint1 = FC.forecast[FC_1].dewPoint local precipitationProbability1 = FC.forecast[FC_1].precipitationProbability local precipitationDesc1 = FC.forecast[FC_1].precipitationDesc local rainFall1 = FC.forecast[FC_1].rainFall local snowFall1 = FC.forecast[FC_1].snowFall local airInfo1 = FC.forecast[FC_1].airInfo local airDescription1 = FC.forecast[FC_1].airDescription local windSpeed1 = FC.forecast[FC_1].windSpeed local windDirection1 = FC.forecast[FC_1].windDirection local windDesc1 = FC.forecast[FC_1].windDesc local windDescShort1 = FC.forecast[FC_1].windDescShort local visibility1 = FC.forecast[FC_1].visibility local iconName1 = FC.forecast[FC_1].iconName local iconLink1 = FC.forecast[FC_1].iconLink local weekday1 = FC.forecast[FC_1].weekday local localTime1 = FC.forecast[FC_1].localTime local daylight3 = FC.forecast[FC_3].daylight local description3 = FC.forecast[FC_3].description local skyDescription3 = FC.forecast[FC_3].skyDescription local temperature3 = FC.forecast[FC_3].temperature local temperatureDesc3 = FC.forecast[FC_3].temperatureDesc local comfort3 = FC.forecast[FC_3].comfort local humidity3 = FC.forecast[FC_3].humidity local dewPoint3 = FC.forecast[FC_3].dewPoint local precipitationProbability3 = FC.forecast[FC_3].precipitationProbability local precipitationDesc3 = FC.forecast[FC_3].precipitationDesc local rainFall3 = FC.forecast[FC_3].rainFall local snowFall3 = FC.forecast[FC_3].snowFall local airInfo3 = FC.forecast[FC_3].airInfo local airDescription3 = FC.forecast[FC_3].airDescription local windSpeed3 = FC.forecast[FC_3].windSpeed local windDirection3 = FC.forecast[FC_3].windDirection local windDesc3 = FC.forecast[FC_3].windDesc local windDescShort3 = FC.forecast[FC_3].windDescShort local visibility3 = FC.forecast[FC_3].visibility local iconName3 = FC.forecast[FC_3].iconName local iconLink3 = FC.forecast[FC_3].iconLink local weekday3 = FC.forecast[FC_3].weekday local localTime3 = FC.forecast[FC_3].localTime FC1_wind.rename('Wind Forecast around ' .. tostring(hour_correct(domoticz.utils.round((hour+1))))) FC1_wind.updateWind(tonumber(windDirection1), cardinal_heading(tonumber(windDirection1)), domoticz.utils.round(windSpeed1/3.6,1), 0, domoticz.utils.round(temperature1,1), domoticz.utils.round(Wind_Chill(temperature1,windSpeed1),1)) -- bearing, direction, speed, gust, temperature, chill FC1_vis.updateVisibility(visibility1) FC1_vis.rename('vis Forecast around '.. tostring(hour_correct(domoticz.utils.round((hour+1))))) FC1_hum.updateHumidity(humidity1,humidity_status(tonumber(humidity1))) FC1_hum.rename('Hum Forecast around '.. tostring(hour_correct(domoticz.utils.round((hour+1))))) -- local TAF1 = 'HOME '.. windDirection1..windSpeed1..' '..visibility1.. domoticz.log('snowFall '..snowFall1) if snowFall1 == '*' then domoticz.log('No snow') end FC3_wind.rename('Wind Forecast around ' .. tostring(hour_correct(domoticz.utils.round((hour+3))))) FC3_wind.updateWind(tonumber(windDirection3), cardinal_heading(tonumber(windDirection3)), domoticz.utils.round(windSpeed3/3.6,1), 0, domoticz.utils.round(temperature3,1), domoticz.utils.round(Wind_Chill(tonumber(temperature3),tonumber(windSpeed3)),1)) -- bearing, direction, speed, gust, temperature, chill FC3_vis.updateVisibility(visibility3) FC3_vis.rename('vis Forecast around '.. tostring(hour_correct(domoticz.utils.round((hour+3))))) FC3_hum.updateHumidity(humidity3,humidity_status(tonumber(humidity3))) FC3_hum.rename('Hum Forecast around '.. tostring(hour_correct(domoticz.utils.round((hour+3))))) domoticz.log(localTime1..' '..localTime3) domoticz.devices(254).updateText(localTime1..' '..localTime3) end end }
- Spoiler: show
- {
hourlyForecasts: {
forecastLocation: {
forecast: [
{
daylight: "D",
description: "Partly cloudy. Mild.",
skyInfo: "10",
skyDescription: "Partly cloudy",
temperature: "20.30",
temperatureDesc: "Mild",
comfort: "20.30",
humidity: "50",
dewPoint: "9.40",
precipitationProbability: "7",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "15.12",
windDirection: "349",
windDesc: "North",
windDescShort: "N",
visibility: "20.14",
icon: "4",
iconName: "partly_cloudy",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/3.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T14:00:00.000+02:00",
localTime: "1405252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "More sun than clouds. Mild.",
skyInfo: "8",
skyDescription: "More sun than clouds",
temperature: "20.80",
temperatureDesc: "Mild",
comfort: "20.80",
humidity: "48",
dewPoint: "9.30",
precipitationProbability: "5",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "16.20",
windDirection: "355",
windDesc: "North",
windDescShort: "N",
visibility: "19.65",
icon: "2",
iconName: "mostly_sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/2.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T15:00:00.000+02:00",
localTime: "1505252020",
localTimeFormat: "HHMMddyyyy"
},
etc