How to use JavaScript sockets?

Discussions about RaZberry - Z-Wave board for Raspberry computer
ArthurMaroulier
Posts: 5
Joined: 20 Jul 2015 21:21

How to use JavaScript sockets?

Post by ArthurMaroulier »

Hello every one, I use the great RaZberry module and I try to use JavaScript sockets to control my Fibaro Module. I saw that the feature is available since v2.
I wanted to retrieve live updates of the state of the modules in my app.

I found on the forum the two main topics on sockets:
viewtopic.php?f=3422&t=20881
viewtopic.php?f=3424&t=20849
and this one viewtopic.php?f=3422&t=20816

But It's still unclear on how to setup socket and use it on both server and client side.
And beside, the up to date dev documentation from the github repo https://github.com/Z-Wave-Me/Z-Way-Manual is very light.

I'm a little bit familiar with socket.io and meteor, but here I'm stuck.

I don't think that I'm the only one that try to do this.
Is anybody can help me to setup everything? Is there a skeleton of code for server and client side anywere?

Thank you for your help.

[EDIT]
I think I didn't express myself correctly: I want to setup and use a websocket with js on server and client side (in a web app) to have live states of z-wave modules from apis through the websocket. And make apis calls to change state of z-wave modules through the websocket.
Last edited by ArthurMaroulier on 21 Jul 2015 13:39, edited 1 time in total.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: How to use JavaScript sockets?

Post by pz1 »

ArthurMaroulier wrote:Hello every one, I use the great RaZberry module and I try to use JavaScript sockets to control my Fibaro Module.
What/Which Fibaro module?
ArthurMaroulier
Posts: 5
Joined: 20 Jul 2015 21:21

Re: How to use JavaScript sockets?

Post by ArthurMaroulier »

Hello pz1, for now I have installed one FGS-221.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: How to use JavaScript sockets?

Post by pz1 »

This module only communicates over the Z-Wave protocol. So please explain why/what you intend to use sockets for?
ArthurMaroulier
Posts: 5
Joined: 20 Jul 2015 21:21

Re: How to use JavaScript sockets?

Post by ArthurMaroulier »

To access the APIs to query the z-way server about my modules. Somethining like http://server:8083/ZWaveAPI/Run/devices ... c.Set(255)
or
http://server:8083/JS/Run/zway.devices[2].Basic

But through socket to make it real time.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: How to use JavaScript sockets?

Post by pz1 »

What do you use as a client?
ArthurMaroulier
Posts: 5
Joined: 20 Jul 2015 21:21

Re: How to use JavaScript sockets?

Post by ArthurMaroulier »

A simple custom mobile web app I made with Ionic framework (angularJS) to use with any device in the house network.
Really simple to use for the family.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: How to use JavaScript sockets?

Post by pz1 »

I only know a little about sockets, but I do understand that Z-Way also supports websockets. There are a couple of posts about that.
I don't know sockets work in mobile applications. The UDP send functions I described work between always on/connected devices.
I am afraid I have to leave the answer to more technical oriented people.
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: How to use JavaScript sockets?

Post by PoltoS »

Z-Way supports three types of connections:
1) classical HTTP connection (TCP socket to 8083 port)
2) websockets (again, TCP, but with special websocket extension of HTTP)
3) TCP/UPD sockets - raw mode to control anything via TCP/IP protocol. Even multicast is here!
ArthurMaroulier
Posts: 5
Joined: 20 Jul 2015 21:21

Re: How to use JavaScript sockets?

Post by ArthurMaroulier »

Hi PoltoS, thanks for the reply.

So, for case 2, how to setup and use websocket for Z-Way.
Post Reply