pdmangel / node-red-contrib-openhab2

Other
21 stars 15 forks source link

Nodes for things instead of items #16

Closed SierraNL closed 6 years ago

SierraNL commented 6 years ago

Within OpenHAB 2 you can also created rules on Status changes to Things, beside Items: http://docs.openhab.org/configuration/rules-dsl.html#thing-based-triggers

I would really like to use this in the node-red rules. For instance I have a lot of Hue White bulbs that go ONLINE or OFFLINE via the normal light switches. And I can use these triggers to start a rule.

Things are their status options: http://docs.openhab.org/concepts/things.html

fab33 commented 6 years ago

It will be fine for some bindings too. For amazon dash button or Xiaomi mi Home, for some things you only have event triggered and you can't associate item to this channel. On OpenHAB SSE when you see all the bus you have such messages : event: message data: {"topic":"smarthome/channels/mihome:sensor_switch:xxx:xxx:button/triggered","payload":"{\"event\":\"SHORT_PRESSED\",\"channel\":\"mihome:sensor_switch:xxx:xxx:button\"}","type":"ChannelTriggeredEvent"} event: message data: {"topic":"smarthome/channels/mihome:sensor_switch:xxx:xxx:button/triggered","payload":"{\"event\":\"DOUBLE_PRESSED\",\"channel\":\"mihome:sensor_switch:xxx:xxx:button\"}","type":"ChannelTriggeredEvent"}

pdmangel commented 6 years ago

Thanks for the info Fabien! Which url did you use to obtain these events ? Did you find more documentation on OpenHAB SSE ?

Orfait commented 6 years ago

I am also very interested in having events in your node. It would allow to have all rules in node-red, which is much more easy to edit. I can help in testing and maybe develop.

fab33 commented 6 years ago

I'm using this URL : http://openhab.lan:8080/rest/events?topics=smarthome/channels you can have more information here : https://www.eclipse.org/smarthome/documentation/features/events.html and here : https://www.eclipse.org/smarthome/documentation/features/rest.html

pdmangel commented 6 years ago

Thanks for the valuable links, Fabien. I will implement a new 'openhab2-events' node for this purpose.

fab33 commented 6 years ago

Did you start working on it ? I will have some time to work on it.

pdmangel commented 6 years ago

I checked a simple version of a new node 'openhab2-events' in in github. It subscribes to all events. Goal is in a future version to offer filtering on event type and entity name/id.

fab33 commented 6 years ago

You forgot to update package.json with new version number so I can't update with node-red UI. Just a question, why did you use @joeybaker fork ? The most important part (ie issues with multiple reconnect) are in the original branch (https://github.com/EventSource/eventsource) @joeybaker branch doesn't seem to bu up to date.

pdmangel commented 6 years ago

I updated the version number to 1.1.0.

pdmangel commented 6 years ago

And a valid remark regarding the eventsource library. I'll try to switch asap.

fab33 commented 6 years ago

NOK on npmjs so it's not possible to update via node-red palette.

pdmangel commented 6 years ago

Sorry... Only GitHub AST for now. I'll try to release on npm asap.

pdmangel commented 6 years ago

Sorry... Only GitHub AST for now. I'll try to release on npm asap.

pdmangel commented 6 years ago

updated in npm ...

fab33 commented 6 years ago

ok it works fine.