Subscribe to events trough REST API

Hi, I’m working on an node.js module for heating control in our house. Now it is working with a “polling” concept where all relevant items (thermostats, temp sensors, etc) are checked every minute.

I’ve started to add event driven actions - and subscribing to item events is pretty much straight forward with "/rest/events?topics=smarthome/items/{itemName}

The next step is to subscribe to events from all members of a group (eg. all temp sensors and thermostats), but I am not able to find out how to do this trough the REST API. What I am looking for is something like the “Member of {groupName} changed” in the built in rules engine.

Thanks

Olav

OpenHAB 2 or 3?

OpenHAB 2

@Spaceman_Spiff does that with HABApp in Python 3. Perhaps he has some tips.

You have to subscribe to the group item and then you should get the corresponding events through the API.
Probably you have to subscribe to the group members as well …

1 Like

Thanks for the guiding.

After some more investigation, I found the following:

  • A group which is defined without itemtype (and function) will not emit any events.
  • After I defined the aThermostat group like this:
    “Group:Number:SUM gThermostats”, a group event is emitted when the sum of values for all group items are changed

Source for the information: Items | openHAB

The path to the event(s): /rest/events?topics=smarthome/items/gThermostats

Example of event:
{
topic: ‘smarthome/items/gThermostats/Thermostat_Kitchen_Room/statechanged’,
payload: ‘{“type”:“Decimal”,“value”:“30”,“oldType”:“Decimal”,“oldValue”:“40”}’,
type: ‘GroupItemStateChangedEvent’
}

Thanks to all

2 Likes