Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Zigbee Home Automation #6263

Merged
merged 13 commits into from Apr 25, 2017
Merged

Add support for Zigbee Home Automation #6263

merged 13 commits into from Apr 25, 2017

Conversation

rcloran
Copy link
Contributor

@rcloran rcloran commented Feb 26, 2017

Description: Add support for locally managed ZigBee Home Automation devices with a compatible ZigBee radio.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2155

Example entry for configuration.yaml (if applicable):

zha:
  usb_path: /dev/ttyUSB0
  database_path: /home/hass/.config/bellows/app.db

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

Hi @rcloran,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@balloob
Copy link
Member

balloob commented Feb 27, 2017

I'm a bit confused here. We already have a Zigbee component + platforms: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/zigbee.py

@rcloran
Copy link
Contributor Author

rcloran commented Feb 27, 2017

The zigbee component is a "DIY" component. As far as I know, you can't do anything but control or read digital and analog pins on a remote zigbee device. The configuration reflects this.

This PR is for "consumer" zigbee devices. I should expand the docs PR to list some example devices, but here's why I'm controlling through ZigBee at the moment:

  • SmartThings motion sensor (motion + temperature)
  • SmartThings arrival sensor
  • Iris door sensor (opening + temperature)
  • SmartThings Outlet
  • OSRAM Lightify tunable white bulb
  • Philips Hue dimmable bulb
  • Philips Hue color bulb

@rcloran
Copy link
Contributor Author

rcloran commented Feb 27, 2017

I meant to say "control or read digital and analog pins on a remote xbee device" previously.

@raccettura
Copy link
Contributor

What zigbee hardware is this supporting?

@rcloran
Copy link
Contributor Author

rcloran commented Feb 27, 2017

In terms of the local radio, it should support any EmberZNet device that supports the EZSP protocol. I've been using the GoControl QuickStick Combo (sometimes also called HubZ, model number is HUSBZB-1).

ZigBee devices I have tested on the network are:

  • SmartThings motion sensor (motion + temperature)
  • SmartThings arrival sensor
  • Iris door sensor (opening + temperature)
  • SmartThings Outlet
  • OSRAM Lightify tunable white bulb
  • Philips Hue dimmable bulb
  • Philips Hue color bulb

@balloob
Copy link
Member

balloob commented Feb 28, 2017

Thanks for the clarification.

If this implements the EZSP protocol, I suggest we rename this component to ezsp

@rcloran
Copy link
Contributor Author

rcloran commented Feb 28, 2017

I'm not totally against renaming it. That said, I want to make sure that the understanding about the various protocols etc is clear.

EZSP is the protocol between the host (Home Assistant, in this case) and the "Network Co-Processor" (a USB device which contains a ZigBee radio). It implements methods like formNetwork (with parameters like the channel, security keys, etc), permitJoins, sendUnicast (with a destination address, and packet contents) and sendMulticast (similar). You could use an EZSP device to talk to XBee devices using their flavour of ZigBee.

bellows is a library which implements the EZSP protocol, and then a ZigBee stack on top of that. In that sense, it really conflates two things. Some of the ZigBee support in it also assumes ZHA (mostly just for expedience).

It should be possible to use the ZigBee parts of the bellows stack and just replace how it communicates with a radio, in order to provide ZHA support for other radios - XBee S2C and TI CC2530/CC2531 seem like possible candidates.

The logic that exists inside this platform is all about implementing the ZigBee Home Automation logic - eg, when we read manufacturer and model information in _discover_endpoint_information, that is about dealing with things specified in the ZHA spec; there's nothing EZSP specific about it.

I guess the question is ... if someone wanted to implement support for ZHA devices with an XBee S2C radio as the controller, would you prefer that they re-implement the logic in this platform?

@andrewpc
Copy link

andrewpc commented Mar 1, 2017

This looks excellent. Ive been keen to try zigbee direct rather than needing to use a proprietary gateway or hub. It looks like this usb device might also be compatible too as it seems to use an EmberZNet chipset?

@rcloran
Copy link
Contributor Author

rcloran commented Apr 24, 2017

@dale3h , I've just re-added my iris contact sensor, and it works OK (it reports as a CentraLite 3320). If you could get me some debug logs, that'd be useful. I usually run with this logger config:

logger:
  default: debug
  logs:
    homeassistant.components.websocket_api: info
    bellows.uart: info

@balloob
Copy link
Member

balloob commented Apr 24, 2017

Yes, naming is fine.

@balloob
Copy link
Member

balloob commented Apr 24, 2017

This is ready to merge @rcloran when you give the 👍

@dale3h
Copy link
Member

dale3h commented Apr 24, 2017

@rcloran Here is the (filtered) debug output from me trying to permit 3 different, in this order:

  1. Iris Gen 2 Contact Sensor
  2. IKEA Tradfri Motion Detector
  3. IKEA Tradfri Wireless Dimmer
17-04-24 14:11:10 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=permit, service_call_id=140666110357576-4, service_data=duration=120, domain=zha>
17-04-24 14:11:10 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 FORWARDING <Event call_service[L]: service=permit, service_call_id=140666110357576-4, service_data=duration=120, domain=zha>
17-04-24 14:11:10 INFO (MainThread) [homeassistant.components.zha] Permitting joins for 120s
17-04-24 14:11:10 DEBUG (MainThread) [bellows.ezsp] Send command permitJoining
17-04-24 14:11:10 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 WRITING data: {"event_type": "call_service", "origin": "LOCAL", "data": {"domain": "zha", "service_call_id": "140666110357576-4", "service_data": {"duration": 120}, "service": "permit"}, "time_fired": "2017-04-24T19:11:10.118879+00:00"}
17-04-24 14:11:10 DEBUG (MainThread) [bellows.ezsp] Application frame 34 (permitJoining) received
17-04-24 14:11:10 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140666110357576-4>
17-04-24 14:11:10 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 FORWARDING <Event service_executed[L]: service_call_id=140666110357576-4>
17-04-24 14:11:10 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 WRITING data: {"event_type": "service_executed", "origin": "LOCAL", "data": {"service_call_id": "140666110357576-4"}, "time_fired": "2017-04-24T19:11:10.139565+00:00"}
17-04-24 14:11:32 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:32 DEBUG (MainThread) [bellows.zigbee.zdo] [0x8278:zdo] ZDO request 0x0006: [65533, 260, [25], []]
17-04-24 14:11:32 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:11:32 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:11:32 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:11:34 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:34 WARNING (MainThread) [bellows.zigbee.zcl] Data remains after deserializing ZCL frame
17-04-24 14:11:34 WARNING (MainThread) [bellows.zigbee.endpoint] [0x8278:1] Message on unknown cluster 0x0019
17-04-24 14:11:38 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:38 WARNING (MainThread) [bellows.zigbee.zcl] Data remains after deserializing ZCL frame
17-04-24 14:11:38 WARNING (MainThread) [bellows.zigbee.endpoint] [0x8278:1] Message on unknown cluster 0x0019
17-04-24 14:11:41 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:41 WARNING (MainThread) [bellows.zigbee.zcl] Data remains after deserializing ZCL frame
17-04-24 14:11:41 WARNING (MainThread) [bellows.zigbee.endpoint] [0x8278:1] Message on unknown cluster 0x0019
17-04-24 14:11:44 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:44 WARNING (MainThread) [bellows.zigbee.zcl] Data remains after deserializing ZCL frame
17-04-24 14:11:44 WARNING (MainThread) [bellows.zigbee.endpoint] [0x8278:1] Message on unknown cluster 0x0019
17-04-24 14:11:47 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:11:47 WARNING (MainThread) [bellows.zigbee.zcl] Data remains after deserializing ZCL frame
17-04-24 14:11:47 WARNING (MainThread) [bellows.zigbee.endpoint] [0x8278:1] Message on unknown cluster 0x0019
17-04-24 14:12:13 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:12:16 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:13:19 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:13:19 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:13:21 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:13:21 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:13:26 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:13:26 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:13:28 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:13:28 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:13:36 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:13:36 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
17-04-24 14:13:36 INFO (MainThread) [bellows.zigbee.application] Device 0x8278 (00:0b:57:ff:fe:2b:37:71) left the network
17-04-24 14:13:36 WARNING (MainThread) [bellows.zigbee.util] Error calling listener.device_left: 'ApplicationListener' object has no attribute 'device_left'
17-04-24 14:14:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=permit, service_call_id=140666110357576-12, service_data=duration=120, domain=zha>
17-04-24 14:14:25 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 FORWARDING <Event call_service[L]: service=permit, service_call_id=140666110357576-12, service_data=duration=120, domain=zha>
17-04-24 14:14:25 INFO (MainThread) [homeassistant.components.zha] Permitting joins for 120s
17-04-24 14:14:25 DEBUG (MainThread) [bellows.ezsp] Send command permitJoining
17-04-24 14:14:25 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 WRITING data: {"event_type": "call_service", "origin": "LOCAL", "data": {"domain": "zha", "service_call_id": "140666110357576-12", "service_data": {"duration": 120}, "service": "permit"}, "time_fired": "2017-04-24T19:14:25.970221+00:00"}
17-04-24 14:14:26 DEBUG (MainThread) [bellows.ezsp] Application frame 34 (permitJoining) received
17-04-24 14:14:26 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140666110357576-12>
17-04-24 14:14:26 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 FORWARDING <Event service_executed[L]: service_call_id=140666110357576-12>
17-04-24 14:14:26 DEBUG (MainThread) [homeassistant.components.api] STREAM 140664743010368 WRITING data: {"event_type": "service_executed", "origin": "LOCAL", "data": {"service_call_id": "140666110357576-12"}, "time_fired": "2017-04-24T19:14:26.087982+00:00"}
17-04-24 14:14:26 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
17-04-24 14:14:27 INFO (MainThread) [bellows.zigbee.application] Device 0xf016 (00:0b:57:ff:fe:2b:37:71) joined the network
17-04-24 14:14:27 INFO (MainThread) [bellows.zigbee.device] [0xf016] Discovering endpoints
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 98 (incomingSenderEui64Handler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.zigbee.zdo] [0xf016:zdo] ZDO request 0x0013: [61462, 00:0b:57:ff:fe:2b:37:71, 128]
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:14:27 INFO (MainThread) [bellows.zigbee.device] [0xf016] Discovered endpoints: [1]
17-04-24 14:14:27 INFO (MainThread) [bellows.zigbee.endpoint] [0xf016:1] Discovering endpoint information
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:14:27 INFO (MainThread) [bellows.zigbee.endpoint] [0xf016:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=2064 device_version=2 input_clusters=[0, 1, 3, 9, 2821, 4096] output_clusters=[3, 4, 6, 8, 25, 4096]>
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:27 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:14:35 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:14:35 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:14:46 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:14:46 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
17-04-24 14:14:46 INFO (MainThread) [bellows.zigbee.application] Device 0xf016 (00:0b:57:ff:fe:2b:37:71) left the network
17-04-24 14:14:46 WARNING (MainThread) [bellows.zigbee.util] Error calling listener.device_left: 'ApplicationListener' object has no attribute 'device_left'
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
17-04-24 14:14:50 INFO (MainThread) [bellows.zigbee.application] Device 0x91f0 (00:0b:57:ff:fe:2b:37:71) joined the network
17-04-24 14:14:50 INFO (MainThread) [bellows.zigbee.device] [0x91f0] Discovering endpoints
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Application frame 98 (incomingSenderEui64Handler) received
17-04-24 14:14:50 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:50 DEBUG (MainThread) [bellows.zigbee.zdo] [0x91f0:zdo] ZDO request 0x0013: [37360, 00:0b:57:ff:fe:2b:37:71, 128]
17-04-24 14:14:51 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:51 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:14:51 INFO (MainThread) [bellows.zigbee.device] [0x91f0] Discovered endpoints: [1]
17-04-24 14:14:51 INFO (MainThread) [bellows.zigbee.endpoint] [0x91f0:1] Discovering endpoint information
17-04-24 14:14:51 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:51 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:14:52 INFO (MainThread) [bellows.zigbee.endpoint] [0x91f0:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=2064 device_version=2 input_clusters=[0, 1, 3, 9, 2821, 4096] output_clusters=[3, 4, 6, 8, 25, 4096]>
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:14:52 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
17-04-24 14:15:08 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:15:08 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:15:15 DEBUG (MainThread) [bellows.ezsp] Application frame 70 (macFilterMatchMessageHandler) received
17-04-24 14:15:15 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/lib/python3.5/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 54, in data_received
    self.frame_received(frame)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 64, in frame_received
    self.data_frame_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/uart.py", line 84, in data_frame_received
    self._application.frame_received(self._randomize(data[1:-3]))
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/ezsp.py", line 159, in frame_received
    result, data = t.deserialize(data, schema)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/__init__.py", line 9, in deserialize
    value, data = type_.deserialize(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/types/basic.py", line 12, in deserialize
    r = cls.from_bytes(data[:cls._size], 'little', signed=cls._signed)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 128 is not a valid EmberMacPassthroughType
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
17-04-24 14:15:25 INFO (MainThread) [bellows.zigbee.application] Device 0x91f0 (00:0b:57:ff:fe:2b:37:71) joined the network
17-04-24 14:15:25 DEBUG (MainThread) [bellows.zigbee.application] Skip initialization for existing device 00:0b:57:ff:fe:2b:37:71
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 98 (incomingSenderEui64Handler) received
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:15:25 DEBUG (MainThread) [bellows.zigbee.zdo] [0x91f0:zdo] ZDO request 0x0013: [37360, 00:0b:57:ff:fe:2b:37:71, 128]
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 98 (incomingSenderEui64Handler) received
17-04-24 14:15:25 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
17-04-24 14:15:25 DEBUG (MainThread) [bellows.zigbee.zdo] [0x91f0:zdo] ZDO request 0x0013: [37360, 00:0b:57:ff:fe:2b:37:71, 128]

Both IKEA Tradfri devices throw the ValueError: 128 is not a valid EmberMacPassthroughType error. My guess is that whichever protocol they use is not compatible with EmberZNet.

@rcloran
Copy link
Contributor Author

rcloran commented Apr 24, 2017

I'm somewhat ignoring the tradfri stuff for now - my initial experiments with the devices I could get to join showed that they weren't standards compliant. While it may be true that these particular ones are actually, I'm not quite up for this fight with gadgets right now :)

The exception is caused because we're getting an undocumented value over EZSP. Even if I add a value to that enum, I don't have anything that'll handle those macFilterMatchMessageHandler messages. I have a feeling these are generated when some zll devices try to join a zha network, but I'm not yet sure why, or really exactly what they mean.

It's not clear from your logs when you attempted to make the iris contact sensor join. 14:12:13?

Here's the logs from my iris contact sensor joining: https://gist.github.com/rcloran/7a91bbeb1e708fc54c98b5cca02a1c4e

It seems that yours is not finishing the join to the trust center, which is something entirely handled by the USB stick (ie, no communication with bellows). Did you do anything special when forming the network, or did you let the code in hass do that?

@rcloran
Copy link
Contributor Author

rcloran commented Apr 25, 2017

@dale3h got his device paired - it needed to be closer to his zigbee radio. So, I'm confident this is reasonably close to OK to merge. There are a few things I'd still like to do, but I can always submit more PRs to fix future things. I guess there's one quick fix I want to make, which is to add a value 128 to the EmberMacPassthroughType in bellows. Will do that and push a bumped requirement here in a few minutes.

@patrickeasters
Copy link
Contributor

Sorry if I led you astray this weekend, @dale3h! My Iris Contact sensor paired just fine from across the house. 😬

@balloob balloob merged commit d79f89e into home-assistant:dev Apr 25, 2017
@dale3h
Copy link
Member

dale3h commented Apr 25, 2017

👏 👏 👏 👏 👏

@h3ndrik
Copy link
Contributor

h3ndrik commented Apr 25, 2017

just joining the discussion about compatible usb sticks available in Europe(/Germany). Are there any?

what about an em357 or em3588 based stick? (like this one: https://www.digikey.de/de/product-highlight/c/cel/cortet-radio-em3588-usb-sticks)
and i assume i need some firmware, too? is a compatible firmware image available somewhere?

@rcloran rcloran deleted the zha branch April 25, 2017 16:10
@rcloran
Copy link
Contributor Author

rcloran commented Apr 25, 2017

@h3ndrik , I think that em3588 stick should work.

@turbokongen
Copy link
Contributor

Is this a stick that would work? https://www.dresden-elektronik.de/conbee/

@patrickeasters
Copy link
Contributor

@turbokongen I believe @dale3h confirmed that the Conbee does NOT work since the firmware isn't compatible.

@Hedda
Copy link
Contributor

Hedda commented Apr 26, 2017

@MartinHjelmare
Copy link
Member

Please don't turn merged PRs into a FAQ or forum. That's what our forum and docs are for. If there's a problem, open an issue. Thanks!

@home-assistant home-assistant locked and limited conversation to collaborators Apr 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet