Z-Way to MQTT

Discussions about RaZberry - Z-Wave board for Raspberry computer
cblomart
Posts: 2
Joined: 03 Apr 2014 17:26

Z-Way to MQTT

Post by cblomart »

Hello all the z-wave.me community.

I was not satifsied with domoticz or openhab... and realy like the Z-Way interface to manage the Razberry.
Still i would like to interface with the may things in my house (Bluetooth awareness, Nest, Sonos, ...).

So i deceided to check if a MQTT gateway was possible. Eventually i found project based on nodejs but on my Raspberry... i didn't like it.

I took upon myself to patch up a Gateway to MQTT in "GO" (golang) which compiles to native binary (no interpretor).

You can check the result @ github.com/cblomart/zwaymqtt
[moderator]Added link

Far from perfect but functionning.

This is a bit of a test proof and in an open world: don't hesitate to fork, or ask me the things you feel lacking

Pesronally, next steps are tidies up and refactoring...

Thanks for any feedback.
Stubbs
Posts: 11
Joined: 29 Sep 2015 11:23

Re: Z-Way to MQTT

Post by Stubbs »

How does the z-way server use your gateway? How would I send all notifications to it, for example.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Z-Way to MQTT

Post by pz1 »

Interesting! I've been fiddling with Node-RED to capture mqtt data
Hope the ZWay developers pick that up some time soon to develop it into a generic mqtt protocol interface.
Stubbs
Posts: 11
Joined: 29 Sep 2015 11:23

Re: Z-Way to MQTT

Post by Stubbs »

That's what I'm trying to do too, I've found the z-wave modules for node-red to be less that reliable so I'm looking for an alternative method to get z-wave events into Node Red, this would be a great way to do it.
past
Posts: 32
Joined: 11 Sep 2013 22:54

Re: Z-Way to MQTT

Post by past »

Hi!
I have made some node-red flows to poll z-way-server status

Code: Select all

[  
   {  
      "id":"48fb8db.fb70474",
      "type":"mqtt-broker",
      "z":"",
      "broker":"localhost",
      "port":"8883",
      "clientid":"",
      "usetls":true,
      "verifyservercert":true,
      "compatmode":false,
      "keepalive":"15",
      "cleansession":true,
      "willTopic":"",
      "willQos":"0",
      "willRetain":null,
      "willPayload":"",
      "birthTopic":"",
      "birthQos":"0",
      "birthRetain":null,
      "birthPayload":""
   },
   {  
      "id":"d6697fb5.29968",
      "type":"inject",
      "z":"6de5ee.ff921a1",
      "name":"Every 2 s",
      "topic":"",
      "payload":"",
      "payloadType":"none",
      "repeat":"2",
      "crontab":"",
      "once":false,
      "x":84.33333587646484,
      "y":169.88890075683594,
      "wires":[  
         [  
            "16bb6a27.e94496",
            "eb361256.14c9f"
         ]
      ]
   },
   {  
      "id":"16bb6a27.e94496",
      "type":"function",
      "z":"6de5ee.ff921a1",
      "name":"Get devices updates",
      "func":"msg.url = context.global.zway.devicesUrl;\n\nif(context.global.zway.updateTime) {\n    msg.url += '?since=' + context.global.zway.updateTime;\n}\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":281.3333435058594,
      "y":169.55557250976562,
      "wires":[  
         [  
            "ab2172e4.54de9"
         ]
      ]
   },
   {  
      "id":"ab2172e4.54de9",
      "type":"http request",
      "z":"6de5ee.ff921a1",
      "name":"devices",
      "method":"GET",
      "ret":"obj",
      "url":"",
      "x":463.1111145019531,
      "y":172.33334350585938,
      "wires":[  
         [  
            "7138cb76.8ec734",
            "b1ef1fcd.4e10e",
            "6414dacd.9beb24",
            "a359d340.5ca63"
         ]
      ]
   },
   {  
      "id":"b1ef1fcd.4e10e",
      "type":"function",
      "z":"6de5ee.ff921a1",
      "name":"MQTT publish",
      "func":"var MQTTMsg = {};\n\nmsg.payload.data.devices.forEach(function(device) {\n    MQTTMsg.topic = 'z-way/events/' + device.deviceType + '/' + device.id;\n    MQTTMsg.payload = device.metrics;\n    MQTTMsg.payload.event = true;\n    node.send(MQTTMsg);\n});\n",
      "outputs":1,
      "noerr":0,
      "x":709,
      "y":172,
      "wires":[  
         [  
            "e68ce19e.19732"
         ]
      ]
   },
   {  
      "id":"e68ce19e.19732",
      "type":"mqtt out",
      "z":"6de5ee.ff921a1",
      "name":"",
      "topic":"",
      "qos":"",
      "retain":"true",
      "broker":"48fb8db.fb70474",
      "x":891,
      "y":171,
      "wires":[  

      ]
   },
   {  
      "id":"28f12d43.d70ed2",
      "type":"inject",
      "z":"6de5ee.ff921a1",
      "name":"init",
      "topic":"",
      "payload":"",
      "payloadType":"none",
      "repeat":"",
      "crontab":"",
      "once":true,
      "x":73,
      "y":114,
      "wires":[  
         [  
            "afcdb4f8.503248"
         ]
      ]
   },
   {  
      "id":"afcdb4f8.503248",
      "type":"function",
      "z":"6de5ee.ff921a1",
      "name":"context.global.z-way",
      "func":"context.global.zway = { \n    devicesUrl :  'http://localhost:8083/ZAutomation/api/v1/devices',\n    notificationsUrl :  'http://localhost:8083/ZAutomation/api/v1/notifications'\n    \n};\n",
      "outputs":"0",
      "noerr":0,
      "x":291,
      "y":109,
      "wires":[  

      ]
   }
]
luxus
Posts: 12
Joined: 20 Sep 2015 11:34

Re: Z-Way to MQTT

Post by luxus »

@cblomart looks perfect for what i need..
i use cloudmqtt.com for mqtt, is there a way to add username and password to the server?
lademeister
Posts: 24
Joined: 29 Mar 2016 13:58

Re: Z-Way to MQTT

Post by lademeister »

has anyone already done something like an ESP-8266 with mqtt and DHT-22 temperature/humidity sensor and using mqtt?
I am just starting that project but right now i only managed to do it with http code device (to be exact I am testing and right now I have a ESP8266 with an relay and I am able to switch it as binary switch in z-way and my iphone app, including feedback about switch status).
I will add DHT22 temp/hum sensor soon.
But I'd like to do it with MQTT protocol.
I have the mqtt broker running on raspberry (its name is mosquitto) and I am pretty sure that I can do the software for ESP8266 wifi chip so that is uses mqtt,

...but how the heck do I import received messages into z-way?
my workaround idea is to write a shell skript that writes mqtt logfile to a ramdrive, another skript which I call from z-way via a code device will search that file for e.g. temperature readings and extract that string and give it back to that "sensor multilevel"-code device as value.
this will work but means a lot of fiddling around with parameters in shell skripts.

I've found this:
https://www.npmjs.com/package/mqtt-zway
but i don't wand to switch z-wave-devices via mqtt protocol, but i want to get sensor values INTO z-way-server "virtual temp sensor" cenerated by code device app using mqtt...


So is there anyone who has a deeper understanding of how to create a virtual sensor which can be filled with values via z-way-API?

I've read a lot but still don't get it how to do this.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Z-Way to MQTT

Post by pz1 »

lademeister wrote:But I'd like to do it with MQTT protocol.
What is the advantage over using http, which seems to be working for you?
lademeister
Posts: 24
Joined: 29 Mar 2016 13:58

Re: Z-Way to MQTT

Post by lademeister »

http causes quite a lot of traffic and also uses more memory on the ESP-8266.
Especially when I'm planning to have some more of those neat ESP chips around my house sending sensor data or controlling RGB stripes both advantages would help a lot...
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Z-Way to MQTT

Post by pz1 »

Fair enough.
As a matter of fact, I just noticed a new MQTT module in the App-store. Have a look at http://developer.z-wave.me/?uri=public#/web/apps
Post Reply