Page 1 of 2

How to use JavaScript sockets?

Posted: 20 Jul 2015 21:39
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.

Re: How to use JavaScript sockets?

Posted: 20 Jul 2015 21:55
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?

Re: How to use JavaScript sockets?

Posted: 20 Jul 2015 22:01
by ArthurMaroulier
Hello pz1, for now I have installed one FGS-221.

Re: How to use JavaScript sockets?

Posted: 21 Jul 2015 08:41
by pz1
This module only communicates over the Z-Wave protocol. So please explain why/what you intend to use sockets for?

Re: How to use JavaScript sockets?

Posted: 21 Jul 2015 09:19
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.

Re: How to use JavaScript sockets?

Posted: 21 Jul 2015 09:35
by pz1
What do you use as a client?

Re: How to use JavaScript sockets?

Posted: 21 Jul 2015 09:40
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.

Re: How to use JavaScript sockets?

Posted: 21 Jul 2015 10:27
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.

Re: How to use JavaScript sockets?

Posted: 26 Jul 2015 01:05
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!

Re: How to use JavaScript sockets?

Posted: 26 Jul 2015 01:23
by ArthurMaroulier
Hi PoltoS, thanks for the reply.

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