Plugwise Plugs component

I hope I can get some interest to create a component for Plugwise plugs.

There is already a GitHub with a python code to run it and it already should work with Home Assistant. I would like to use it in my HASS.io setup so I hope somebody could create a component with the code from the GitHub page: GitHub - SevenW/Plugwise-2-py: A version 2.0 of a plugwise python interface and controller


@brefra created a custom component which can be (early) tested :partying_face:
You can download the files here.

To use this you only have to:
1. Remove older versions you maybe have installed
2. Download plugwise_stick.zip (with highest version number)
3. Unpack the zip-file in custom_components/plugwise_stick
4. Restart HA
5. Add ‘plugwise stick’ through integrations page
6. Configure the integration by selecting the correct USB stick


@befra has the custom component now available via HACS.

To use this:
1. In HACS search for ‘Plugwise USB-Stick’
2. Add ‘Plugwise USB-Stick’ through the integrations page
3. Configure the integration by selecting the correct USB stick

The repository is GitHub - brefra/home-assistant-plugwise-stick: Plugwise USB-stick integration to support Circle+, Circle and Stealth devices


There is now a combined version of different Plugwise hardware.

To be able to use the USB Stick with Circles variant you’ve to manually register this version in HACS.
Then you are going to use the development (beta) version of the Plugwise Integration as the native Plugwise integration does not support the legacy stick & plugs (yet).

GitHub - plugwise/plugwise-beta: Custom-component / development version of the Plugwise Home Assistant platform


Per April '23 the branches splitted from each other again. For USB/Stick use there is a new repository:

So to be able to use the USB Stick with Circles variant you’ve to manually register this version in HACS.
Then you are going to use the development (beta) version of the Plugwise USB/Stick Integration as the native Plugwise integration does not support the legacy stick & plugs (yet).


More information overhere:

Versions of the beta custom_component above v0.34.10 are not supporting USB anymore.
From version v0.40.1 and up this repository can’t be used anymore for the USB/Stick functionality.

I came across this post looking for a way to hook up my Plugwise Circle to Home Assistant. Later I found this custom component and made that work:

Ive had mixed results with Plugwise-2-py, it crashed frequently making it totally unreliable. In the holiday period I’ve written a small script to communicate with the Plugwise Source webserver. Once modules are added to the Plugwise Source application, they are automatically added to HA with MQTT autodiscovery.

It’s been working perfectly for a couple of days, but needs some polishing before I publish it to GitHub. This does require that you have a Windows system up and running for the Plugwise software though.

Dear Devastator, have you already circles working on Home Assistant (Hassio) yet?

Hi Bob, Been running it for more than a month now without any issues. Currently working on finishing another HA project first. Will post this one afterwards.

Hi Devastator, I am also patiently but eagerly awaiting your project to come online, thanks in advance!

Hi Devastator, I am also patiently but eagerly awaiting your project to come online, thanks in advance!

I’ve kind of the same demand too. So I started to rewrite the mentioned plugwise lib into an required async version. I’ve the basics structure on github at this branch almost ready. Still a lot of fine tuning, code cleanup and testing to be done…
No promises yet, but a native Home Assistant integration look feasible somewhere in the near future :grinning:

1 Like

Sorry, I now see that this topic is about the Circle plugs, not about the new Plugs, so never mind.

That’s sweet and just in time :). My Plugwise Stretch burned out the other day, so I could use the Pi to read all my circles with this?

Gave it a go, but its not quite clear how to initialize the stick. The supplied python code errored out for me:

admin@Pi4:~/git/python-plugwise-async/example $ sudo python3 scan.py
Traceback (most recent call last):
  File "scan.py", line 4, in <module>
    plugwise.scan(discovery_finished)
NameError: name 'discovery_finished' is not defined

Trying to run a scan (after changing com5 to /dev/ttyUSB0) with the example code seems to get stuck at the connecting stage:

admin@Pi4:~/git/python-plugwise-async/example $ sudo python3 example.py
start connecting to stick

PS I got everything running with what cyberjunky made @ https://github.com/cyberjunky/home-assistant-custom-components

Hi @brefra, awesome development!
Since it is needed to python setup.py install I assume this doesn’t run on hass.io?

@Devastator, is it possible to publish the code as-is? Maybe the community can “polish” it?

@JeeCee, It will run on hass.io

I have made good progress to write a native “plugwise stick” integration which:

  • has new config flow to easy setup
  • only the connection string to the stick is required
  • discovers all linked nodes automatically
  • an optimal update frequency is automatically setup
  • shows the zigbee network details

Just have to do some more testing…but it’s getting close to summit to homeassistant code base.
A sneak preview:

image

image

image

image

3 Likes

Looks great! Can’t wait until its published!
Can you please give me a pointer on how to install the version you referred to earlier, I can’t use python setup.py. Thanks!

Readme was wrong, I have updated now. I’ve published the library to pip so you can install the lib it using command:

pip install python-plugwise

I still have to do some bug fixing and code cleanup for the integration part at HA. As soon as it’s stable enough I’ll try to publish it as custom component so you can give it a try. Final goal is to get it as a native integration as part of HA.

2 Likes

Thanks, but also pip is not found.
Are you using hass.io or hassbian?

Wonderful work, can’t wait to try it out! Please keep us posted and if you need any testers, let us know.

People who want to do some early (beta) testing => Copy the contents of this zip file to your custom_components folder of your HA instance.

1 Like

Oeh play-time :slight_smile:

Almost worked out of the box/zip. At first I wondered what ‘Connection string’ could refer to during integration setup. Only variable to be known to me here was the serial port, so indeed it needed /dev/ttyUSB0 here. I suggest just asking for ‘port’ or ‘serial port’ and maybe pre-fill the field with /dev/ttyUSB0, which would be most common, if possible.

Had to remove previous plugwise references from configuration.yaml, probably to make the serial port available for this integration. All I got was a connection failed at first.

Some initial data seems to have come in, it even found my Stealth (which is not much more than a Circle in a different enclosure). For most plugs I only have 1 or 2 initial data points in the last 20 minutes, which suggests it has trouble retrieving data I guess. In home-assistant.log I see many warnings, for example:

2020-03-28 15:45:23 WARNING (send_messages_deamon) [plugwise] Resend NodePingRequest for 000D6F00004EEB0A (b'0196') because stick did not acknowledged send request
2020-03-28 15:45:24 WARNING (send_messages_deamon) [plugwise] Resend CirclePowerUsageRequest for 000D6F00004EEB0A (b'0196') because stick did not acknowledged send request

this happened for all Circles, also Circle+.

Figured I’d set the logging to debug, restart HA and try again. This time all seemed to work and am still getting data points for most devices. Will test some more and report back later.

2 Likes

It looks like it only works for a few minutes after starting HA and initializing the Stick. Within those minutes I see data being gathered from the stick without issue for all my Circles and Stealths like this:

2020-03-28 16:12:59 DEBUG (MainThread) [plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-03-28 16:12:59 DEBUG (MainThread) [plugwise] start serial port
2020-03-28 16:12:59 DEBUG (MainThread) [plugwise] Serial port initialized
2020-03-28 16:12:59 DEBUG (MainThread) [plugwise] Send init request to Plugwise Zigbee stick
2020-03-28 16:12:59 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Feed data: b'\n'
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Feed data: b'\x05\x05\x03\x030000099900'
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Parse data: b'\n\x05\x05\x03\x030000099900' 
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\n\x05\x05\x03\x030000099900')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Valid message header found at index 1
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000099900')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] No valid message footer found yet
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Feed data: b'C'
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Parse data: b'\x05\x05\x03\x030000099900C' 
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x030000099900C')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Valid message header found at index 0
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000099900C')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] No valid message footer found yet
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Feed data: b'19FEE\r\n\x05\x05\x03\x0300110999000D6F000258842E0101220D6F0002588DB0DD22FF01C9\r\n\x83'
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Parse data: b'\x05\x05\x03\x030000099900C19FEE\r\n\x05\x05\x03\x0300110999000D6F000258842E0101220D6F0002588DB0DD22FF01C9\r\n\x83' 
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x030000099900C19FEE\r\n\x05\x05\x03\x0300110999000D6F000258842E0101220D6F0002588DB0DD22FF01C9\r\n\x83')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Valid message header found at index 0
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000099900C19FEE\r\n\x05\x05\x03\x0300110999000D6F000258842E0101220D6F0002588DB0DD22FF01C9\r\n\x83')
2020-03-28 16:12:59 DEBUG (Thread-2) [plugwise] Valid message footer found at index 20

But after some happy data gathering, it all grinds to a halt here:

2020-03-28 16:15:22 DEBUG (send_messages_deamon) [plugwise] send CirclePowerUsageRequest to 000D6F000076CAB4 using seq_id b'0B28'
2020-03-28 16:15:22 DEBUG (write_packets_process) [plugwise] Sending CirclePowerUsageRequest to plugwise stick (b'\x05\x05\x03\x030012000D6F000076CAB4EE24\r\n')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Feed data: b'\x05'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Feed data: b'\x05\x03\x0300000B2800C13953\r\n\x83'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Parse data: b'\x05\x05\x03\x0300000B2800C13953\r\n\x83' 
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x0300000B2800C13953\r\n\x83')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Valid message header found at index 0
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300000B2800C13953\r\n\x83')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Valid message footer found at index 20
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Success acknowledge on message request with sequence id b'0B28'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Reset parser : b'000B2800C13953\r\n\x83'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Parse data: b'000B2800C13953\r\n\x83' 
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'000B2800C13953\r\n\x83')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] No valid message header found yet
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Feed data: b'\x05'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Parse data: b'000B2800C13953\r\n\x83\x05' 
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'000B2800C13953\r\n\x83\x05')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] No valid message header found yet
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Feed data: b'\x05\x03\x0300130B28000D6F000076CAB40000FFFF00000000FFFFFFBA000B166C\r\n'
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Parse data: b'000B2800C13953\r\n\x83\x05\x05\x03\x0300130B28000D6F000076CAB40000FFFF00000000FFFFFFBA000B166C\r\n' 
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'000B2800C13953\r\n\x83\x05\x05\x03\x0300130B28000D6F000076CAB40000FFFF00000000FFFFFFBA000B166C\r\n')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Valid message header found at index 17
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300130B28000D6F000076CAB40000FFFF00000000FFFFFFBA000B166C\r\n')
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Valid message footer found at index 60
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] New CirclePowerUsageResponse message with seq id b'0B28' for 000D6F000076CAB4
2020-03-28 16:15:22 DEBUG (Thread-2) [plugwise] Last update 2020-03-28 16:15:22.199340 of node 000D6F000076CAB4, last message 2020-03-28 16:15:22.363516
2020-03-28 16:15:22 DEBUG (send_messages_deamon) [plugwise] send NodePingRequest to 000D6F00004EEB0A using seq_id b'0B29'
2020-03-28 16:15:22 DEBUG (write_packets_process) [plugwise] Sending NodePingRequest to plugwise stick (b'\x05\x05\x03\x03000D000D6F00004EEB0A252A\r\n')
2020-03-28 16:15:23 WARNING (send_messages_deamon) [plugwise] Resend NodePingRequest for 000D6F00004EEB0A (b'0B29') because stick did not acknowledged send request
2020-03-28 16:15:23 DEBUG (send_messages_deamon) [plugwise] send CirclePowerUsageRequest to 000D6F00004EEB0A using seq_id b'0B29'
2020-03-28 16:15:23 DEBUG (write_packets_process) [plugwise] Sending CirclePowerUsageRequest to plugwise stick (b'\x05\x05\x03\x030012000D6F00004EEB0AED50\r\n')
2020-03-28 16:15:24 WARNING (send_messages_deamon) [plugwise] Resend CirclePowerUsageRequest for 000D6F00004EEB0A (b'0B29') because stick did not acknowledged send request
2020-03-28 16:15:24 DEBUG (send_messages_deamon) [plugwise] send NodePingRequest to 000D6F000416BA68 using seq_id b'0B29'
2020-03-28 16:15:24 DEBUG (write_packets_process) [plugwise] Sending NodePingRequest to plugwise stick (b'\x05\x05\x03\x03000D000D6F000416BA6819DC\r\n')
2020-03-28 16:15:26 WARNING (send_messages_deamon) [plugwise] Resend NodePingRequest for 000D6F000416BA68 (b'0B29') because stick did not acknowledged send request
2020-03-28 16:15:26 DEBUG (send_messages_deamon) [plugwise] send CirclePowerUsageRequest to 000D6F000416BA68 using seq_id b'0B29'
2020-03-28 16:15:26 DEBUG (write_packets_process) [plugwise] Sending CirclePowerUsageRequest to plugwise stick (b'\x05\x05\x03\x030012000D6F000416BA68D1A6\r\n')
2020-03-28 16:15:27 WARNING (send_messages_deamon) [plugwise] Resend CirclePowerUsageRequest for 000D6F000416BA68 (b'0B29') because stick did not acknowledged send request
2020-03-28 16:15:27 DEBUG (send_messages_deamon) [plugwise] send NodePingRequest to 000D6F000046A0B1 using seq_id b'0B29'
2020-03-28 16:15:27 DEBUG (write_packets_process) [plugwise] Sending NodePingRequest to plugwise stick (b'\x05\x05\x03\x03000D000D6F000046A0B1BA4B\r\n')
2020-03-28 16:15:28 WARNING (send_messages_deamon) [plugwise] Resend NodePingRequest for 000D6F000046A0B1 (b'0B29') because stick did not acknowledged send request
2020-03-28 16:15:28 DEBUG (send_messages_deamon) [plugwise] send CirclePowerUsageRequest to 000D6F000046A0B1 using seq_id b'0B29'
2020-03-28 16:15:28 DEBUG (write_packets_process) [plugwise] Sending CirclePowerUsageRequest to plugwise stick (b'\x05\x05\x03\x030012000D6F000046A0B17231\r\n')
2020-03-28 16:15:29 WARNING (send_messages_deamon) [plugwise] Resend CirclePowerUsageRequest for 000D6F000046A0B1 (b'0B29') because stick did not acknowledged send request

and does not seem to recover until I restart HA again.

EDIT: interesting detail, this was all in a USB2 port on my Pi4. If I try a USB3 port, it never comes this far and stalls on the initialization part.

It looks like the processing of the power use message fails when invalid poweruse is reported back and after that the receiving thread dies.
I tried to quick fix this in release 0.4.

Please update the requirement versie to 0.4 at the manifest.json file inside the custom_component folder like below:

"requirements": ["python-plugwise==0.4"]

1 Like