Connecting Plugwise-2-py via MQTT to Domoticz

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

Connecting Plugwise-2-py via MQTT to Domoticz

Postby dorenberg » Sunday 26 July 2015 22:41

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: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Monday 27 July 2015 7:52

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

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Monday 27 July 2015 10:53

yes I did. USB plugwise stick in de rpi and it works! I have no clue how to connect these 2 programs.

rron
Posts: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Monday 27 July 2015 14:03

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

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Monday 27 July 2015 16:41

just the wiki on github and some extra help from SevenW because there was something wrong with permissions and trouble with MQTT configuration.

RayAmsterdam
Posts: 136
Joined: Sunday 11 January 2015 17:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Postby RayAmsterdam » Monday 27 July 2015 18:51

This thread has a working solution.

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Monday 27 July 2015 19:16

This is for the Plugwise Stretch 2.0 or Smile P1. Not for the Stick of plugwise.

RayAmsterdam
Posts: 136
Joined: Sunday 11 January 2015 17:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Postby RayAmsterdam » Monday 27 July 2015 19:57

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: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Monday 27 July 2015 20:03

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: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Monday 27 July 2015 20:12

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

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Monday 27 July 2015 20:15

sudo pip install .

Dont forget the .

rron
Posts: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Monday 27 July 2015 20:21

dorenberg wrote:sudo pip install .

Dont forget the .

I overlooked . :D Now to the configuration.
Rpi, RFXcom, klikaan klikuit switch,thermosmart

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Tuesday 28 July 2015 10:25

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: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Tuesday 28 July 2015 10:41

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

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

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

Postby pepijn » Tuesday 28 July 2015 20:57

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 2930 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: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Tuesday 28 July 2015 22:31

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: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Tuesday 28 July 2015 22:34

I have send you a pm for help.
Rpi, RFXcom, klikaan klikuit switch,thermosmart

dorenberg
Posts: 62
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi
Domoticz version: 3.4984
Location: Veghel, The Netherlands
Contact:

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

Postby dorenberg » Saturday 01 August 2015 22:46

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 12:51, edited 1 time in total.

rron
Posts: 117
Joined: Sunday 30 March 2014 15:24
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Waterland
Contact:

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

Postby rron » Sunday 16 August 2015 15:17

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

SevenW
Posts: 27
Joined: Sunday 16 August 2015 22:19
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Postby SevenW » Monday 17 August 2015 18:15

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


Return to “Meters”

Who is online

Users browsing this forum: No registered users and 1 guest