sudden error  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

sudden error

Post by nosehook »

Hi,

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
script:
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
}
example output of request (JSON):
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
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sudden error

Post by waaren »

nosehook wrote: Monday 25 May 2020 16:20 Is there anyone who can help me? It ran fine, until 1505 local time today and now it keeps giving this error.
The function domoticz.utils.round was changed in a recent beta and does stricter type checking.
It looks like you are feeding it a string in one of the parms.

Can you replace the self.round function in the file <domoticz dir>/dzVents/runtime/Utils.lua with this one and check again ? (and report back)
It will show what the unexpected value is and try to convert the string to a number.

Code: Select all

function self.round(value, decimals)
    if type(value) ~= 'number' then
        self.log('Type of first parm (' .. tostring(value) .. ') is ' .. type(value) .. '. Function round expects a number', self.LOG_ERROR )
        value = tonumber(value)
    end
    if decimals and type(decimals) ~= 'number'  then
        self.log('Type of second parm (' .. tostring(decimals) .. ') is ' .. type(decimals) .. '. Function round expects a number', self.LOG_ERROR )
        decimals = tonumber(decimals) or 0
    end

    if value >= 0 and decimals and decimals > 0 then
        return math.floor( (value * 10 ^ decimals) + 0.5) / (10 ^ decimals)
    elseif value >=0 then
        return math.floor(value + 0.5)
    elseif decimals and decimals > 0 then
        return math.ceil ( (value * 10 ^ decimals) - 0.5) / (10 ^ decimals)
    else
        return math.ceil(value - 0.5)
    end
end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sudden error

Post by nosehook »

Hi waaren,

Did as requested:

Code: Select all

2020-05-25 17:55:01.650 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (19.10) is string. Function round expects a number
2020-05-25 17:55:01.652 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (15.70) is string. Function round expects a number
hope this sorts something.

the dataset was
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"
},
{
daylight: "D",
description: "More sun than clouds. Mild.",
skyInfo: "8",
skyDescription: "More sun than clouds",
temperature: "21.10",
temperatureDesc: "Mild",
comfort: "21.10",
humidity: "47",
dewPoint: "9.20",
precipitationProbability: "3",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "17.64",
windDirection: "1",
windDesc: "North",
windDescShort: "N",
visibility: "19.15",
icon: "2",
iconName: "mostly_sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/2.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T16:00:00.000+02:00",
localTime: "1605252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "Mostly sunny. Mild.",
skyInfo: "3",
skyDescription: "Mostly sunny",
temperature: "20.90",
temperatureDesc: "Mild",
comfort: "20.90",
humidity: "47",
dewPoint: "9.10",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "20",
airDescription: "Beautiful",
windSpeed: "18.36",
windDirection: "5",
windDesc: "North",
windDescShort: "N",
visibility: "18.65",
icon: "2",
iconName: "mostly_sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/2.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T17:00:00.000+02:00",
localTime: "1705252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "Mostly sunny. Mild.",
skyInfo: "3",
skyDescription: "Mostly sunny",
temperature: "20.20",
temperatureDesc: "Mild",
comfort: "20.20",
humidity: "50",
dewPoint: "9.30",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "20",
airDescription: "Beautiful",
windSpeed: "18.36",
windDirection: "9",
windDesc: "North",
windDescShort: "N",
visibility: "17.16",
icon: "2",
iconName: "mostly_sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/2.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T18:00:00.000+02:00",
localTime: "1805252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "Sunny. Mild.",
skyInfo: "1",
skyDescription: "Sunny",
temperature: "19.10",
temperatureDesc: "Mild",
comfort: "19.10",
humidity: "54",
dewPoint: "9.40",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "20",
airDescription: "Beautiful",
windSpeed: "17.64",
windDirection: "13",
windDesc: "North",
windDescShort: "N",
visibility: "16.66",
icon: "1",
iconName: "sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/1.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T19:00:00.000+02:00",
localTime: "1905252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "Sunny. Mild.",
skyInfo: "1",
skyDescription: "Sunny",
temperature: "17.10",
temperatureDesc: "Mild",
comfort: "17.10",
humidity: "61",
dewPoint: "9.40",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "20",
airDescription: "Beautiful",
windSpeed: "16.20",
windDirection: "18",
windDesc: "North",
windDescShort: "N",
visibility: "15.79",
icon: "1",
iconName: "sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/1.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T20:00:00.000+02:00",
localTime: "2005252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "Sunny. Cool.",
skyInfo: "1",
skyDescription: "Sunny",
temperature: "15.70",
temperatureDesc: "Cool",
comfort: "15.70",
humidity: "66",
dewPoint: "9.30",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "20",
airDescription: "Beautiful",
windSpeed: "13.68",
windDirection: "20",
windDesc: "North",
windDescShort: "N",
visibility: "14.93",
icon: "1",
iconName: "sunny",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/1.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T21:00:00.000+02:00",
localTime: "2105252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Clear. Cool.",
skyInfo: "2",
skyDescription: "Clear",
temperature: "14.50",
temperatureDesc: "Cool",
comfort: "13.95",
humidity: "72",
dewPoint: "9.40",
precipitationProbability: "1",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "10.44",
windDirection: "21",
windDesc: "North",
windDescShort: "N",
visibility: "14.06",
icon: "13",
iconName: "night_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/16.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T22:00:00.000+02:00",
localTime: "2205252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Haze. Cool.",
skyInfo: "6",
skyDescription: "Haze",
temperature: "11.40",
temperatureDesc: "Cool",
comfort: "10.60",
humidity: "85",
dewPoint: "8.90",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "8.28",
windDirection: "24",
windDesc: "Northeast",
windDescShort: "NE",
visibility: "9.19",
icon: "14",
iconName: "night_mostly_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/23.png",
dayOfWeek: "2",
weekday: "Monday",
utcTime: "2020-05-25T23:00:00.000+02:00",
localTime: "2305252020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Clear. Cool.",
skyInfo: "2",
skyDescription: "Clear",
temperature: "10.00",
temperatureDesc: "Cool",
comfort: "8.95",
humidity: "91",
dewPoint: "8.60",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "8.28",
windDirection: "38",
windDesc: "Northeast",
windDescShort: "NE",
visibility: "13.33",
icon: "13",
iconName: "night_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/16.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T00:00:00.000+02:00",
localTime: "0005262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Clear. Cool.",
skyInfo: "2",
skyDescription: "Clear",
temperature: "9.70",
temperatureDesc: "Cool",
comfort: "8.60",
humidity: "91",
dewPoint: "8.30",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "8.28",
windDirection: "60",
windDesc: "Northeast",
windDescShort: "NE",
visibility: "11.46",
icon: "13",
iconName: "night_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/16.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T01:00:00.000+02:00",
localTime: "0105262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Clear. Cool.",
skyInfo: "2",
skyDescription: "Clear",
temperature: "9.20",
temperatureDesc: "Cool",
comfort: "8.16",
humidity: "93",
dewPoint: "8.10",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "7.56",
windDirection: "79",
windDesc: "East",
windDescShort: "E",
visibility: "12.91",
icon: "13",
iconName: "night_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/16.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T02:00:00.000+02:00",
localTime: "0205262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "Clear. Cool.",
skyInfo: "2",
skyDescription: "Clear",
temperature: "8.60",
temperatureDesc: "Cool",
comfort: "7.83",
humidity: "94",
dewPoint: "7.60",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "6.12",
windDirection: "90",
windDesc: "East",
windDescShort: "E",
visibility: "11.36",
icon: "13",
iconName: "night_clear",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/16.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T03:00:00.000+02:00",
localTime: "0305262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "N",
description: "High level clouds. Cool.",
skyInfo: "12",
skyDescription: "High level clouds",
temperature: "7.80",
temperatureDesc: "Cool",
comfort: "7.25",
humidity: "93",
dewPoint: "6.80",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "5.04",
windDirection: "100",
windDesc: "East",
windDescShort: "E",
visibility: "12.80",
icon: "16",
iconName: "night_high_clouds",
iconLink: "https://weather.ls.hereapi.com/static/w ... con/21.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T04:00:00.000+02:00",
localTime: "0405262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "High level clouds. Cool.",
skyInfo: "12",
skyDescription: "High level clouds",
temperature: "7.20",
temperatureDesc: "Cool",
comfort: "7.20",
humidity: "94",
dewPoint: "6.30",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "4.32",
windDirection: "118",
windDesc: "Southeast",
windDescShort: "SE",
visibility: "14.25",
icon: "5",
iconName: "high_clouds",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/4.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T05:00:00.000+02:00",
localTime: "0505262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "High level clouds. Chilly.",
skyInfo: "12",
skyDescription: "High level clouds",
temperature: "7.00",
temperatureDesc: "Chilly",
comfort: "7.00",
humidity: "97",
dewPoint: "6.60",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "4.32",
windDirection: "148",
windDesc: "Southeast",
windDescShort: "SE",
visibility: "13.70",
icon: "5",
iconName: "high_clouds",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/4.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T06:00:00.000+02:00",
localTime: "0605262020",
localTimeFormat: "HHMMddyyyy"
},
{
daylight: "D",
description: "High level clouds. Cool.",
skyInfo: "12",
skyDescription: "High level clouds",
temperature: "8.70",
temperatureDesc: "Cool",
comfort: "8.27",
humidity: "92",
dewPoint: "7.50",
precipitationProbability: "0",
precipitationDesc: "",
rainFall: "*",
snowFall: "*",
airInfo: "*",
airDescription: "",
windSpeed: "5.04",
windDirection: "174",
windDesc: "South",
windDescShort: "S",
visibility: "15.15",
icon: "5",
iconName: "high_clouds",
iconLink: "https://weather.ls.hereapi.com/static/w ... icon/4.png",
dayOfWeek: "3",
weekday: "Tuesday",
utcTime: "2020-05-26T07:00:00.000+02:00",
localTime: "0705262020",
localTimeFormat: "HHMMddyyyy"
},

Seems the 19.10 is temperature and comfort. The 15.70 too, but in a different array (looking ahead 1 and 3 hours).


waaren wrote: Monday 25 May 2020 17:35
nosehook wrote: Monday 25 May 2020 16:20 Is there anyone who can help me? It ran fine, until 1505 local time today and now it keeps giving this error.
The function domoticz.utils.round was changed in a recent beta and does stricter type checking.
It looks like you are feeding it a string in one of the parms.

Can you replace the self.round function in the file <domoticz dir>/dzVents/runtime/Utils.lua with this one and check again ? (and report back)
It will show what the unexpected value is and try to convert the string to a number.

Code: Select all

function self.round(value, decimals)
    if type(value) ~= 'number' then
        self.log('Type of first parm (' .. tostring(value) .. ') is ' .. type(value) .. '. Function round expects a number', self.LOG_ERROR )
        value = tonumber(value)
    end
    if decimals and type(decimals) ~= 'number'  then
        self.log('Type of second parm (' .. tostring(decimals) .. ') is ' .. type(decimals) .. '. Function round expects a number', self.LOG_ERROR )
        decimals = tonumber(decimals) or 0
    end

    if value >= 0 and decimals and decimals > 0 then
        return math.floor( (value * 10 ^ decimals) + 0.5) / (10 ^ decimals)
    elseif value >=0 then
        return math.floor(value + 0.5)
    elseif decimals and decimals > 0 then
        return math.ceil ( (value * 10 ^ decimals) - 0.5) / (10 ^ decimals)
    else
        return math.ceil(value - 0.5)
    end
end
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sudden error

Post by waaren »

nosehook wrote: Monday 25 May 2020 18:00 Hi waaren,

Did as requested:

Code: Select all

2020-05-25 17:55:01.650 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (19.10) is string. Function round expects a number
2020-05-25 17:55:01.652 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (15.70) is string. Function round expects a number
hope this sorts something.
Thx.

These messages show that your script calls the domoticz.utils.round function with variables of type string as the value to round. To prevent the error message you should ensure that the round function is called with a variable or value of type number.
You can force that by using the builtin conversion method tonumber()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sudden error

Post by nosehook »

Cheers! Did that and the issue is gone. Will restore the regular utils.lua now.
I was under the impression that dzVents would change strings to text automatically? It used to before the last update.
will this be restored?

Thanks again for your help!
waaren wrote: Monday 25 May 2020 23:29
nosehook wrote: Monday 25 May 2020 18:00 Hi waaren,

Did as requested:

Code: Select all

2020-05-25 17:55:01.650 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (19.10) is string. Function round expects a number
2020-05-25 17:55:01.652 Error: dzVents: Error: (3.0.7) here_wx_fc: Type of first parm (15.70) is string. Function round expects a number
hope this sorts something.
Thx.

These messages show that your script calls the domoticz.utils.round function with variables of type string as the value to round. To prevent the error message you should ensure that the round function is called with a variable or value of type number.
You can force that by using the builtin conversion method tonumber()
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sudden error  [Solved]

Post by waaren »

nosehook wrote: Monday 25 May 2020 23:33 I was under the impression that dzVents would change strings to text automatically? It used to before the last update.
Lua does happily calculate with strings and because dzVents = Lua, it does that too. :)
See below an example of this behavior:

Code: Select all

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> myString = '12'
> type(myString)
string

> myString * 4
48.0
but comparing a string against a number is not possible :cry:

Code: Select all

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> myString = '12'
> type(myString)
string

> myString == '13'
false

>myString > 0
stdin:1: attempt to compare number with string
stack traceback:
        stdin:1: in main chunk
        [C]: in ?

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest