I have configured OpenHAB to read data from my central heating system via the Modbus binding, and it works well. I also want to expose the data to HomeKit, and for that purpose I need to add a few “derived” dummy switches to show, for example if the filter needs to be replaced based on the life time of the filter, below are the items relevant:
Number prmFilterInlet_TimeThreshold "Inlet Filter Time Threshold" <calendar> (gNilanVentilation) {channel="modbus:data:Ventilation:FilterReplaceWrite:hold1326:number"}
Number prmFilterInlet_PassDays "Inlet Filter Replace" <calendar> (gNilanVentilation) {channel="modbus:data:Ventilation:FilterReplaceRead:input1328:number"}
Switch HomeKitVentilationFilterItem "Ventilation Filter Replace"
Basically I want to set the dummy switch HomeKitVentilationFilterItem on when the filter needs to be replaced, and I configured the following rule:
rule "Nilan Ventilation Filter Replace"
when
Item prmFilterInlet_PassDays changed
then
if(prmFilterInlet_PassDays == 360) {
sendCommand(HomeKitVentilationFilterItem, ON)
}
else {
sendCommand(HomeKitVentilationFilterItem, OFF)
}
end
Very simple stuff and it works as expected when the system is initialised, I can see the state of HomeKitVentilationFilterItem changed from NULL to OFF. However when I run the system a few days, the value HomeKitVentilationFilterItem has changed back to NULL, below is the result when I call the REST service (which is also used by the Homebridge Plugin I think):
{"link":"http://IP_ADDRESS:80XX/rest/items/HomeKitVentilationFilterItem","state":"NULL","editable":false,"type":"Switch","name":"HomeKitVentilationFilterItem","label":"Ventilation Filter Replace","tags":[],"groupNames":[]}
I tried to find an trace in the events.log file and I can only see the dummy switch has been set to OFF everyday:
2019-06-23 02:07:48.024 [ome.event.ItemCommandEvent] - Item 'HomeKitVentilationFilterItem' received command OFF
2019-06-24 03:19:55.048 [ome.event.ItemCommandEvent] - Item 'HomeKitVentilationFilterItem' received command OFF
There is no indicate in the log that the value is reset to NULL. Given the rule is triggered very rarely (on daily basis), I’m wondering if there is some kind of cache timeout in OpenHAB, so when the value isn’t changed for X hours, it will try to pull the value again. And because the dummy switch isn’t connect to any channel, therefore it returns NULL.
Any suggestion on possible root cause or potential fix to the problem is appreciated!