How to set "forecastString" ?

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

Moderator: leecollings

Post Reply
solarboy
Posts: 357
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

How to set "forecastString" ?

Post 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 ?
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: How to set "forecastString" ?

Post 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"
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
solarboy
Posts: 357
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: How to set "forecastString" ?

Post by solarboy »

Ah OK, thanks again Walter, I think I can work with that.

You're a great help. :mrgreen:
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
solarboy
Posts: 357
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: How to set "forecastString" ?

Post 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.
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: How to set "forecastString" ?

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: How to set "forecastString" ?

Post by boum »

Well dz.BARO_SUNNY here but waltervl is right.
solarboy
Posts: 357
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: How to set "forecastString" ?

Post 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.
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: How to set "forecastString" ?

Post by boum »

Looks like a typo somewhere, it should be dz.BARO_PARTLYCLOUDY.
See: https://domoticz.com/forum/viewtopic.ph ... 06#p192802
solarboy
Posts: 357
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: How to set "forecastString" ?

Post by solarboy »

Ah brilliant, I copied form the Dzvents wiki. Thank you !
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest