steilerDev / homebridge-openhab2-complete

A homebridge plugin for openHAB, that has the expectation to fully support all Services offered by Apple's Homekit Accessory Protocol (HAP)
GNU General Public License v3.0
52 stars 16 forks source link

Do you have a best practice way to avoid NULL states? #10

Closed piejanssens closed 5 years ago

piejanssens commented 5 years ago

What's the easiest way to make sure my items are not initialized with NULL values when OH is starting up? I have this on occasion for some RFXCom (Lightning 4) switches (433MHz). I know this is more OH related, but it affects Homekit more, than operating through OH UI since the item is disabled in Homekit when it has a value of null.

apfelflo89 commented 5 years ago

You can use a persistence service and a database connection within openHAB and initialize the items with the option restoreOnStartup. When openHAB is starting the configured groups or items with the state NULL will get their last known state.

See: openHAB persistence

piejanssens commented 5 years ago

Thanks. I went with mapdb and it seems to be working fine.