Plugwise Plugs component

After updating to Core 0.114.0, Iā€™m seeing this in Logs:

Log Details (ERROR)
Logger: root
Source: /usr/src/homeassistant/homeassistant/bootstrap.py:313
First occurred: 2:57:56 PM (1 occurrences)
Last logged: 2:57:56 PM

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 701, in _watchdog_loop
    if not self.connection.read_thread_alive():
  File "/usr/local/lib/python3.8/site-packages/plugwise/connections/connection.py", line 103, in read_thread_alive
    return self._reader_thread.isAlive() if run_reader_thread else False
NameError: name 'run_reader_thread' is not defined

Thanks @bouwew for reporting the exception.
Iā€™ve fixed this in the updated v1.2.1 release. Please update the custom Integration from HACS.

1 Like

@brefa, an observation and some feedback, if you donā€™t mind :slight_smile:

I see you are showing as an attribute the ā€œtoday_energy_kwhā€ value. When looking at the value: 0.002 at the moment, and looking at my own sensor for the same entity: 2.2, it looks like your value is a factor 1000 wrong.

I also see that you are showing the device_class ā€œoutletā€ as an attribute.
FYI, switches donā€™t have device classes, see here: https://www.home-assistant.io/docs/configuration/customizing-devices/#device-class
Click on each entity to see the allowed device_classes per type of entity.

@bouwew, Iā€™m happy with any feedback :wink:

Nice catch, the today_energy_kwh is definitely miscalculated. I have fixed it in the latest version 1.2.2.

I have assigned the ā€œoutletā€ device_class according to this development page. Apparently the user documentation is kind of missing the switch entity.
Do you experience any negative behavior due to this device_class setting?

Thanks for the fix, the value is correct now.

Also, thanks for the link, I hadnā€™t looked there :slight_smile:
Indeed, the documentation is not great.

Just FYI, not to steal your thunder @brefa :slight_smile: , initial support for the Plugwise Stretch with firmware 3.1 is available in Plugwise-beta. Please leave a message in the Plugwise Smile custom_component (BETA) topic if you are interested in helping us test.

@brefa I just noticed that after the latest update the sensors for power_consumption_today_xyz and power_consumption_yesterday_xyz are always zero.

@bouwew, sorry I cannot reproduce the problem you are reporting. Do you experience this for all plugs and do the values remain at 0 even after one day?
If possible could you collect some debug logging of the startup process (first few minutes should be enough) so Iā€™m able to investigate this.

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

Sneak preview for next release:
Getting support for Scan devices and automatic accepting (joining) of new or reset devices is almost finished:


Still some code polishing and reorganization to doā€¦

Iā€™ve just checked again: false alarm, the numbers are no longer 0 :slight_smile:
Must have been a glitch in my system, sorry!

Hi, first off thank you for all your hard work. I was very excited to see that my plugs arenā€™t useless anymore. I do have a problem with configuring the USB stick. It gives me the following error: ā€˜Initialization of Plugwise USB-stick failedā€™ when selecting the stick. I followed the 3 steps written in the first post, anything I overlooked? thanks.

Did you restart HA Core after installing the integration?
This is not in the first post but is required.

I restarted my server, but the problem is still there.

Are you sure you have selected the correct USB serial device? The most obvious reason to bump into this error messages is when you selected/entered a wrong device path.

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.