Plugwise Plugs component

Works like a charm, been humming along nicely now for the past 10 minutes. :+1:

Hi,

Just FYI, @CoMPaTech and me, @bouwew, are working on a HA custom_component that supports the “new” Plugs, via the Adam HA.
Any suggestion on how we should name these new Plugs so they can be distinguished from the “old” Plug: the Circles and the Stealth’s?

Or, maybe the title of this topic can be changed to “Plugwise legacy Plugs component”?

(I have a number of these old units lying around collecting dust, several Sticks as well, anyone interested?)

@brefra thank you for this plugin!
i just got started with hass, so it took some time to get it running, but after a reboot or 2 it started working, and automatically showed my plugs, very cool indeed.

i have a couple of circles i only use for monitoring power, and which i don’t want to toggle accidentally, so i’ve disabled the switch part of those devices.
when looking at the logs later, i noticed a warning message about the disabled switches.

2020-03-29 12:50:00 WARNING (MainThread) [homeassistant.helpers.entity] Entity switch.circle_ecf19 is incorrectly being triggered for updates while it is disabled. This is a bug in the plugwise_stick integration.
2020-03-29 12:50:53 WARNING (MainThread) [homeassistant.helpers.entity] Entity switch.circle_ef08e is incorrectly being triggered for updates while it is disabled. This is a bug in the plugwise_stick integration.
2020-03-29 12:51:48 WARNING (MainThread) [homeassistant.helpers.entity] Entity switch.circle_ba0ae is incorrectly being triggered for updates while it is disabled. This is a bug in the plugwise_stick integration.
2020-03-29 12:58:07 WARNING (MainThread) [homeassistant.helpers.entity] Entity switch.circle_bc4ff is incorrectly being triggered for updates while it is disabled. This is a bug in the plugwise_stick integration.

doesn’t seem to be a big problem, but thought i would mention it here :smiley:

I love to see my Plugwise stick integration is usable :slight_smile:

To anyone who is interested I just have updated the library and the required custom component files.

Besides some code fixes and cleanups, this release corrects the power consumption calculation of historic power use (last hour, today & yesterday). It also adds the power production messurement of Circle plugs.

@koter84, I’ll have a look into the warning messages.

@bouwew, we must indeed make a clear distinction between the old and new Plugwise products. I’ve called my integration plugwise_stick to “link” the name to the required (legacy) USB stick. I intend to emphasize this in the linked documentation when I do the final pull request to append this integration to HA core.

@brefra, thanks!
Would it be an idea to link to each others topics?
Our topic is here: Plugwise Smile custom_component (BETA)

@brefra I updated to your latest release, but it seems this broke the integration. All my modules are now offline and no data is coming in anymore. Also tried removing and re-adding through integrations, no joy.

The following is all the logging after adding the stick again. After this nothing happens anymore:

2020-04-05 21:12:58 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-04-05 21:13:29 DEBUG (MainThread) [plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] start serial port
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] Serial port initialized
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] Send init request to Plugwise Zigbee stick
2020-04-05 21:13:29 INFO (MainThread) [homeassistant.setup] Setting up plugwise_stick
2020-04-05 21:13:29 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-04-05 21:13:29 INFO (MainThread) [homeassistant.setup] Setup of domain plugwise_stick took 0.0 seconds.
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] start serial port
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] Serial port initialized
2020-04-05 21:13:29 DEBUG (MainThread) [plugwise] Send init request to Plugwise Zigbee stick
2020-04-05 21:13:29 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:29 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Feed data: b'\x03\x030000000100C1FEED\r\n\x05\x05\x03\x0300110001000D6F000258842E0101220D6F0002588DB0DD22FF28C9\r\n\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Parse data: b'\x05\x03\x030000000100C1FEED\r\n\x05\x05\x03\x0300110001000D6F000258842E0101220D6F0002588DB0DD22FF28C9\r\n\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83' 
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x03\x030000000100C1FEED\r\n\x05\x05\x03\x0300110001000D6F000258842E0101220D6F0002588DB0DD22FF28C9\r\n\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message header found at index 21
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300110001000D6F000258842E0101220D6F0002588DB0DD22FF28C9\r\n\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message footer found at index 58
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] New StickInitResponse message with seq id b'0001' for 000D6F000258842E
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Reset parser : b'\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Parse data: b'\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83' 
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x83\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message header found at index 1
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Success acknowledge on message request with sequence id b'0002'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Reset parser : b'00000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Parse data: b'00000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83' 
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000200C1103F\r\n\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message header found at index 16
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300110002000D6F000258842E0101220D6F0002588DB0DD22FF9757\r\n\x83')
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Valid message footer found at index 58
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] New StickInitResponse message with seq id b'0002' for 000D6F000258842E
2020-04-05 21:13:29 ERROR (Thread-5) [plugwise] Error while processing StickInitResponse message : b'0002'
2020-04-05 21:13:29 DEBUG (Thread-5) [plugwise] Reset parser : b'\x83'
2020-04-05 21:13:30 DEBUG (send_messages_deamon) [plugwise] send NodeInfoRequest to 000D6F0002588DB0 using seq_id b'0003'
2020-04-05 21:13:30 DEBUG (write_packets_process) [plugwise] Sending NodeInfoRequest to plugwise stick (b'\x05\x05\x03\x030023000D6F0002588DB02DA1\r\n')
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:30 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Feed data: b'\x03\x030000000300C1BA6E\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000300E110C8\r\n\x83'
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Parse data: b'\x05\x03\x030000000300C1BA6E\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000300E110C8\r\n\x83' 
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x03\x030000000300C1BA6E\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000300E110C8\r\n\x83')
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Valid message header found at index 130
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000300E110C8\r\n\x83')
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Timeout acknowledge on message request with sequence id b'0003'
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] NodeInfoResponse request with seq id b'0003' processed
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Network time out received for (1 of 3) of NodeInfoRequest to 000D6F0002588DB0, resend request
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Reset parser : b'00000300E110C8\r\n\x83'
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Parse data: b'00000300E110C8\r\n\x83' 
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000300E110C8\r\n\x83')
2020-04-05 21:13:30 DEBUG (Thread-5) [plugwise] No valid message header found yet
2020-04-05 21:13:39 DEBUG (receive_timeout_deamon) [plugwise] Timeout expired for message with sequence ID b'0000'
2020-04-05 21:13:39 DEBUG (receive_timeout_deamon) [plugwise] Resend request StickInitRequest
2020-04-05 21:13:39 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:39 DEBUG (Thread-5) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Feed data: b'\x03\x030000000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83'
2020-04-05 21:13:39 DEBUG (Thread-5) [plugwise] Parse data: b'00000300E110C8\r\n\x83\x05' 
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Parse data: b'\x05\x05\x05\x03\x030000000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83' 
2020-04-05 21:13:39 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000300E110C8\r\n\x83\x05')
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x05\x03\x030000000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83')
2020-04-05 21:13:39 DEBUG (Thread-5) [plugwise] No valid message header found yet
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Valid message header found at index 1
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83')
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Success acknowledge on message request with sequence id b'0004'
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Reset parser : b'00000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83'
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Parse data: b'00000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83' 
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000400C1DDBA\r\n\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83')
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Valid message header found at index 16
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300110004000D6F000258842E0101220D6F0002588DB0DD22FFF84A\r\n\x83')
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Valid message footer found at index 58
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] New StickInitResponse message with seq id b'0004' for 000D6F000258842E
2020-04-05 21:13:39 DEBUG (Thread-4) [plugwise] Reset parser : b'\x83'
2020-04-05 21:13:39 DEBUG (send_messages_deamon) [plugwise] send NodeInfoRequest to 000D6F0002588DB0 using seq_id b'0005'
2020-04-05 21:13:39 DEBUG (write_packets_process) [plugwise] Sending NodeInfoRequest to plugwise stick (b'\x05\x05\x03\x030023000D6F0002588DB02DA1\r\n')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Parse data: b'00000300E110C8\r\n\x83\x05\x05' 
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000300E110C8\r\n\x83\x05\x05')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] No valid message header found yet
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Feed data: b'\x05\x03\x030000000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Parse data: b'00000300E110C8\r\n\x83\x05\x05\x05\x03\x030000000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83' 
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000300E110C8\r\n\x83\x05\x05\x05\x03\x030000000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Valid message header found at index 18
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Success acknowledge on message request with sequence id b'0005'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Reset parser : b'00000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Parse data: b'00000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83' 
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000500C177EB\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000500E1DD4D\r\n\x83')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Valid message header found at index 125
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000500E1DD4D\r\n\x83')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Timeout acknowledge on message request with sequence id b'0005'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Reset parser : b'00000500E1DD4D\r\n\x83'
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Parse data: b'00000500E1DD4D\r\n\x83' 
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000500E1DD4D\r\n\x83')
2020-04-05 21:13:40 DEBUG (Thread-5) [plugwise] No valid message header found yet
2020-04-05 21:13:41 WARNING (send_messages_deamon) [plugwise] Resend NodeInfoRequest for 000D6F0002588DB0 because stick did not acknowledge request (b'0005')
2020-04-05 21:13:41 DEBUG (send_messages_deamon) [plugwise] send NodeInfoRequest to 000D6F0002588DB0 using seq_id b'0005'
2020-04-05 21:13:41 DEBUG (send_messages_deamon) [plugwise] Retry 1 for message NodeInfoRequest to 000D6F0002588DB0
2020-04-05 21:13:41 DEBUG (write_packets_process) [plugwise] Sending NodeInfoRequest to plugwise stick (b'\x05\x05\x03\x030023000D6F0002588DB02DA1\r\n')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Feed data: b'\x05\x03\x030000000600C19939\r\n# APSRequestNodeInf'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Parse data: b'\x05\x05\x03\x030000000600C19939\r\n# APSRequestNodeInf' 
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'\x05\x05\x03\x030000000600C19939\r\n# APSRequestNodeInf')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Valid message header found at index 0
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000600C19939\r\n# APSRequestNodeInf')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Success acknowledge on message request with sequence id b'0006'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Reset parser : b'00000600C19939\r\n# APSRequestNodeInf'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Parse data: b'00000600C19939\r\n# APSRequestNodeInf' 
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600C19939\r\n# APSRequestNodeInf')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] No valid message header found yet
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Feed data: b'o'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Parse data: b'00000600C19939\r\n# APSRequestNodeInfo' 
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600C19939\r\n# APSRequestNodeInfo')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] No valid message header found yet
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Feed data: b': Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000600E1339F\r\n\x83'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Parse data: b'00000600C19939\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000600E1339F\r\n\x83' 
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600C19939\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000600E1339F\r\n\x83')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Valid message header found at index 125
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000600E1339F\r\n\x83')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Timeout acknowledge on message request with sequence id b'0006'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Reset parser : b'00000600E1339F\r\n\x83'
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Parse data: b'00000600E1339F\r\n\x83' 
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600E1339F\r\n\x83')
2020-04-05 21:13:41 DEBUG (Thread-4) [plugwise] No valid message header found yet
2020-04-05 21:13:42 WARNING (send_messages_deamon) [plugwise] Resend NodeInfoRequest for 000D6F0002588DB0 because stick did not acknowledge request (b'0005')
2020-04-05 21:13:42 DEBUG (send_messages_deamon) [plugwise] send NodeInfoRequest to 000D6F0002588DB0 using seq_id b'0007'
2020-04-05 21:13:42 DEBUG (send_messages_deamon) [plugwise] Retry 2 for message NodeInfoRequest to 000D6F0002588DB0
2020-04-05 21:13:42 DEBUG (write_packets_process) [plugwise] Sending NodeInfoRequest to plugwise stick (b'\x05\x05\x03\x030023000D6F0002588DB02DA1\r\n')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Parse data: b'00000600E1339F\r\n\x83\x05' 
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600E1339F\r\n\x83\x05')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] No valid message header found yet
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Feed data: b'\x05\x03\x030000000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Parse data: b'00000600E1339F\r\n\x83\x05\x05\x03\x030000000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83' 
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000600E1339F\r\n\x83\x05\x05\x03\x030000000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Valid message header found at index 17
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Success acknowledge on message request with sequence id b'0007'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Reset parser : b'00000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Parse data: b'00000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83' 
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000700C13368\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x030000000700E199CE\r\n\x83')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Valid message header found at index 125
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x030000000700E199CE\r\n\x83')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Valid message footer found at index 20
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Timeout acknowledge on message request with sequence id b'0007'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] NodeInfoResponse request with seq id b'0007' processed
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Network time out received for (3 of 3) of NodeInfoRequest to 000D6F0002588DB0, resend request
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Reset parser : b'00000700E199CE\r\n\x83'
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Parse data: b'00000700E199CE\r\n\x83' 
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'00000700E199CE\r\n\x83')
2020-04-05 21:13:42 DEBUG (Thread-4) [plugwise] No valid message header found yet

The debug log shows two concurrent instances to the same plugwise stick. I.e line 2 and 9 both logs an “open USB connection” entry. As result both instances are kind of “fighting” for the response messages. Could you please make sure to remove the integration completely and try adding it again?

I see what you mean. I did the following steps to try and start fresh:

  1. removed integration in HA under Configuration>Integrations
  2. deleted custom_components/plugwise_stick
  3. rebooted server
  4. unpacked plugwise_stick.zip into custom_components
  5. restarted HA
  6. added Plugwise Stick integration

Same behavior again unfortunately:

2020-04-07 00:30:10 INFO (SyncWorker_3) [homeassistant.util.package] Attempting install of python-plugwise==0.5
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] start serial port
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Serial port initialized
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Send init request to Plugwise Zigbee stick
2020-04-07 00:30:50 INFO (MainThread) [homeassistant.setup] Setting up plugwise_stick
2020-04-07 00:30:50 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-04-07 00:30:50 INFO (MainThread) [homeassistant.setup] Setup of domain plugwise_stick took 0.0 seconds.
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Open USB serial connection to Plugwise Zigbee stick
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] start serial port
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Serial port initialized
2020-04-07 00:30:50 DEBUG (MainThread) [plugwise] Send init request to Plugwise Zigbee stick
2020-04-07 00:30:50 DEBUG (write_packets_process) [plugwise] Sending StickInitRequest to plugwise stick (b'\x05\x05\x03\x03000AB43C\r\n')
2020-04-07 00:30:50 DEBUG (Thread-4) [plugwise] Feed data: b'\x05'
2020-04-07 00:30:50 DEBUG (Thread-5) [plugwise] Feed data: b'\x05'
...

Strange problem, I have no idea what is going wrong here.
I guess the previous zip version still works correctly?

Unfortunately old version is also not working anymore. I guess something got ‘stuck’ somewhere, but have no idea what to do about it yet other than restoring a snapshot or backup, which is what I’ll have a go at this weekend.

Interesting detail is after I updated HA to 0.108 today and HA restarted, integration worked again briefly. Had to reboot the system for some other task, after that it was broken again.

I’m unhappy to read it doesn’t work for you anymore.
Could you please check the contents of

/config/.storage/core.config_entries

It should contain only single domain for the plugwise_stick

And can you also validate if the file

/config/.storage/core.device_registry

it should not contain duplicate plugwise devices either.

1 Like

Thanks for caring :+1:

I think I fixed it! Began with a restore of an older snapshot earlier today, but that resulted in other issues where the thread kept dying. Ultimately rolled back to my current snapshot, but had the ‘multiple thread’ issue again. Decided to set global log level to debug and then found another mention of plugwise in the logs. It was an older HACS plugwise integration from cyberjunky. Removed this completely, reinstalled plugwise_stick into custom_components and restarted HA. This time it all worked again :slight_smile:

I don’t understand how this could have been the reason for the issue, but happy everything now works with your latest code.

PS also checked the files you mentioned for duplicate entries in my file backup from yesterday, but only one mention of plugwise in .storage/core.config_entries and no devices in .storage/core.device_registry

1 Like

I’ve made some progress and changed the integration a bit.

  • It now automatically adds a sensor for each meassured value. Some will be default active (enabled) and some will be disabled. If required you can enable/disable sensors.
  • Fixed closing port issue which caused an issue when you enable a sensor.
  • Fixed the warning messages mentioned by @koter84 when you disable sensors/switches
  • Add experimental support for Stealth devices as I am not able to test because I don’t own one

You can download the new custom_component here

2 Likes

I tried to install plugwise but it does not work. These are the steps I took:

  • installed the library: pip3 install python-plugwise
  • copied contents of plugwise_stick to the custom components directory
  • changed the port = “/dev/ttyUSB0” in the example.py wich is the usb port of the plugwise circle stick
  • added the following to the configuration.yaml file:
    switch:
    • platform: plugwise_stick
      port: /dev/ttyUSB0
      circles:
      CirclePlus: 000D6F00019DB8A0

When I run the example.py (python3 ./example.py) I get the following:

roel@srv-hass-01:~/.homeassistant/custom_components/plugwise_stick$ python3 ./example.py
start connecting to stick
Exception in thread receive_timeout_deamon:
Traceback (most recent call last):
File “/usr/lib/python3.7/threading.py”, line 926, in _bootstrap_inner
self.run()
File “/usr/lib/python3.7/threading.py”, line 870, in run
self._target(*self._args, **self._kwargs)
File “/home/roel/.local/lib/python3.7/site-packages/plugwise/stick.py”, line 358, in _receive_timeout_daemon
self.expected_responses[seq_id][1].mac.decode(“ascii”),
AttributeError: ‘str’ object has no attribute ‘decode’

The home assistant log gives this output:
Apr 19 22:23:48 srv-hass-01 hass[779]: 2020-04-19 22:23:48 INFO (MainThread) [homeassistant.components.switch] Setting up switch.plugwise_stick
Apr 19 22:23:48 srv-hass-01 hass[779]: 2020-04-19 22:23:48 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform plugwise_stick
Apr 19 22:23:48 srv-hass-01 hass[779]: Traceback (most recent call last):
Apr 19 22:23:48 srv-hass-01 hass[779]: File “/home/roel/.local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 148, in _async_setup_platform
Apr 19 22:23:48 srv-hass-01 hass[779]: task = async_create_setup_task()
Apr 19 22:23:48 srv-hass-01 hass[779]: File “/home/roel/.local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 104, in async_create_setup_task
Apr 19 22:23:48 srv-hass-01 hass[779]: platform.setup_platform,
Apr 19 22:23:48 srv-hass-01 hass[779]: AttributeError: module ‘custom_components.plugwise_stick.switch’ has no attribute ‘setup_platform’

Any suggestions?

I removed and reinserted the usb stick and now the example.py finds the plugwise nodes. So now home assistant gives me the error:

Apr 19 22:48:59 srv-hass-01 hass[779]: 2020-04-19 22:48:59 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.plugwise_stick
Apr 19 22:48:59 srv-hass-01 hass[779]: 2020-04-19 22:48:59 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform plugwise_stick
Apr 19 22:48:59 srv-hass-01 hass[779]: Traceback (most recent call last):
Apr 19 22:48:59 srv-hass-01 hass[779]:   File "/home/roel/.local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 148, in _async_setup_platform
Apr 19 22:48:59 srv-hass-01 hass[779]:     task = async_create_setup_task()
Apr 19 22:48:59 srv-hass-01 hass[779]:   File "/home/roel/.local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 104, in async_create_setup_task
Apr 19 22:48:59 srv-hass-01 hass[779]:     platform.setup_platform,
Apr 19 22:48:59 srv-hass-01 hass[779]: AttributeError: module 'custom_components.plugwise_stick.sensor' has no attribute 'setup_platform'

No need to install the library through pip. Might even break stuff, not sure…

You only have to:

  1. remove all plugwise stick config from configuration.yaml
  2. download plugwise_stick.zip
  3. unpack it in custom_components/plugwise_stick
  4. restart HA
  5. Add plugwise stick through integrations
  6. configure
1 Like

Thanks hapklaar!

It is working now, the plugs are being discovered and show all the readings. Now I’m going to test this for a week to know it is stable before I put it in my “production” server :wink:

I had to restart the home assistant server after adding the integration. The plugs got discovered after the restart…

@Roel_van_Wanrooy good to hear!

I still have some stability issues where plugwise sensor readings suddenly just stop. home-assistant.log then shows no activity anymore for the plugwise integration. When I only restart HA I see short activity in the log @ debug, then it stops again after 10-20 lines of debug logging without obvious reasons. Only after a full reboot of the server returns to normal.

@brefra any idea what could cause this?

last lines in the logs this time were:

2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Valid message footer found at index 20
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Success acknowledge on message request with sequence id b'4CE6'
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Reset parser : b'004CE600C1CC2A\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x0300004CE600E1668C\r\n\x83'
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Parse data: b'004CE600C1CC2A\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x0300004CE600E1668C\r\n\x83' 
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'004CE600C1CC2A\r\n# APSRequestNodeInfo: Source MAC: 000D6F000258842E# APSRequestNodeInfo: Destination MAC: \r\n000D6F0002588DB0\r\n\x05\x05\x03\x0300004CE600E1668C\r\n\x83')
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Valid message header found at index 125
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Lookup message footer (b'\r\n') in (b'\x05\x05\x03\x0300004CE600E1668C\r\n\x83')
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Valid message footer found at index 20
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Timeout acknowledge on message request with sequence id b'4CE6'
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] NodeInfoResponse request with seq id b'4CE6' processed
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Network time out received for (1 of 3) of NodeInfoRequest to 000D6F0002588DB0, resend request
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Reset parser : b'004CE600E1668C\r\n\x83'
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Parse data: b'004CE600E1668C\r\n\x83' 
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] Lookup message header (b'\x05\x05\x03\x03') in (b'004CE600E1668C\r\n\x83')
2020-04-21 00:22:40 DEBUG (Thread-2) [plugwise] No valid message header found yet
...

Are you using multiple usb devices on a raspberry pi or on one usb port on your pc? If that’s the case than it could be a power issue. I had this before because I had 2 Arduino’s, 2 FTDI sticks and a SDR radio stick on one usb port. When I connected it to a usb hub witch was powered by a separate adapter the problems were over. Some usb devices are more prone to power issues than other. My MySensors hub was having trouble all the time while the other devices worked perfectly.

The plugwise sticks are working flawlessly for a day now.

I used to, but now running everything on a NUC. Hoped that would go better. Both act the same as in they’ll eventually stop gathering Plugwise Stick data after a while and will work fine again after a full reboot.