Yoda-x / ha-zha-new

update of the zha component
56 stars 10 forks source link

Osram Lightify dimming switch is not working #26

Closed Adminiuga closed 6 years ago

Adminiuga commented 6 years ago

Hi, I'm trying to get an Osram lightify dimming switch working with zha_new, but currently I have no luck with it. Getting the following errors in the log file:

2018-04-20 19:51:33 ERROR (MainThread) [homeassistant.helpers.entity] Update for
Traceback (most recent call last):
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 160, in __get
    return self._cluster_attr[name]
KeyError: 'on_off'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 204, in async_
    yield from self.async_device_update()
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 325, in async_
    yield from self.async_update()
  File "/home/lex/.ha-dev/custom_components/switch/zha_new.py", line 79, in asyn
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __get
    raise AttributeError
AttributeError
2018-04-20 19:51:33 INFO (MainThread) [homeassistant.core] Bus:Handling <Event s
ha_new.py, exception=Traceback (most recent call last):
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 160, in __get
    return self._cluster_attr[name]
KeyError: 'on_off'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 204, in async_
    yield from self.async_device_update()
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 325, in async_
    yield from self.async_update()
  File "/home/lex/.ha-dev/custom_components/switch/zha_new.py", line 79, in asyn
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __get
    raise AttributeError
AttributeError
, timestamp=1524268293.4580781, level=ERROR, message=Update for switch.osram_lig
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __getattr__
    raise AttributeError
AttributeError
2018-04-20 19:51:33 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: source=custom_components/s
ha_new.py, exception=Traceback (most recent call last):
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 160, in __getattr__
    return self._cluster_attr[name]
KeyError: 'on_off'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/home/lex/.ha-dev/custom_components/switch/zha_new.py", line 79, in async_update
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __getattr__
    raise AttributeError
AttributeError
, timestamp=1524268293.4580781, level=ERROR, message=Update for switch.osram_lightify_dimming_switch_00e911f1_1 fails>
2018-04-20 19:52:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: new_state=<state sensor.time_
9:52, 2018-04-20; icon=mdi:calendar-clock, friendly_name=Time & Date @ 2018-04-20T19:52:00.457512-04:00>, old_state=<state sen
e__date=19:51, 2018-04-20; icon=mdi:calendar-clock, friendly_name=Time & Date @ 2018-04-20T19:51:01.456639-04:00>, entity_id=s
ime__date>
2018-04-20 19:52:04 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.osram_lightify_dimming_switch_00e911f1

Traceback (most recent call last):
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 160, in __getattr__
    return self._cluster_attr[name]
KeyError: 'on_off'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/home/lex/.ha-dev/custom_components/switch/zha_new.py", line 79, in async_update
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __getattr__
    raise AttributeError
AttributeError
2018-04-20 19:52:04 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: source=custom_components/s
ha_new.py, exception=Traceback (most recent call last):
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 160, in __getattr__
    return self._cluster_attr[name]
KeyError: 'on_off'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/home/lex/rcl-hass/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/home/lex/.ha-dev/custom_components/switch/zha_new.py", line 79, in async_update
    v = yield from self._endpoint.on_off.read_attributes(
  File "/home/lex/rcl-hass/venv/src/zigpy/zigpy/endpoint.py", line 162, in __getattr__
    raise AttributeError
AttributeError
, timestamp=1524268324.4576075, level=ERROR, message=Update for switch.osram_lightify_dimming_switch_00e911f1_1 fails>

And here's output for bellows devices

Device:
  NWK: 0xf723
  IEEE: 84:18:26:00:00:e9:11:f1
  Endpoints:
    1: profile=0x104, device_type=DeviceType.LEVEL_CONTROL_SWITCH
      Input Clusters:
        Basic (0)
        Power Configuration (1)
        Identify (3)
        Poll Control (32)
        Temperature Measurement (1026)
        IAS Zone (1280)
        Diagnostic (2821)
      Output Clusters:
        Identify (3)
        On/Off (6)
        Level control (8)
        Ota (25)

I have added the following to zha_new config section and switch appeared in HA, but can't get state or level

database_path: /home/lex/.ha-dev/zigbee.db
device_config:
  "84:18:26:00:00:e9:11:f1-1":
    type: switch

I'm noticing that it misses On/Off input cluster, which makes sense since this is just a switch so it has it in the output clusters. I know to get this working with zha, i had to get this Pull Request #12528

Yoda-x commented 6 years ago

right, you mentioned the problem already your self. I checked thie pull request and it looks quite interesting. I will put in on my list. I'm currently working on the group functionality inside bellows and zha, thus, it may take some time, but I think groups will enable also many other switches (tradfri, GE) that send commands over multicast and not direct to the controller, and which are currently not working with this patch.
Stay tuned

Yoda-x commented 6 years ago

BTW, how you expect the switch to work?

  1. sending events upstream to HA, where you can script actions?

    • having a virtual switch device, with on/off state, brightness/color-temp level, Where you can copy the virtual switch on/off state, brightness level to a group of bulbs/devices? Triggering actions on device_update events.
  2. 1+2 , makes the most sense for me, as it provide all options

Thanks Arno

jarocks commented 6 years ago

Having both the states and events is definitely the best way to go.

Also as a side-note, I couldn't get dimming to work properly with this pull request.

Adminiuga commented 6 years ago

Yes, I can confirm the dimming is broken with this PR. It's using wrong command Id and is interpreting "move" command as "move to level". And currently it moves only once for each long press. and currently it is somewhat "progressive" level change.

I'm working on some me fixes (to original PR) and making some progress.

On Fri, Apr 27, 2018, 13:42 Joey Averett notifications@github.com wrote:

Having the states and events is definitely the best way to go.

Also as a side-note, I couldn't get dimming to work properly with this pull request.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Yoda-x/ha-zha-new/issues/26#issuecomment-385043045, or mute the thread https://github.com/notifications/unsubscribe-auth/AFjmcMSaDHcWFA4uixoI_JF1dOyo616Rks5ts1h4gaJpZM4TeOkf .

Yoda-x commented 6 years ago

I'm almost done with the implementation, Sending events upstream is a very simple. creating the 'virtual' devices is a little bit more tricky as I need to go through the different cases, like what's happens during a long press. As i have only the tradfri remotes and dimmers, it may also need some adjustments. I will push out a new master soon.

Adminiuga commented 6 years ago

Specifically to OSRAM Dimming switch, when you make a Long press on the down side, it sends command MOVE (0x01) on the LevelCluster. Which should continue moving the level until command STOP (0x03) is received upon button release.

When you long press the "up side", then it sends MOVE_WITH_ON_OFF command (0x05), so level should keep moving until STOP or STOP_WITH_ON_OFF is received.

(My attempt at implementation)[https://community.home-assistant.io/t/zha-zigbee-tested-devices-please-add-your-device-results/17718/330?u=quatuor] Need some more working, as I'd like to have somewhat exponential level change, the longer button is pressed, the quicker level changes. Currently the above implementation has a bug, as it doesn't handle properly step commands. The 45857GE switch I have, sends steps commands when it turns on/off from the switch.

Yoda-x commented 6 years ago

I added support for remotes. please have a look and comment

Adminiuga commented 6 years ago

I'm not sure what i'm doing wrong, but I can't get the devices to show up. So this is a fresh installation of HASS 0.69 and I pulled latest bellows & zigpy from your repo. I'm starting hass with "--skip-pip". Removed the zigbee.db file and rejoined devices again. I do get devices in bellows devices

Device:
  NWK: 0xb235
  IEEE: 84:18:26:00:00:e9:11:f1
  Endpoints:
    1: profile=0x104, device_type=DeviceType.LEVEL_CONTROL_SWITCH
      Input Clusters:
        Basic (0)
        Power Configuration (1)
        Identify (3)
        Poll Control (32)
        Temperature Measurement (1026)
        Diagnostic (2821)
      Output Clusters:
        Identify (3)
        On/Off (6)
        Level control (8)
        Ota (25)
Device:
  NWK: 0x6f78
  IEEE: 00:0b:57:ff:fe:97:95:52
  Endpoints:
    1: profile=0xc05e, device_type=DeviceType.ON_OFF_SENSOR
      Input Clusters:
        Basic (0)
        Power Configuration (1)
        Identify (3)
        Alarms (9)
        Diagnostic (2821)
        LightLink (4096)
      Output Clusters:
        Identify (3)
        Groups (4)
        On/Off (6)
        Ota (25)
        LightLink (4096)
Device:
  NWK: 0x402e
  IEEE: 00:22:a3:00:00:1b:94:bb
  Endpoints:
    1: profile=0x104, device_type=DeviceType.DIMMABLE_LIGHT
      Input Clusters:
        Basic (0)
        Identify (3)
        Groups (4)
        Scenes (5)
        On/Off (6)
        Level control (8)
        Metering (1794)
        Diagnostic (2821)
      Output Clusters:
        Time (10)
        Ota (25)
    2: profile=0x104, device_type=DeviceType.DIMMER_SWITCH
      Input Clusters:
        Basic (0)
        Identify (3)
        Diagnostic (2821)
      Output Clusters:
        Identify (3)
        On/Off (6)
        Level control (8)

but in hass log i'm getting the following errors upon device joining the network:

2018-05-12 19:25:59 INFO (MainThread) [homeassistant.core] Bus:Handling <Event s
tate_changed[L]: new_state=<state zha_new.controller=Joined 00:22:a3:00:00:1b:94
:bb; friendly_name=Controller, neighborCount=2, no_devices=0 @ 2018-05-12T19:25:
59.292592-04:00>, entity_id=zha_new.controller, old_state=<state zha_new.control
ler=Permit; friendly_name=Controller, neighborCount=2, no_devices=0 @ 2018-05-12
T19:25:07.814382-04:00>>
2018-05-12 19:25:59 INFO (MainThread) [zigpy.device] [0x402e] Discovering endpoi
nts
2018-05-12 19:25:59 INFO (MainThread) [zigpy.device] [0x402e] Discovered endpoin
ts: [1, 2]
2018-05-12 19:25:59 INFO (MainThread) [zigpy.endpoint] [0x402e:1] Discovering en
dpoint information
2018-05-12 19:25:59 INFO (MainThread) [zigpy.endpoint] [0x402e:1] Discovered end
point information: <SimpleDescriptor endpoint=1 profile=260 device_type=257 devi
ce_version=0 input_clusters=[0, 3, 4, 5, 6, 8, 2821, 1794] output_clusters=[10,
25]>
2018-05-12 19:25:59 INFO (MainThread) [zigpy.endpoint] [0x402e:2] Discovering en
dpoint information
2018-05-12 19:25:59 INFO (MainThread) [zigpy.endpoint] [0x402e:2] Discovered end
point information: <SimpleDescriptor endpoint=2 profile=260 device_type=260 devi
ce_version=0 input_clusters=[0, 3, 2821] output_clusters=[3, 6, 8]>
2018-05-12 19:25:59 INFO (MainThread) [homeassistant.core] Bus:Handling <Event s
tate_changed[L]: new_state=<state zha_new.controller=Device init 00:22:a3:00:00:
1b:94:bb; friendly_name=Controller, neighborCount=2, no_devices=0 @ 2018-05-12T1
9:25:59.615075-04:00>, entity_id=zha_new.controller, old_state=<state zha_new.co
ntroller=Joined 00:22:a3:00:00:1b:94:bb; friendly_name=Controller, neighborCount
=2, no_devices=0 @ 2018-05-12T19:25:59.292592-04:00>>
2018-05-12 19:25:59 ERROR (MainThread) [homeassistant.core] Error doing job: Tas
k exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/lex/.ha-dev/custom_components/zha_new.py", line 449, in async_devi
ce_initialized
    for report in node_config.get(CONF_CONFIG_REPORT):
TypeError: 'NoneType' object is not iterable
2018-05-12 19:25:59 DEBUG (MainThread) [zigpy.zdo] [0x402e:zdo] ZDO request 0x00
13: [16430, 00:22:a3:00:00:1b:94:bb, 142]
2018-05-12 19:26:01 INFO (MainThread) [homeassistant.core] Bus:Handling <Event s
tate_changed[L]: new_state=<state sensor.time__date=19:26, 2018-05-12; icon=mdi:
calendar-clock, friendly_name=Time & Date @ 2018-05-12T19:26:01.288250-04:00>, e
ntity_id=sensor.time__date, old_state=<state sensor.time__date=19:25, 2018-05-12
; icon=mdi:calendar-clock, friendly_name=Time & Date @ 2018-05-12T19:25:01.28745
9-04:00>>

any ideas?

Adminiuga commented 6 years ago

How do I configure reporting in yaml? Should we really configure reporting here? I think I like idea of letting the entity to configure reporting itself, when it is added for the 1st time.

            # if reporting is configured in yaml,
            # then create cluster if needed and setup reporting
            if join:
#                if CONF_CONFIG_REPORT in node_config:
                for report in node_config.get(CONF_CONFIG_REPORT):
                    report_cls, report_attr, report_min, report_max, report_chan...
Adminiuga commented 6 years ago

BTW, unrelated, but something happened with the latest zigpy/bellows and "polled lights" component. When I try to switch light off, it immediately switches on in the web UI (the actual light turns off). have same behavior with zha_new and original zha. changing should_poll to False for lights, fixes this issue.

is it just me or anyone else?

Yoda-x commented 6 years ago

hi, congrats, you found another bug (the traceback).

OK, not sure if I understand the problem: your start with light on in the webui and bulb, then you click off in the webui and the lights go off, but the webui switches back to on ? I have this only when changing brightness with the slider, then it jumps back to the previous value and after a few seconds it jumps back to the correct value

see configuration for configuration options inside the yaml. But I dont think reporting is needed, because most of the clusters are output clusters

Adminiuga commented 6 years ago

@Yoda-x The device 0x402e is a 45857GE Dimmable wall switch from GE and yes, it has two endpoints. The 1st one is pretty behaves like a dimmable light. The 2nd endpoint behaves pretty much as a regular dimmable remote control.

OK, not sure if I understand the problem: your start with light on in the webui and bulb, then you click off in the webui and the lights go off, but the webui switches back to on ? I have this only when changing brightness with the slider

yep, that's pretty much what's happening and i'm getting same behavior as you when using the dimmig slider. I drop it, but it goes back to a previous position. Let me do some more testing and I'll open another issue if needed.

Adminiuga commented 6 years ago

@Yoda-x about the brightness slider jumping back, or the light on/off jumping into old position. I think this could be explained by attribute cache expiration which also would explain a few other issues I was seeing.