How to make openhab to remember GPIO states before reset?
And how to make openhab to set remembered states after restart.
I have persistence rrd4j and i have rule to persist every change i have rule to roll back all persisted info after reset, bit not working good, every time after reset give me exact same GPIO output states no meter how is set before reset.
rule "System started"
18:41:40.321 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘System started’: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null
18:41:40.326 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘RedLED’ received command ON
Since this is a System started Rule, I’m going to guess that what is happening is the Item is not fully initialized when the Rule runs. You are not seeing errors now because the rule only does something if the item has been initialized. I bet if you added an else with a log you will find that the rule isn’t doing anything some it all of the time.
You can add a Thread::sleep to the Rule to give everything a chance to become initialized.
It look like the mcp23017 is initialized and your solution is working.
The problem was that I had a sitemap which inverted the status and this lead to incorrect rule action.
Switch item=A0 mappings=[OFF=ON, ON=OFF]
It is not related to this topic anymore but I had this in my sitemap because the MCP23017 addon is sending a logic high when I need a low and vice versa so for example my relays are switching on when an OFF command is sent.
Inversing the logic in the sitemap might not be the best idea.
I need to find out something…maybe will do it with unbound items.