Yoda-x / ha-zha-new

update of the zha component
56 stars 10 forks source link

PersistingListener, Discovered_Info.get errors and switch/zha_new.py indent error #11

Closed walthowd closed 6 years ago

walthowd commented 6 years ago

Home Assistant Version: 0.60.1

Latest ha-zha new and latest of your fork of bellows. Trying to do a drop in replacement for the existing bellows and ZHA component as I am chasing an issue with color temperature not being controllable from the HA front end for Phillips LCT bulbs and trying to add support for Sengled Element Plus bulbs.

Do I need to specify a device_config for each bulb that's already in zigbee.db?

Config:

zha_new:
  usb_path: /dev/tty.GoControl_zigbee
  database_path: /Users/hass/.homeassistant/zigbee.db

Multiple errors:

2018-01-22 12:39:35 WARNING (MainThread) [bellows.zigbee.util] Error calling listener.device_updated: 'PersistingListener' object has no attribute 'device_updated'

2018-01-22 12:39:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/Users/hass/.homeassistant/custom_components/zha_new.py", line 255, in async_device_initialized
    dev_func= discovered_info.get(CONF_MODEL,"default").replace(".","_").replace(" ","_")
2018-01-22 12:39:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 126, in _async_setup_platform
    self.hass, self.config, self.domain, platform_type)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/setup.py", line 241, in async_prepare_setup_platform
    platform = loader.get_platform(domain, platform_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/loader.py", line 104, in get_platform
    return get_component(PLATFORM_FORMAT.format(domain, platform))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/loader.py", line 142, in get_component
    module = importlib.import_module(path)
  File "/Library/Frameworks/Python.framework/Versions/3.6/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 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/hass/.homeassistant/custom_components/switch/zha_new.py", line 41
    pass
       ^
IndentationError: unindent does not match any outer indentation level
Yoda-x commented 6 years ago

Hi @walthowd the first error block is not severe and creates just logs, for the second please get the dev_switch branch. I had not looked into switches 2 weeks ago, and it seems there is an indent error. In the meantime I added switch support and for my switches its' working ok. The switch code now supports attribute reporting and polling of state.

you need to define a device config, when bellows can't detect the model from endpoint 1/cluster 0/attrib 4. For this case I added the template option: Eg the tradfri dimmable bulbs, they report themself as ZLL devices, but you need to talk ZHA to them. With this you have no change to get the manufacturer or model. Here you need to add the device config with the template. Where the template is a device specific python file. In the case of the Tradfri bulbs it just overrides the detected ZLL profile to a ZHA profil. With this the discovery identication is back on track. when the model is visible, device specific code is called to from templates/device_handlers, then you need no extra configuration entries. Can you send over the device information from bellows for your bulbs. That would be helpful.

walthowd commented 6 years ago

Switching to dev_switch branch, I receive this error on Home Assistant startup and the component never fully loads to allow light control.

2018-01-22 19:17:16 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 180, in _step result = coro.send(None) File "/Users/hass/.homeassistant/custom_components/zha_new.py", line 268, in async_device_initialized _custom_endpoint_init(endpoint,node_config,dev_func) UnboundLocalError: local variable '_custom_endpoint_init' referenced before assignment

I then tried manually assigning the default template, but same results:

zha_new:
  usb_path: /dev/tty.GoControl_zigbee
  database_path: /Users/hass/.homeassistant/zigbee.db
  device_config:
    "00:17:88:01:03:5d:32:c1":
      template: default
    "b0:ce:18:14:03:00:f1:7e":
      template: default

Attached is the output from my bellows devices. I'm particularity looking at b0:ce:18:14:03:00:f1:7e which is an Sengeld Element Plus that should support color_temperature. I'm also chasing the three full Philips Hue bulbs (00:17:88:01:02:88:ce:3f, 00:17:88:01:02:88:d3:8c and 00:17:88:01:02:e8:01:14) which randomly lose the ability to set the color temperature via the Home Assistant front end.

bellows-devices.txt

Yoda-x commented 6 years ago

I added better exception handling and added also debugging to the light component. you should not see the error anymore. The orginal code tries to get an attribute from the color control cluster. Based on the result it decides if it's an color bulb or a white-colortone bulb. Please update the dev_switch branch and try it again. Please have a look on the switch.zha_new logs You say, it works sometimes and sometimes not? Can you pin-point, when it fails? Maybe after a HA restart?

walthowd commented 6 years ago

I pulled the latest from your master bellows branch and the latest dev_switch branch of zha-new.

Seeing multiple errors logged at startup, zha never fully loads and doesn't create any entities.

Home Assistant log is attached.

home-assistant.log

Yoda-x commented 6 years ago

sorry, my badness. I forgot to push the changes to github. At least it should load now.

walthowd commented 6 years ago

Loading and working now, still not seeing color temperature being configurable from the HA frontend at times for my Phillips Hue bulbs, but that has been an issue in the original bellows/zha component too. I can submit some info to track that separately.

Thank you!

Yoda-x commented 6 years ago

@walthowd yes, please provide the debug logs for lights.zha_new and bellows for the initialization. thanks