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

Xiaomi Mijia Wirelss Switch (Round) #94

Closed
Kanishkaz opened this issue Jul 7, 2020 · 5 comments
Closed

Xiaomi Mijia Wirelss Switch (Round) #94

Kanishkaz opened this issue Jul 7, 2020 · 5 comments
Assignees
Labels
new-device New device

Comments

@Kanishkaz
Copy link

Kanishkaz commented Jul 7, 2020

New Device Support

Device Information

  • Device Model: Mijia Wirelss Switch
  • Device Description: Xiaomi Mijia Smart Switch Round
  • Device Manufacturer: Xiaomi

Integrations

ZHA sends a click type for each event:
payload.event.args.click_type

Sample ZHA event:

{ "event_type": "zha_event", "data": { "device_ieee": "00:15:8d:00:01:9c:a4:2c", "unique_id": "00:15:8d:00:01:9c:a4:2c:1:0x0006", "endpoint_id": 1, "cluster_id": 6, "command": "click", "args": { "click_type": "single" } }, "origin": "LOCAL", "time_fired": "2020-07-07T09:18:52.457737+00:00", "context": { "id": "86e379662f6f4019a19512f08353f0d7", "parent_id": null, "user_id": null } }

Valid values for click_type:

  • "single"
  • "double"
  • "triple"
  • "quadruple"
  • "furious"

Integration: zha

Actions

Uses click_type attribute as mentioned above

  • single: Sent when button pressed once
  • double: Sent when button pressed twice
  • triple: Sent when button pressed 3 times
  • quadruple: Sent when button pressed 4 times
  • furious: Sent when button pressed multiple times in quick succession

Notes

ZHA currently does not implement a press and hold event for this button.

ZHA Quirk implementation: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/xiaomi/mija/sensor_switch.py

@xaviml
Copy link
Owner

xaviml commented Jul 9, 2020

Hi @Kanishkaz,

First of all, thank you for your request. As I understand the "command" is always click and what it changes is the click_type from args, right? ZHA events are very confusing and they are not standard. For example, z2m always sends a string with the action is taking, but ZHA sends this JSON where some devices specify the action in command and other in args. This is why issue #97 needs to be solved in order to integrate this controller.

I will integrate this controller and solve #97 for the next release.

Thank you,
Xavi M.

@Kanishkaz
Copy link
Author

Kanishkaz commented Jul 9, 2020

Thanks.

I just tested a single click and captured the events. It triggered the following 3 events. Hope that helps too. Please reach out if you need more log output.

Event 2 fired 11:11 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:01:d8:df:dc",
        "unique_id": "00:15:8d:00:01:d8:df:dc:1:0x0006",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": false
        }
    },
    "origin": "LOCAL",
    "time_fired": "2020-07-09T13:11:28.310748+00:00",
    "context": {
        "id": "c0cc387e55db4754be63a4b814d82167",
        "parent_id": null,
        "user_id": null
    }
}
Event 1 fired 11:11 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:01:d8:df:dc",
        "unique_id": "00:15:8d:00:01:d8:df:dc:1:0x0006",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": true
        }
    },
    "origin": "LOCAL",
    "time_fired": "2020-07-09T13:11:28.102705+00:00",
    "context": {
        "id": "ae17774a0fda4373bb27097f747cf9b9",
        "parent_id": null,
        "user_id": null
    }
}
Event 0 fired 11:11 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:01:d8:df:dc",
        "unique_id": "00:15:8d:00:01:d8:df:dc:1:0x0006",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "click",
        "args": {
            "click_type": "single"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2020-07-09T13:11:28.102375+00:00",
    "context": {
        "id": "353795c3d97942e9a2988c80c24e9dd6",
        "parent_id": null,
        "user_id": null
    }
}

@Kanishkaz
Copy link
Author

Out of curiosity, what Zigbee integration are you using with HA?

xaviml added a commit that referenced this issue Jul 11, 2020
@xaviml
Copy link
Owner

xaviml commented Jul 11, 2020

Out of curiosity, what Zigbee integration are you using with HA?

I am currently using zigbee2mqtt and deconz at the same time. I have it like so I can test easily with both integrations.

I have now pushed the code to support ZHA for this device. Now ZHA integrations will be easier since a specific parse can be done for each device since ZHA devices are all different when it comes to firing the events. I will let you know once this is released. Thank you :)

@xaviml
Copy link
Owner

xaviml commented Jul 12, 2020

The integration for this device has been added in ControllerX v3.2.0. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-device New device
Projects
None yet
Development

No branches or pull requests

2 participants