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

[BUG] WXKG01LM ZHA Integration #241

Closed
nickneos opened this issue Feb 6, 2021 · 4 comments
Closed

[BUG] WXKG01LM ZHA Integration #241

nickneos opened this issue Feb 6, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@nickneos
Copy link

nickneos commented Feb 6, 2021

Bug report

The WXKG01LM Aqara switch fires 3 events on a button press.

data["args"]["click_type"] is only in one of those events, resulting in the errors shown in log below.

Button still performs as expected, but the error shown in log should be handled by an exception (eg. by using try except in the relevant python function)

Additional information

  • Devices involved:
    • Model: WXKG01LM Light
  • Integration: ZHA
  • AppDaemon version: 4.0.5]
  • ControllerX version: 4.5.0
  • HACS version (if installed from there): 1.10.1
  • Home Assistant Core version: 2021.02

AppDaemon app configuration

aqara_study:
  module: controllerx
  class: WXKG01LMLightController
  controller: <redacted>
  integration: zha
  light: light.study

Logs

2021-02-06 10:42:17.181819 WARNING aqara_study: Worker Ags: {'id': '<redacted>', 'name': 'aqara_study', 'objectid': '<redacted>', 'type': 'event', 'event': 'zha_event', 'function': <bound method ZHAIntegration.callback of <cx_core.integration.zha.ZHAIntegration object at 0x7f3b26c9daf0>>, 'data': {'device_ieee': '<redacted>', 'unique_id': '<redacted>', 'device_id': '<redacted>', 'endpoint_id': 1, 'cluster_id': 6, 'command': 'attribute_updated', 'args': {'attribute_id': 0, 'attribute_name': 'on_off', 'value': False}}, 'pin_app': True, 'pin_thread': 12, 'kwargs': {'device_ieee': '<redacted>', '__thread_id': 'MainThread'}}
2021-02-06 10:42:17.182154 WARNING aqara_study: ------------------------------------------------------------
2021-02-06 10:42:17.182684 WARNING aqara_study: Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/appdaemon/threading.py", line 838, in async_worker
    await funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"]))
  File "/conf/apps/controllerx/cx_core/integration/zha.py", line 32, in callback
    action = self.controller.get_zha_action(data)
  File "/conf/apps/controllerx/cx_devices/aqara.py", line 114, in get_zha_action
    return data["args"]["click_type"]
KeyError: 'click_type'
@nickneos nickneos added the bug Something isn't working label Feb 6, 2021
@xaviml
Copy link
Owner

xaviml commented Feb 6, 2021

Hi @nickneos,

Thank you for sharing this information. I am double-checking the original ticket that provided the information about this controller (#94), and I see that the click_type is shown only when the command is click is that correct for single, double, triple, and quadruple?

If so, I will just parse actions where command is equal to click.

Thank you,
Xavi M

@nickneos
Copy link
Author

nickneos commented Feb 7, 2021

Yeah that sounds right.

Sharing event data below.

Single:

Event 0 fired 11:13 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "click",
        "args": {
            "click_type": "single"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:13:56.338932+00:00",
    "context": {
        "id": "2dd4f92cef570ab55d6ab9082a841da7",
        "parent_id": null,
        "user_id": null
    }
}

Event 1 fired 11:13 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": true
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:13:56.339053+00:00",
    "context": {
        "id": "ba6c96838aaa892247dd2b393f2257ea",
        "parent_id": null,
        "user_id": null
    }
}

Event 2 fired 11:13 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": false
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:13:56.618385+00:00",
    "context": {
        "id": "161692e79a0f12084f2240efdd6629fd",
        "parent_id": null,
        "user_id": null
    }
}

Double:

Event 3 fired 11:14 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "click",
        "args": {
            "click_type": "double"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:14:21.495338+00:00",
    "context": {
        "id": "3837bb34abc54963e3cf4f1fe836f0d3",
        "parent_id": null,
        "user_id": null
    }
}

Event 4 fired 11:14 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 32768,
            "attribute_name": "Unknown",
            "value": 2
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:14:21.495436+00:00",
    "context": {
        "id": "198825f58bc41c88aa9324dd9490b91a",
        "parent_id": null,
        "user_id": null
    }
}

Triple:


Event 5 fired 11:14 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "click",
        "args": {
            "click_type": "triple"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:14:44.849758+00:00",
    "context": {
        "id": "71ca1856f7471bcc950e89cd91e04534",
        "parent_id": null,
        "user_id": null
    }
}

Event 6 fired 11:14 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "",
        "unique_id": "",
        "device_id": "",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 32768,
            "attribute_name": "Unknown",
            "value": 3
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T12:14:44.849882+00:00",
    "context": {
        "id": "499f15566fca07e9b45ee074a485e19e",
        "parent_id": null,
        "user_id": null
    }
}

xaviml added a commit that referenced this issue Feb 7, 2021
@xaviml
Copy link
Owner

xaviml commented Feb 7, 2021

Hi @nickneos,

Fix is now in the dev branch. It will be available for the next release.

Thank you,
Xavi M.

@xaviml
Copy link
Owner

xaviml commented Feb 7, 2021

This has been fixed in ControllerX v4.6.0

@xaviml xaviml closed this as completed Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants