Closed alfista2600 closed 10 months ago
You get the change events in HABApp for items/things so updating a database should be easy because you an register an event listener in a rule. The only thing you have to do is to re-query openHAB for the link when you get an event but the item endpoint is available in the rule. And a one time sync on startup would probably also make sense ...
Thanks for the reply. Do I have to iterate through every item/thing and create a listener for each or is there a way to do them all at once? I still don't really speak the language but suspect EventFilter plays a role. I do have Things being monitored this way, but it seems clumsy to do this for 1800 items, groups, etc. I guess I could do some more filtering so I am only monitoring certain items.
I have been doing lots of updates through the API and creating/updating items from text so I'm trying to find a quick way produce a history of changes.
No - it's only one listener on openHAB.Items
(I think). There you listen for the ItemAddedEvent
, ItemRemovedEvent
and ItemUpdatedEvent
with the EventFilter (or you can just listen to all events and check the instances in your function). For the Things there is a different topic openHAB.Things
(I think) and the events are named differently.
You fill your db once initially and then only track the updates with the events.
Do you see the topics/events?
Ahh, great.
Yes, I think I see these under:
HABApp.openhab.events.item_events.ItemUpdatedEvent ?
Yes, I currently run a script that uploads everything periodically, but it takes a while and it seemed it would be more fun if it was possible to have HABApp involved. I'll give this a try later today!
Does it work as expected?
I believe so. I only had a few minutes to tinker before having to focus on other less-fun projects
Hi @spacemanspiff2007 !
Not sure if this is the best place to ask this question...
I have a few scripts that import OH Items/Things/Links into a database that I can easily query/sort/update/export/link to foreign data/etc. to look for assorted issues as I hone my environment.
what is the best practice to capture all changes (through UI, API, HABapp) to these elements so I can update the database in real-time instead of periodic import?