ConBee ZigBee Stick and HA, will this work together?

Hmm, i cloned your HA repo, hand picked all deconz.py files and copied them to custom_components but i get problems on startup :

2017-11-09 11:09:48 ERROR (MainThread) [homeassistant.loader] Unable to find component input_slider
2017-11-09 11:09:48 ERROR (MainThread) [homeassistant.setup] Setup failed for input_slider: Component not found.
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.light.deconz. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/loader.py", line 142, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/light/deconz.py", line 13, in <module>
    from homeassistant.components.deconz import DATA_DECONZ
ModuleNotFoundError: No module named 'homeassistant.components.deconz'
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Unable to find component light.deconz
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.deconz: Platform not found.
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.sensor.deconz. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/loader.py", line 142, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/sensor/deconz.py", line 10, in <module>
    from homeassistant.components.deconz import DATA_DECONZ
ModuleNotFoundError: No module named 'homeassistant.components.deconz'
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Unable to find component sensor.deconz
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.deconz: Platform not found.
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.binary_sensor.deconz. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/loader.py", line 142, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/binary_sensor/deconz.py", line 12, in <module>
    from homeassistant.components.deconz import DATA_DECONZ
ModuleNotFoundError: No module named 'homeassistant.components.deconz'
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Unable to find component binary_sensor.deconz
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform binary_sensor.deconz: Platform not found.

In /deps/lib/python3.6/site-packages/ i have pydeconz already so it has downloaded it correct.

Maybe it’s because i place the component in custom_components ?

Yes. You need to put them under site-packages / home-assistant / components

hmm, i can’t find that path on my docker container only /usr/src/app/homeassistant/components which is a hassle to update new things in. Is that the place you mean ?

That’s where we did it yesterday. But that was in a virtual environment. Come to think of it it is probably a venv specific path. I’ve never used docker so I am of no use for docker specific issues. I guess you could change the files to be custom components quite easily right?

I don’t know what kind of change is required to make it custom_component ?

It might be as easy as renaming homeassistant.components.deconz to custom_component.deconz

Since that is whats failing in your error log

File "/config/custom_components/binary_sensor/deconz.py", line 12, in <module>
    from homeassistant.components.deconz import DATA_DECONZ
ModuleNotFoundError: No module named 'homeassistant.components.deconz'
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.loader] Unable to find component binary_sensor.deconz
2017-11-09 11:10:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform binary_sensor.deconz: Platform not found.

Ok so i got it working, here are few comments :

  • I would filter out the groups which has no lights attached to it since deConz makes a group for each remote, i don’t see what use these has. I filtered these out in my implementation by looking at the groups lights count and if it was 0 i would not add them to HASS
  • I cannot set color of the lights but you mention it as possible for instance i should have a control of Color temperature on a type: Color temperature light and full RGB color light on a type : Extended color light, you can check my code if you want to add that or any other code that has color lights.
  • In my implementation i added the battery value for each sensors (that supports it) as a separete sensor because otherwise i would have to make a template sensor for each sensor to pull out the battery value and react to it which will be quite a lot of sensor templates i would have to make so i suggest you also do that, it’s just one more call to create that type of sensor. I think it’s great that you have it on the sensor but also as a separate sensor would be of big value at least to me.
  • I can’t try if you are firing events in HASS (since i don’t have a CLIPSwitch support and i am not home) coming on the Websocket from the sensors like user pushes a button. Do you do that ? If not i suggest you add that support. As mentioned earlier it’s a great way to get events from the switces instead of using the sensor value in HASS.

Otherwise it looks good. It’s great you separated things which makes it eventually possible to go into hass as a integrated module. Great work !

Great feedback!

  • Filter out empty groups. I noticed that yesterday so that is already in the latest version :slight_smile:
  • Haven’t added support for color temperature or RGB yet, my goal is to have support for it before the end of this week. Got a Osram RGBW led strip up and running yesterday and will add a Hue light aswell. Though I lost one Ikea GU10 white that doesn’t want to reconnect and I can’t seem to reset it through power cycling either. Any thoughts?
  • Separate battery sensor, I’m not certain how or if I should add this, I will think about and maybe play around with a design and talk to the HASS guys as well as to the preferred way of exposing battery info.
  • Extra signal for sensors, I will talk to HASS guys about this as well. They might not like that double events are happening per sensor. Maybe there is a easy way for this.

/R

  1. Good, i’ll update again
  2. You wrote "Lights, dimmable but able to set temperature or color right now. Exposed as a light. so therefore i thought you had support for it but i guess you forgot to add not :wink:
    I have over 20 GU10 and i have always been able to use the power cycle routing to reset them such as 6 time on/off then they will blink. It’s important to have the network open in deConz when you turn it on first time after power cycle then they should join. You can also remove the node from deConz after you have reset the light at that time open the network and turn the light on to join.
  3. What i have done for switches is that i have not added them as sensors but the only way they interact with HASS is by sending events and those events i react on in automation. Actually that is not fully true, i did actually added a sensor in deConz that supports battery as two sensors in HASS, one as a normal switch sensor and one as a battery sensor. I can see for instance more devices do that so one device can be multiple sensors in HASS. I don’t see a problem with this but yes ask the HASS guys.
  4. Events i think is the right way to do things like this, i mean switches send events, i see no other way to attach this than also send events, one could argue if then sensors are required to be created for switches and i don’t think so, what use are they ? again ask the HASS guys.
  1. Sometimes I’m too quick :). Thanks for the tip, will try it with different timing.
    3/4 It’s also important for it to be easy to see what gets exposed from the component, so some kind of sensor per device. Remember, it is not as obvious for other people who have not coded towards deconz api ;). I’m gonna start with best practices from what the HASS guys want because that will limit what alternatives to do this

Added support for coloured lights now, it is probably buggy

Ok i tested it but it doesn’t get far

2017-11-10 20:11:26 DEBUG (MainThread) [pydeconz.deconzdevice] New device created {'_device_id': '9482', '_any_on': False, '_bri': 127, '_class': 'Other', '_colormode': 'hs', '_ct': 0, '_devicemembership': ['12'], '_effect': 'none', '_hidden': False, '_hue': 0, '_id': '9482', '_lights': [], '_lightsequence': [], '_multideviceids': [], '_on': True, '_sat': 127, '_scenes': [], '_xy': [0, 0], '_set_state_callback': <bound method DeconzSession.put_state_async of <pydeconz.DeconzSession object at 0x7f50a01e98d0>>, '_etag': '9bc0132d59c623b68139edaf9d849562', '_manufacturername': None, '_modelid': None, '_name': 'RWL021 8', '_swversion': None, '_type': 'LightGroup', '_uniqueid': None, 'callback': None}
2017-11-10 20:11:26 ERROR (MainThread) [homeassistant.setup] Error during setup of component deconz
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 191, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "/config/custom_components/deconz.py", line 60, in async_setup
    yield from _setup_deconz(hass, config, deconz_config)
  File "/config/custom_components/deconz.py", line 83, in _setup_deconz
    yield from deconz.populate_lights()
  File "/config/deps/lib/python3.6/site-packages/pydeconz/__init__.py", line 70, in populate_lights
    self.lights[light_id] = DeconzLight(light_id, light, self.put_state_async)
  File "/config/deps/lib/python3.6/site-packages/pydeconz/light.py", line 33, in __init__
    self._x, self._y = device['state'].get('xy')
TypeError: 'NoneType' object is not iterable
2017-11-10 20:11:26 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:

I suspect the problem to be that you add empty groups, the last group it states that is new is a group that is empty.

When xy doesn’t exist it returns Null, I didn’t change that in groups yet. Is it a white light? Need to get that Ikea light working again…

Here is a full list of all my lights, i can’t really say which one it has a problem on since it doesn’t state it in the debug. Hint: maybe a debug output would help when adding :wink:

But yes Color temperature light that has white color spectrum only have ct whereas Dimmable light only have bri

1 Like

That’s an awesome list to verify against!

There won’t be any issues with any of the other parameters, just the xy which is a tuple and I tried to be smart… Came back to bite me in the ass… I’ll just put in a check for if it is none or not.

Do notice the Osram light that has both ct and xy so i am not sure your code takes that into account. No IKEA light that i have have xy. Note to myself, get a IKEA color light, also i need to add at least a Philips HUE light to see how that behaves and what options it has.

FYI: In my implementation i believe there is a bug where i convert RGB to XY since the the brightness is changed as well (i hope you have not copied my code :wink: ) and i don’t know if that’s entirely correct.

I have Hue RGB lights, but they’re in the production environment…

I was thinking about the brightness as well, but in some way it makes sense, because in Y-led it is both color and brightness, so I think it is correct as it is.

Ok well i guess then i don’t have a bug :wink:

Hey, Im not saying that Im right, only that in some regard that it makes sense :slight_smile:

Would you mind explaining the difference in automations for you regarding to signals versus sensors?