Connecting Plugwise-2-py via MQTT to Domoticz

Moderator: leecollings

dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

Hi all,

I have succesfully installed Plugwise-2-py on my raspberry with a lot of help from Pepijn and SevenW over here. The next step would be to show these devices in domoticz via MQTT. (or another way of course.) Does anybody have some experience with this?

Thanks in advance!
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

dorenberg wrote:Hi all,

I have succesfully installed Plugwise-2-py on my raspberry with a lot of help from Pepijn and SevenW over here. The next step would be to show these devices in domoticz via MQTT. (or another way of course.) Does anybody have some experience with this?

Thanks in advance!
Did you install this on the same rpi as your domoticz is running?
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

yes I did. USB plugwise stick in de rpi and it works! I have no clue how to connect these 2 programs.
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

dorenberg wrote:yes I did. USB plugwise stick in de rpi and it works! I have no clue how to connect these 2 programs.
I will also try this. Is there a wiki or did you follow the github wiki?
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

just the wiki on github and some extra help from SevenW because there was something wrong with permissions and trouble with MQTT configuration.
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

This is for the Plugwise Stretch 2.0 or Smile P1. Not for the Stick of plugwise.
RayAmsterdam
Posts: 115
Joined: Sunday 11 January 2015 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by RayAmsterdam »

dorenberg wrote:This is for the Plugwise Stretch 2.0 or Smile P1. Not for the Stick of plugwise.
No, it's not. Only the later posts describe the Stretch 2.0. The previous posts describe the Smile P1 and Stick. I use it with the Stick (removed from the Stretch).
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

I will have a go with is. I saw that recently but now I would like to do this via Plugwise-2-py.
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

dorenberg wrote:just the wiki on github and some extra help from SevenW because there was something wrong with permissions and trouble with MQTT configuration.
When I'm doing "sudo pip install' I got the message: you must give at least give one requirement to install.
Is that the same fault?
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

sudo pip install .

Dont forget the .
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

dorenberg wrote:sudo pip install .

Dont forget the .
I overlooked . :D Now to the configuration.
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

let me know if you succeed in installing and the connection via MQTT to Domoticz.

As this is not so clear to me how this will work.



I have some assumptions. MQTT must be enabled in domoticz of course. MQTT should header with Domoticz/in with svalue nvalue and idx in the MQTT data.
The plugwise-2.py script should be altered to at the qpub.put( point with the proper MQTT values.

If somebody knows exactly what to do, help is most appreciated.
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

I will do that but it will thake some time. I will contact you if I 'm ready to test.
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
pepijn
Posts: 251
Joined: Friday 12 July 2013 13:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by pepijn »

I used Node Red to translate the messages from Plugwise-2-py on MQTT to Domoticz

In Node-Red it looks like this.
Schermafbeelding 2015-07-28 om 20.48.15.png
Schermafbeelding 2015-07-28 om 20.48.15.png (24.65 KiB) Viewed 11405 times
You can try importing my flow as a starting point.

Code: Select all

[{"id":"44cdab58.bb3254","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"aa2e3003.55d1d","type":"mqtt in","name":"Plugwise","topic":"plugwise2py/state/energy/#","broker":"44cdab58.bb3254","x":79,"y":43,"z":"5edc3f92.a123c","wires":[["313d8fcf.cec27"]]},{"id":"313d8fcf.cec27","type":"function","name":"Plugwise 2 Domoticz","func":"//\n// Plugwise JSON MQTT bericht vertalen naar Domoticz HTTP\n//\nnode.log (\"Converteer Plugwise MQTT bericht naar Domoticz HTTP\");\nvar pwJSON = JSON.parse(msg.payload);\n\n///json.htm?type=command&param=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\n//var msg.url = 'http://127.0.0.1/json.htm?mac='+pwJSON.mac+'&power='+pwJSON.power+'&energy='+pwJSON.energy\nmsg.url = \"http://127.0.0.1/json.htm?type=command&param=udevice&hid=2&did=\"+pwJSON.mac.substr(10,6)+\"&dunit=1&dtype=248&dsubtype=1&nvalue=&svalue=\"+pwJSON.power+\";\"+pwJSON.energy;\n\nreturn msg;","outputs":1,"x":243,"y":91,"z":"5edc3f92.a123c","wires":[["cb9166da.346e98"]]},{"id":"2b0700e4.d4f9","type":"debug","name":"Debug","active":false,"console":"true","complete":"true","x":627,"y":89,"z":"5edc3f92.a123c","wires":[]},{"id":"cb9166da.346e98","type":"http request","name":"Domoticz","method":"GET","ret":"txt","url":"","x":447,"y":90,"z":"5edc3f92.a123c","wires":[["2b0700e4.d4f9"]]}]
If the flow works, your Plugwise devices should show up on your Devices tab.

Right now it uses HTTP/JSON posts to publish data to Domoticz, I will change this to MQTT but this is some work in progress.
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

THanks for your help. I have managed to install nodejs and node-red and started it. Importing the flow connects to the plugwise instance but debugging shows nothing. Listening to the mqtt broker I get Plugwise and Domoticz/out messages.

I think it is in the settings. Added the port to the json url. When formatting the Domoticz in node-red, I am unsure what to choose. JSON parsing error when I choose a JSON parsed object.
Last edited by dorenberg on Tuesday 28 July 2015 22:44, edited 1 time in total.
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

I have send you a pm for help.
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
dorenberg
Posts: 111
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by dorenberg »

Everything works!! Not yet via MQTT but via the solution above. This is the code for Node-red. Slightly adapted. But all circles pop up in the unused list and can be added. I have set the time interval to 10 minutes which is sufficient for me.

Code: Select all

[{"id":"7d9fa7de.826058","type":"function","name":"Plugwise 2 Domoticz","func":"//\n// Plugwise JSON MQTT bericht vertalen naar Domoticz HTTP\n//\nnode.log (\"Converteer Plugwise MQTT bericht naar Domoticz HTTP\");\nvar pwJSON = JSON.parse(msg.payload);\n\n///json.htm?type=command&param=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\n//var msg.url = 'http://127.0.0.1:8080/json.htm?mac='+pwJSON.mac+'&power='+pwJSON.power+'&energy='+pwJSON.energy\nmsg.url = \"http://127.0.0.1:8080/json.htm?type=command&param=udevice&hid=2&did=\"+pwJSON.mac.substr(10,6)+\"&dunit=1&dtype=248&dsubtype=1&nvalue=&svalue=\"+pwJSON.power+\";\"+pwJSON.energy;\n\nreturn msg;","outputs":1,"noerr":0,"x":824,"y":187,"z":"e1aec63.f1e5138","wires":[["32191e24.cde6e2"]]}]
Last edited by dorenberg on Thursday 31 December 2015 11:51, edited 1 time in total.
rron
Posts: 247
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by rron »

dorenberg wrote:Everything works!! Not yet via MQTT but via the solution above. This is the code for Node-red. Slightly adapted. But all circles pop up in the unused list and can be added. I have set the time interval to 10 minutes which is sufficient for me.

Code: Select all

[{"id":"7d9fa7de.826058","type":"function","name":"Plugwise 2 Domoticz","func":"//\n// Plugwise JSON MQTT bericht vertalen naar Domoticz HTTP\n//\nnode.log (\"Converteer Plugwise MQTT bericht naar Domoticz HTTP\");\nvar pwJSON = JSON.parse(msg.payload);\n\n///json.htm?type=command&param=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\n//var msg.url = 'http://127.0.0.1:8080/json.htm?mac='+pwJSON.mac+'&power='+pwJSON.power+'&energy='+pwJSON.energy\nmsg.url = \"http://127.0.0.1:8080/json.htm?type=command&param=udevice&hid=2&did=\"+pwJSON.mac.substr(10,6)+\"&dunit=1&dtype=248&dsubtype=1&nvalue=&svalue=\"+pwJSON.power+\";\"+pwJSON.energy;\n\nreturn msg;","outputs":1,"noerr":0,"x":824,"y":187,"z":"e1aec63.f1e5138","wires":[["32191e24.cde6e2"]]}]
Did you succeed to connect it to domoticz with MQTT or did you leave it this way?
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
SevenW
Posts: 25
Joined: Sunday 16 August 2015 22:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Connecting Plugwise-2-py via MQTT to Domoticz

Post by SevenW »

dorenberg wrote:Everything works!! Not yet via MQTT but via the solution above. This is the code for Node-red. Slightly adapted. But all circles pop up in the unused list and can be added. I have set the time interval to 10 minutes which is sufficient for me.
Do the circles automatically show up in the "unused list" or do you need to add some hardware and virtual devices first. I am trying to figure out how this works.

Currently I am sending MQTT topics directly from Plugwise-2.py to domoticz/in, but I have to manually create virtual hardware and virtual devices. I do not seem to have control over the "idx", so I cannot use part of the MAC number as index.

Maybe the Node Red way is just superioir over direct MQTT. Still learning here.

SevenW
pepijn
Posts: 251
Joined: Friday 12 July 2013 13:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Connecting Plugwise-2-py via MQTT to Domoticz

Post by pepijn »

When i created the script this used to be the way to create devices. Now you can just create devices from the gui. The 'RAW device' way is not supported in the MQTT domoticz/in json.

@gizmocuz: could you confirm this is not supported in MQTT, could support be added?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest