websocket client

Discussions about Z-Way software and Z-Wave technology in general
geirgp
Posts: 42
Joined: 22 Oct 2015 19:16

websocket client

Post by geirgp »

Does the z-way device api support websockets or anything else that would let me listen to changes without hammering the server with poll requests?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

yes, please try rc17 with sockets.websocket. See https://github.com/Z-Wave-Me/Z-Way-Manu ... wayDev.pdf for more info

This is a bit experimental for now, but works so far. Would be cool to have some feedback too.
geirgp
Posts: 42
Joined: 22 Oct 2015 19:16

Re: websocket client

Post by geirgp »

Ok, that's great. I already tried connecting to z-way via web sockets, but couldn't figure on which url/path this is exposed by z-way. I cannot find this in the pdf you are referring to either, the example is just generic and connects to "ws://echo.websocket.org" instead of the z-way server.

What would be the correct url for connecting to z-way over a websocket?
past
Posts: 32
Joined: 11 Sep 2013 22:54

Re: websocket client

Post by past »

Looks like there is client only sockets. That sad.
KarlNickel
Posts: 3
Joined: 21 Nov 2015 14:27

Re: websocket client

Post by KarlNickel »

@PoltoS:
Could you please provide a working example how to connect to Z-Way using websockets? The documentation really is too generic :cry:
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: websocket client

Post by pofs »

Z-way currently supports just websocket client (well, it also has built-in websocket server, but it is intended for push notifications only, and is not scriptable).
Even if we add full websocket server later (but I still doubt its usefulness), it will be there only for integration with other services. Z-way itself will never be controllable via websockets.
KarlNickel
Posts: 3
Joined: 21 Nov 2015 14:27

Re: websocket client

Post by KarlNickel »

Thanks for your reply. What kind of push notification do you mean? Is it possible to receive device updates - and if yes, how can I use it? Because this is the only use case I really need.
geirgp
Posts: 42
Joined: 22 Oct 2015 19:16

Re: websocket client

Post by geirgp »

push notifications would be sufficient for my use, no problem using the normal rest api for control. I just want to be notified about device updates as soon as they happen, yet avoid hammering the server with GET requests..
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: websocket client

Post by pofs »

Just connect to ws://razberry-ip:8083 from client-side js, and you'll receive everything pushed with ws.push() call from server-side js (ws is a global instance of WebServer object, which serves 8083 port).
KarlNickel
Posts: 3
Joined: 21 Nov 2015 14:27

Re: websocket client

Post by KarlNickel »

I didn't looked very deep inside the code of the home automation part of Z-Way on GitHub. But I guess have to code a server side module which listens to any kind of update and makes a ws.push(), right?
Post Reply