Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: include device type in websocket payload #159

Closed
rtenklooster opened this issue Sep 1, 2017 · 4 comments
Closed

Feature request: include device type in websocket payload #159

rtenklooster opened this issue Sep 1, 2017 · 4 comments

Comments

@rtenklooster
Copy link

I've created a websockets to MQTT bridge. It allows me to publish messages to my MQTT broker.
This way I'm able to respond on motion sensors and switches without polling.

The websocket client is missing some relevant information. It would be great if the "type": "ZHAPresence" would be included in the message payload. It would be even nicer if a user would be able to define witch fields should be included in the message.

Currently I have a workaround:
if buttonevent is null > switch
else > motion

However when adding more device types this is not the way it should be done. Of course it would be possible to query the rest api on the corresponding ID, this would cause a lot of unneeded requests.

@manup
Copy link
Member

manup commented Sep 1, 2017

Doesn't the event already carry all needed information?

  • switches: state/buttonevent
  • motion sensors: state/buttonevent
  • light sensors: state/lightlevel
  • contact sensors: state/openclose

etc.

In my opinion the events should only contain dynamic / changed data, not the static details of the resource — these should be queried via REST API. Otherwise we could reason to include the full resource in each event which would be overkill.

@rtenklooster
Copy link
Author

Great. Didn't know the event contained that info. Currently I have only connected motion sensors and switches so i didn't saw the logic.

I agree less is better. Thanks again.

@manup
Copy link
Member

manup commented Sep 1, 2017

@ebaauw has written a nice node.js tool to log the websockets events, very handy to see what's happening

https://github.com/ebaauw/dc_eventlog

@rtenklooster
Copy link
Author

rtenklooster commented Sep 1, 2017

@manup Thanks for the link. I already created a nice node-red flow.
(Binds to websocket, processing event, publish to mqtt broker)
node-red-flow

I've updated the filtering on specific events. Seems to work fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants