- Platform information:
- Hardware: R-Pi4
- OS: OpenHabian
- Java Runtime Environment: which java platform is used and what version
- openHAB version: 3.0.2
- Issue of the topic: Can’t set ITEM to value when it is NULL
I can shorten this. I’d give you my takes of woe with OH3.0.2 but it’ll be easier if I just ask outright.
How do I detect a NULL item state and set it to a sensible value? e.g. an item defined in /etc/openhab/items/heating.items
Number:Temperature Entrance_Target_Temp "Entrance Target"
And the code
if(Entrance_Target_Temp.state === NULL ) {
logInfo("Heating", "Set default entrance target 10")
Entrance_Target_Temp.state=10
}
is ignored… Because a few lines later
logInfo("Heating", "CALL "+CallFor+" TARGET ENTRANCE "+Entrance_Target_Temp.state+" ACTUAL "+HallEntrance_Temp.state)
logs
2021-05-23 17:40:27.654 [INFO ] [rg.openhab.core.model.script.Heating] - CHECK Entrance target=NULL vs actual NULL
So how do you check for a NULL value in an item?