Websocket Support in 2.0
-
- Posts: 11
- Joined: 11 Sep 2014 18:53
Websocket Support in 2.0
I see in the 2.0 release notes that websocket push support is there. Can you explain how one would use this? Thanks!
Re: Websocket Support in 2.0
Well, it is pretty simple. On a low level,
will send a JSON-encoded object to all connected websocket clients. Then client may eval() received string and use it.
The shortcoming is, there should be a way for client to identify if the received object is intended for this particular client.
EDIT: In the future there would be an event type to push:
Client may specify a set of event types to listen for (by sending a comma-separated list of types into a socket), so messages will be delivered only to matching clients (in form of {"type": type, "data": obj}). Not specifying types filter will result in receiving all events.
Code: Select all
ws.push(obj);
The shortcoming is, there should be a way for client to identify if the received object is intended for this particular client.
EDIT: In the future there would be an event type to push:
Code: Select all
ws.push(type, obj);
-
- Posts: 11
- Joined: 11 Sep 2014 18:53
Re: Websocket Support in 2.0
Right now I am polling the ZWaveAPI every few seconds for status and would like to replace this with a push function over a websocket. Unfortunately this is the only API I am familiar with, so I'm not sure where your example would live. Would the ws.push(obj) live inside a automation module? How would clients make a websocket connection, what URL would they need to request? Thanks again!
Re: Websocket Support in 2.0
What client software are you using?
Since 29-12-2016 I am no longer a moderator for this forum
Re: Websocket Support in 2.0
well, i am probably in similar position as digitaldan. My Home automation system is a java application which is based on regular ZWaveAPI/Data/{timestamp} requests.
This works very well for me and the whole application is for about 20 devices very stable and reliable.
But I am also wondering how i would achieve to a udp listener discussed above in a java application.
This works very well for me and the whole application is for about 20 devices very stable and reliable.
But I am also wondering how i would achieve to a udp listener discussed above in a java application.
Z-Way 2.0.0-final on Raspberry Pi
Re: Websocket Support in 2.0
Just to clarify, WebSockets are not UDP.hpd wrote:But I am also wondering how i would achieve to a udp listener discussed above in a java application.
If you actually need UDP, you'd better refer to @pz1 posts about UDP and OpenRemote. I'd rather write a native UDP sender, but calling netcat in a shell script also works fine.
For WebSockets you'll need a client-side support (like modern browser, or a java library).
But they're both just transports. Anyway you'll need to write some JS to catch events you need, and send them over preferred transport.
Re: Websocket Support in 2.0
I am about to start rewriting the instructions here in the Recipes forum, and on the OpenRemote site, to make it work for version v2.0.0-rc23 and higher.pofs wrote:If you actually need UDP, you'd better refer to @pz1 posts about UDP and OpenRemote. I'd rather write a native UDP sender, but calling netcat in a shell script also works fine.
update 17:00: Recipe is up to date now
@pofs: A native UDP sender would indeed be nice. Well if you get bored sometime...
Since 29-12-2016 I am no longer a moderator for this forum
-
- Posts: 11
- Joined: 11 Sep 2014 18:53
Re: Websocket Support in 2.0
My system is also Java, so I have a few choices for a websocket client. I was grepping through the automation code but can't find any reference to a websocket class. I would be happy to post what I get working in the recipes section. I just need a little stronger nudge in the right direction
-
- Posts: 11
- Joined: 11 Sep 2014 18:53
Re: Websocket Support in 2.0
BTW, I had not seen the openremote UDP solution, that actually may be better for my needs, so I may pursue that instead. Thanks.
Re: Websocket Support in 2.0
sorry fro bringing UDP into this thread. I have no special knowledge with Websockets and was not aware of the difference.
Well, there are Websocket clients for Java Apps available. Therefore I think it should be possible to listen to the Zway Websocket Server. But I think you have to know some implementation Details of the Server to do so. Are these details known?
Well, there are Websocket clients for Java Apps available. Therefore I think it should be possible to listen to the Zway Websocket Server. But I think you have to know some implementation Details of the Server to do so. Are these details known?
Z-Way 2.0.0-final on Raspberry Pi