All items in an items file are updated whenever it’s saved. Do you save the file often enough that it’s an issue? If so, your options are:
Create a separate file for that item, so that it doesn’t get updated when you save default.items.
Change the trigger in your rule so that it doesn’t fire on every update. I don’t know how you’re using it, but “received command” or “changed” is typically sufficient for most purposes.
I’ve also tried to use it with ‘expire’ and update the state to UNDEF, but after item refresh it somehow backs to ‘single’ state and trigger with ‘changed’ my light.
In the beginning I suspected mapdb, but when I disabled it doesn’t help.
So you’ve installed MapDB and are using that. Did you remove rrd4j? If not did you create an rrd4j.persist file so that this Item is not saved and restored on startup also? By default, without a .persist file to tell it otherwise, most persistence add-ons will save all Items on every change and restoreOnStartup.
As @rpwong mentioned, in the majority of cases triggering on change instead of update will do just fine and prevents the item update event from being fired when saving the items file.
Just using change trigger isn’t going to work.
When you pressed the button, it updates it with the value ‘single’ and when you pressed it again, it will update it again with ‘single’. No state changes there so you’ll miss the second and all subsequent press events.
I was trying to use your approach with empty string, I was updating it with expire=“1s,state=UNDEF” and it doesn’t help - when items file is saved od OH restarted it refreshes to ‘single’ value somehow and turns my light on…
It seems yes - there is action: N/A after expiry, so should be fine.
If you’re asking if any changes happens on zigbe2mqtt level when I’m saving items - no, I didn’t noticed any changes in logs. I just see reaction in openhab.
Pure coincidence. I’ve never used “received command” with an MQTT item, so I didn’t realize that would be an issue until you pointed out that it’s not.
I’ve now reconfigured all my mqtt based buttons to postCommand and it works beautifully so far. It simplifies things, now I no longer have to update the item to blank to detect changes. Thanks again! I love it when a better solution comes along!