when I edit a items.file that contains my GIPO items they loose there state and fall back to the default value.
I tried to solve this with a rule but this rule dosen’t get triggered when I change the rules file.
//rule "Initialize GIPO after restart"
rule "set GPIO after restart"
when
System started
then
logInfo(filename, "Set GPIO")
if(Unbound_Heizung_Wohnzimmer.state == ON){
GPIO_Heizung_Wohnzimmer.sendCommand(ON)
} else {
GPIO_Heizung_Wohnzimmer.sendCommand(OFF)
}
end
2018-09-06 19:36:42.094 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'heaters.items'
2018-09-06 19:36:42.125 [vent.ItemStateChangedEvent] - GPIO_Heizung_Wohnzimmer changed from ON to UNDEF
2018-09-06 19:36:42.635 [vent.ItemStateChangedEvent] - GPIO_Heizung_Wohnzimmer changed from UNDEF to OFF
I do run the latest stable openhabian on a Raspberry PI 2.
I assume the GPIO pins are the ones on your RPI, that’s also running OH. Use debug or trace in the logs to see if you can tell whats occurring when you edit a GPIO items file. Maybe open another terminal with a system log running aslo.
UNDEF - that’s interesting. I thought Items were created initially with NULL state, and a binding might set UNDEF e.g. in the case of a device read error.
Experimenting (OH 2.3.0), reloading an .items file doesn’t change the state of an Item that you haven’t edited. The existing state is preserved.
If you have edited the Item, it does get set to NULL. But does not trigger any rule listening for change on it.
I suspect what is happening is that the GPIO binding is somehow involved. Maybe reloading an Item bound to a binding looks for a ‘refresh’ value from the binding. And here the binding responds with UNDEF, which gives what you see.
(Just as a comment for later readers - I believe Group Items behave quite differently on an .items file reload.)