How to push state changes of ONH objects to an external system automatically?
Posted: Wed Feb 21, 2018 8:26 am
Hi,
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?
/Mikko
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".
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?
/Mikko
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".