Page 1 of 1

How to set "forecastString" ?

Posted: Wednesday 31 August 2022 14:12
by solarboy
Hi,
I am trying to set the "forecastString" value of a virtual TempHumBaro sensor as I have a script that compares 3 outdoor sensors (1 Zwave, 1 Zigbee and 1 RFX) and decides which one is still updating/can be trusted and writes the values from that sensor to a virtual sensor.

I am able to set temperature, humidity, status(a string, "humidityStatus" for example "Comfortable"), pressure but not forecast.

I can aquire "forecastString" from my actual sensor with ".forecastString" , for example 'Some Clouds' however I seem unable to write this value (or any other string) to my virtual sensor, indeed the "update" command is for "forecast" which is a numerical value (5) in my case.

From the wiki:

Temperature, Humidity, Barometer sensor

barometer: Number
dewPoint: Number
forecast: Number.
forecastString: String.
humidity: Number
humidityStatus: String
humidityStatusValue: Number. Value matches with domoticz.HUM_NORMAL, -HUM_DRY, HUM_COMFORTABLE, -HUM_WET.
temperature: Number
updateTempHumBaro(temperature, humidity, status, pressure, forecast): Function. forecast can be domoticz.BARO_NOINFO, BARO_SUNNY, BARO_PARTLY_CLOUDY, BARO_CLOUDY, BARO_RAIN. status can be domoticz.HUM_NORMAL, HUM_COMFORTABLE, HUM_DRY, HUM_WET, HUM_COMPUTE (let dzVents do the math)


If I write "5" as the forecast value I get "Prediction: Unknown" in my dashboard, whereas the original sensor displays "Some Clouds"

Wondering if anyone else had come across this ?

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 14:57
by waltervl
Forecast string is one of the following: BARO_NOINFO, BARO_SUNNY, BARO_PARTLY_CLOUDY, BARO_CLOUDY, BARO_RAIN

eg when set to BARO_PARTLY_CLOUDY the device will show "Some Clouds"

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 15:27
by solarboy
Ah OK, thanks again Walter, I think I can work with that.

You're a great help. :mrgreen:

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 15:52
by solarboy
I went with

Code: Select all

local mainR = (dz.utils.round(main.temperature, 2))
local mainhum = main.humidity
local mainstat = main.humidityStatusValue
local mainbar = (dz.utils.round(main.barometer, 1))
local mainforc = main.forecastString
local mainforc2 = 'BARO_NOINFO'

if mainforc == 'Some Clouds' then mainforc2 = 'BARO_PARTLY_CLOUDY'
elseif mainforc == 'Cloudy' then mainforc2 = 'BARO_CLOUDY'
elseif mainforc == 'Rain' then mainforc2 = 'BARO_RAIN'
elseif mainforc == 'Sunny' then mainforc2 = 'BARO_SUNNY'
            end
        
        if virtualtempR ~= mainR
        then virtualtemp.updateTempHumBaro(mainR,mainhum,mainstat,mainbar,mainforc2)
end
But I still end up with "unknown" as my forecastString and "5" as my forecast.

I then tried

Code: Select all

.....then virtualtemp.updateTempHumBaro(mainR,mainhum,mainstat,mainbar,BARO_SUNNY)
and still got unknown so I am not so sure now.

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 16:41
by waltervl
forecasts are constants and should be called with for example domoticz.BARO_SUNNY
The command should be:

Code: Select all

virtualtemp.updateTempHumBaro(mainR,mainhum,mainstat,mainbar,domoticz.BARO_SUNNY)
as these are domoticz constants.

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 16:43
by boum
Well dz.BARO_SUNNY here but waltervl is right.

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 17:57
by solarboy
Ahh of course, thank you both.

Code: Select all

local mainR = (dz.utils.round(main.temperature, 2))
local mainhum = main.humidity
local mainstat = main.humidityStatusValue
local mainbar = (dz.utils.round(main.barometer, 1))
local mainforc = main.forecastString
local mainforc2 = 'BARO_NOINFO'

        
        if virtualtempR ~= mainR and mainforc == 'Cloudy'
        then virtualtemp.updateTempHumBaro(mainR,mainhum,mainstat,mainbar,dz.BARO_CLOUDY)
end
This works ! but...

I cannot get "BARO_PARTLY_CLOUDY" to work. I am on the latest stable. All the others work though.

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 20:15
by boum
Looks like a typo somewhere, it should be dz.BARO_PARTLYCLOUDY.
See: https://domoticz.com/forum/viewtopic.ph ... 06#p192802

Re: How to set "forecastString" ?

Posted: Wednesday 31 August 2022 20:56
by solarboy
Ah brilliant, I copied form the Dzvents wiki. Thank you !