How to push state changes of ONH objects to an external system automatically?

Functionality and usage of the OpenNethome Server
Post Reply
Posts: 33
Joined: Fri Aug 21, 2015 6:30 am

How to push state changes of ONH objects to an external system automatically?

Post by mikkot »


I'm working on yet another dashboard for ONH (and more). It's based on touchscreen that I plan to mount on the wall.

I would like to have it synchronised with ONH object states in real time. Currently it's polling the statuses via REST once per minute. This causes some issues when someone uses e.g. physical switch to trigger a light; the dashboard does not see the change immediately and has wrong status in the dashboard for the light for a moment.

How would you implement a functionality that automatically triggers an event e.g. to an external system REST API whenever a state change (including attributes like brightness, color temp etc) happens in ONH? The API call could be handled by a script, but I'm missing a way to trigger the script somehow.

EDIT: While answering to another post here I started wondering whether this functionality already exists in ONH. E.g. in MQTTValueLogger you have ReactOnEvent "mode" that basically seems to react on ANY event in the system. This would actually be enough for a script to fulfil my needs (given that the event details, e.g. similar json dataset you receive for an object by using ONH REST, can be passed on to the script). Ideally there could be a "ReactOnEvent" object with selectable list of groups(eg. all lamps)/objects/attributes to filter only the wanted events that would then trigger something outside the system.

Any ideas or pointers to an existing object that does this already?


P.S. I'd love to be able to update ONH object states as well to make sure ONH has correct states all the time. E.g. with MQTT enabled switches it would be really nice to set ONH state based on the "MQTT response" feedback. The response can well be "negative" i.e. switching something on fails -> need to change ONH object state back to "off".
Site Admin
Posts: 313
Joined: Sun Nov 30, 2014 2:16 pm

Re: How to push state changes of ONH objects to an external system automatically?

Post by stefangsbb »

I have been a bit careful with Items that trigger on all events and does something, because of the risk of creating "loops" where the action triggers an event which triggers an action and so on... As long as the Item does something that does not cause an internal event (or an event if can ignore) it would work. Do you have a suggestion?

In which Item do you want to set the state?
Post Reply