Plugwise Plugs component

I have tried a few things, different usb port, a few restarts of the server but nothing works. I know for sure I have the right USB stick. This is the error I see in the logs when I attempt to configure it:

Skip message, received 54 bytes of expected 60 bytes

and:

 Uncaught thread exception 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/plugwise/stick.py", line 514, in _receive_timeout_loop
    if self._cb_stick_initialized:
AttributeError: 'stick' object has no attribute '_cb_stick_initialized'

It seems that the first answer to the initialization request from the USB stick is different from what is expected: a message with 54 bytes instead of a message containing 60 bytes. I am curious about the contents of this 54 bytes message.

To investigate this could you collect some debug logging by setting the logging level like below? As it fails at the initialization phase the log will be small.

logger:
  default: warning
  logs:
    custom_components.plugwise_stick: debug
    python-plugwise: debug

The crash (uncaught thread exception) happens while recovering from the unexpected response. I will fix that but it won’t solve your problem as it shouldn’t get to that point.

here is the log:

2020-09-14 20:23:18 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for plugwise_stick which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-09-14 20:23:45 DEBUG (SyncWorker_2) [python-plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-09-14 20:23:45 DEBUG (SyncWorker_2) [python-plugwise] Open serial port /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4003x54-if00-port0
2020-09-14 20:23:45 DEBUG (SyncWorker_2) [python-plugwise] Successfully connected to serial port /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4003x54-if00-port0
2020-09-14 20:23:45 DEBUG (SyncWorker_2) [python-plugwise] Starting threads...
2020-09-14 20:23:45 DEBUG (SyncWorker_2) [python-plugwise] All threads started
2020-09-14 20:23:45 DEBUG (SyncWorker_23) [python-plugwise] Send init request to Plugwise Zigbee stick
2020-09-14 20:23:45 DEBUG (send_messages_thread) [python-plugwise] send StickInitRequest using seq_id b'0000'
2020-09-14 20:23:45 DEBUG (serial_writer_thread) [python-plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Feed data: b'\x05\x05\x03\x030011000D6F00002363C501000D6F00002366A934DAFF5370\r\n\x05\x05\x03\x0300'
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Parse data: b'\x05\x05\x03\x030011000D6F00002363C501000D6F00002366A934DAFF5370\r\n\x05\x05\x03\x0300' 
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x030011000D6F00002363C501000D6F00002366A934DAFF5370\r\n\x05\x05\x03\x0300')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Valid message header found at index 0
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030011000D6F00002363C501000D6F00002366A934DAFF5370\r\n\x05\x05\x03\x0300')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Valid message footer found at index 52
2020-09-14 20:23:45 ERROR (serial_reader_thread) [python-plugwise] Skip message, received 54 bytes of expected 60 bytes
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Reset parser : b'\x05\x05\x03\x0300'
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Parse data: b'\x05\x05\x03\x0300' 
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x0300')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Valid message header found at index 0
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] No valid message footer found yet
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Feed data: b'0000C1AB92\r\n\x83'
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Parse data: b'\x05\x05\x03\x03000000C1AB92\r\n\x83' 
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x03000000C1AB92\r\n\x83')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Valid message header found at index 0
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x03000000C1AB92\r\n\x83')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Valid message footer found at index 16
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Received message b'\x05\x05\x03\x03000000C1AB92\r\n' to small, skip parsing
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Reset parser : b'0000C1AB92\r\n\x83'
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Parse data: b'0000C1AB92\r\n\x83' 
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'0000C1AB92\r\n\x83')
2020-09-14 20:23:45 DEBUG (serial_reader_thread) [python-plugwise] No valid message header found yet
2020-09-14 20:23:50 ERROR (receive_timeout_thread) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/plugwise/stick.py", line 514, in _receive_timeout_loop
    if self._cb_stick_initialized:
AttributeError: 'stick' object has no attribute '_cb_stick_initialized'

I did some investigation to the response message:

0011000D6F00002363C501000D [Zigbee state missing] 6F00002366A934DA [Zigbee ID missing] FF5370

I’m guessing the Zigbee network information is missing, but I’m not 100% sure yet. From some reverse enginering of the plugwise source software I discovered there could be situations some information in this message is optional, but I have not seen this happen in real life before.

To be sure could you let me know some little more information?

  • Does the Circle+ module have ID 934DA ?
  • Is the Circle+ operational (powered) and within reach of the USB-Stick
  • Does the USB-Stick work using the Windows Source software?

Hi, I just noticed this: I have used my oven in the morning and evening, as can be seen in the power usage graph.
However, in the energy used graph the morning usage is not shown.
How can I/we debug this?

Also, how can I retrieve “total power usage to date”?
Thanks for any help!

I’ve been running Plugwise-2-py fro a long time now and i’ve made some small modifications to if for myself.

As home assistant only works with present values, I’ve modified the Plugwse-2-py to push straight to influxdb. So in case home assistant is crashing, or a circle is out of range for some time, the data will be recovered as soon as the connection is back. Maybe we can add something like that to this plugin at a later stage.

But first things first, stability.

I wanted to test this integration. But during testing i found that the polling is not consistent.
Using the Plugwise-2-py -> MQTT -> Influxdb I get consistent pols every 10 (+/-1) seconds:

Using the stick plugin (Homeassistant ->Influxdb) i get mixed times:

hi there,

My circle+ does NOT have the ID: 934DA
the Circle+ is powered and when plugging in I hear a ‘click’
I have tried using the circle+ with the source software on windows but it gets stuck on linking it to the stick. I’ve waited around 1,5 hours and it’s still not working.

@lll.co, You might have to try resetting the Circle+ using this instruction first and then try to link it to the stick using the source software. And afterwards all other plugs too.

@JeeCee, the missing part looks like some kind of communication issue during that period. Do you see an unavailable state?

@jammiejammie, The main reason I started (re)writing the backend library is to make it more reliable. At the moment in this library the automatic polling interval is kind of fixed. The used polling interval is calculated based on the number of nodes. It’s on the to do list to make it optional to configure it manually.

1 Like

Ok, so i have 19 nodes in my network.
What should i be getting as polling interval?

I’ve set it to a debatable 3sec per node over here After the update thread has finished al it tasks it will suspend for the calulated time. Some time drift, according to the time required to do the tasks, will happen too.

okay I have successfully reset my circle+ and have been trying to reset my circles but no luck. Tried every reset method but it won’t work. I don’t know what firmware they’re on because they don’t connect without a reset.

edit: after hours of trying I found the problem. The ‘newest’ version of source does NOT allow plugs with old firmware. I downloaded a old version of source and this one does find the circles. I can update them and then the newest version will find them.

Plugwise-2-py uses 2 different poll times if i’m correct.
Every 10 seconds for the power (W) for all plugs, and every minute for polling the energy (Wh) of one plug.

What is the reason that the polling time is calculated based on the number of nodes? Because the plugwise2py polling type works quite sable for me actually.

I took the number of nodes in the calculation of the polling time to prevent oversaturation of the network communication. This way a small network of a few nodes updates more frequently in relation to a network containing a lot (max 64) nodes in which case there could be nodes only reachable by multiple hops consuming more network time.
The polling does only request the power use and a ping to allow HA to update the device availability.

As we’ve now (in BETA) merged the custom_components, we’d like to continue in the Plugwise core and custom_component topic. See you all there!

For most users here, please note that with our merge/combined forces we are looking for testers! Updates to including Plugwise Stick into HA core are ongoing (so we hope you’ll be able to help us test the beta custom_component)

1 Like

To provide some more background, @brefa’s code for the Plugwise Stick has been merged with the plugwise-beta code, with the aim of providing this functionality, in the future, as a part of Home Assistant Core.

Please note that brefa has been busy: there are several new functions available like full hardware-detection (I can see my Stealth M+ now :slight_smile: ) and automatic connection of devices that have been reset.

So, please head over to the new topic and help us test the latest code!

1 Like

Is this custom component still relevant? (since topic is 2 years old). Looking for support for my old Plugwise stick and Circles.

I am trying to install the Plugwise component through HACS, installed v1.0.4. Added the extra lines of code to configuration.yaml.

Restarting gives me:
2023-02-12 16:26:16.306 ERROR (SyncWorker_2) [homeassistant.loader] The custom integration ‘plugwise’ does not have a version key in the manifest file and was blocked from loading. See Custom integration changes | Home Assistant Developer Docs for more details

2023-02-12 16:26:16.307 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2023-02-12 16:26:22.489 ERROR (MainThread) [homeassistant.components.switch] The plugwise platform for the switch integration does not support platform setup. Please remove it from your config.

@W_denice the version you’re referring to is indeed deprecated and not maintained anymore.
You’ve have to use the development (beta) version of the Plugwise Integration as the native Plugwise integration does not support the legacy stick & plugs (yet)
Note: you’ve to manually register this version in HACS

This development version is discussed in this thread

1 Like

Thanks very much, this was the info I was looking for! My stick is now recognized and one Circle+ is also detected. My other Circle (non-plus) is not detected but this may have to do with the reception of the signal I guess. The rest seems to work OK now. Many thanks!

update: putting the Circle closer to the stick makes it detectable as well. Now all working

For anyone using the plugwise-beta custom_component, please read Plugwise core and custom_component - #338 by CoMPaTech before updating beyond v0.34.10. TLDR; we have moved USB support into a separate integration (yes again) to better align for upstreaming.

TEST-RELEASE: Release Recent improvements on EnergyCounters and Network Floodings. · plugwise/plugwise_usb-beta · GitHub

Welcome @dirixmjm to the team, he has made some nice improvements to the code, please test his recent updates.

Do these updates help solve the reported memory-leak?