Core: Aqara 小ube in HA via deCONZ component sends the same data.ids for rotation and, e.g., flipping or sliding

Created on 20 Apr 2019  路  18Comments  路  Source: home-assistant/core

Home Assistant release with the issue: 0.91.4

Last working Home Assistant release (if known): no

Operating environment (Hass.io/Docker/Windows/etc.): HASS.IO (not relevant)

Component/platform: deCONZ

Description of problem:
Aqara cube event.data.ids are the same for rotation and switching sides.
So event.data can be

{ 
  "id": "mi_aqara_cube",
  "event": 3003
}

for rotation to the right for 30.03 degrees (it is degrees, I guess)
or the same event.data can be if I double tapped the cube on the side 3.

Additional information:
Additional information can be found here.

deconz

All 18 comments

I don't know why this happens to some users or maybe sometimes happen they don't see it clearly(at least it happened to me at the beginning), but the event that reports the rotation has the id which is the name from phoscon which is used for rotation only, all other non-rotation events will be reported with a different id, like the default phoscon names like switch_27

This is my event listener from ha as i rotate first then flip

{
    "event_type": "deconz_event",
    "data": {
        "id": "switch_27",
        "event": 5003
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:37:02.225077+00:00",
    "context": {
        "id": "cdb8cde166cd4e41a72530f5ee79813c",
        "parent_id": null,
        "user_id": null
    }
}
Event 2 fired 4:36 PM:
{
    "event_type": "deconz_event",
    "data": {
        "id": "switch_27",
        "event": 3006
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:36:53.614895+00:00",
    "context": {
        "id": "9a6456bb729e428e9846a81263cffa9c",
        "parent_id": null,
        "user_id": null
    }
}
Event 1 fired 4:36 PM:
{
    "event_type": "deconz_event",
    "data": {
        "id": "cube_white",
        "event": 9653
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:36:46.443896+00:00",
    "context": {
        "id": "cb7a25f8750945c0a6075b7be307ecb4",
        "parent_id": null,
        "user_id": null
    }
}
Event 0 fired 4:36 PM:
{
    "event_type": "deconz_event",
    "data": {
        "id": "switch_27",
        "event": 7000
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:36:45.979415+00:00",
    "context": {
        "id": "8b30d13335e841879663d52368a3c9cf",
        "parent_id": null,
        "user_id": null
    }
}

So I have this:

Event 4 fired 9:43:
{
    "event_type": "deconz_event",
    "data": {
        "id": "mi_magic_cube",
        "event": 1004
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:43:29.083586+00:00",
    "context": {
        "id": "641895cae5a94f1298cc77ae2f4986ce",
        "parent_id": null,
        "user_id": null
    }
}
Event 3 fired 9:43:
{
    "event_type": "deconz_event",
    "data": {
        "id": "mi_magic_cube",
        "event": -577
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:43:27.296587+00:00",
    "context": {
        "id": "d428310987e2470390296d9ea8f45e62",
        "parent_id": null,
        "user_id": null
    }
}
Event 2 fired 9:43:
{
    "event_type": "deconz_event",
    "data": {
        "id": "mi_magic_cube",
        "event": -10525
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:43:26.841160+00:00",
    "context": {
        "id": "661061bde0194d70a8d60b9609dd9047",
        "parent_id": null,
        "user_id": null
    }
}
Event 1 fired 9:43:
{
    "event_type": "deconz_event",
    "data": {
        "id": "mi_magic_cube",
        "event": 9065
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:43:25.375532+00:00",
    "context": {
        "id": "fdcd6ef508c04b4eacb3d7d0935a548c",
        "parent_id": null,
        "user_id": null
    }
}
Event 0 fired 9:43:
{
    "event_type": "deconz_event",
    "data": {
        "id": "mi_magic_cube",
        "event": 4001
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-22T06:43:22.282504+00:00",
    "context": {
        "id": "c2d91bfbed4b411490d7c12a952f507a",
        "parent_id": null,
        "user_id": null
    }
}

Yeah, looks like a bug not sure if ha or deconz, the first and last ones are non-rotation from the event number ?

Have you checked the deconz websocket output to confirm is sending the same id?

Yes, the first and last ones above are turns from side to side. From 4th to 1st and back.
deCONZ websocket:

{"e":"changed","id":"26","r":"sensors","state":{"buttonevent":7000,"lastupdated":"2019-04-22T07:20:30"},"t":"event","uniqueid":"00:15:8d:00:02:76:ee:0d-02-0012"}
{"e":"changed","id":"10","r":"sensors","state":{"buttonevent":4440,"lastupdated":"2019-04-22T07:20:30"},"t":"event","uniqueid":"00:15:8d:00:02:76:ee:0d-03-000c"}
{"e":"changed","id":"10","r":"sensors","state":{"buttonevent":6462,"lastupdated":"2019-04-22T07:20:51"},"t":"event","uniqueid":"00:15:8d:00:02:76:ee:0d-03-000c"}
{"e":"changed","id":"26","r":"sensors","state":{"buttonevent":6005,"lastupdated":"2019-04-22T07:20:56"},"t":"event","uniqueid":"00:15:8d:00:02:76:ee:0d-02-0012"}
{"e":"changed","id":"26","r":"sensors","state":{"buttonevent":5006,"lastupdated":"2019-04-22T07:20:57"},"t":"event","uniqueid":"00:15:8d:00:02:76:ee:0d-02-0012"}

So no, different ids.
7000 for wakeup
4440 and 6462 are rotations
6005 and 5006 is for turn from side to side and back

You can try rename the cube in phoscon, see if that leaves the non-rotate actions with a different id. I've heard about this issue before in discord.
Clearly they are coming into home assistant with different id, and different uniqueid, so the event should have also different id.
I think i saw this from a user in discord before i received my conbee, but i didn't pay attention as later on when i received it , ha showed in the event bus two different id's

I renamed the cube in Phoscon, but no luck. Both event types (rotation and others) are there with new "aqara_cube" id.

I'm not sure I'm following what the real issue is here (I don't have a cube myself). Can you start by enabling debug for the component and find all instances of sensors related to the cube logged during startup?

@Kane610 Deconz (as you can see in the websocket connection log) is sending the digital (flip,shake, etc) and the analog (rotate) events with different id's, this is ok because is easy to filter by id, if you want to automate something by rotation or cube action.
The problem here for @fantomnotabene is that HASS is mapping the deconz event id 10 and 26 to one id "mi_magic_cube" so say he rotates the cube to 60.05(6005) degrees, it also means he has flipped the cube, which cannot be.

In my case the ha event log is showing two different id's which is good. But this is the second time i see this, someone in discord mentioned this in march, just reviewing his screenshots he had the same problem.

@fantomnotabene Have you tried removing the cube from deconz and repairing it?

@subzero79 no. But I just added the cube. 3 days before the issue.
Anyway, I'll try to remove and pair again today.

@Kane610 logs related to the Cube:

2019-04-23 07:30:31 DEBUG (MainThread) [pydeconz.deconzdevice] Aqara Cube created as 
{
  "_async_callbacks": [],
  "_battery": 98,
  "_buttonevent": 1177,
  "_deconz_id": "/sensors/10",
  "_ep": 3,
  "_etag": "030278fce054d54401b99a3d3dd6ba0d",
  "_lowbattery": None,
  "_manufacturername": "LUMI",
  "_modelid": "lumi.sensor_cube.aqgl01",
  "_name": "Aqara Cube",
  "_on": True,
  "_reachable": True,
  "_sensor_class": None,
  "_sensor_icon": None,
  "_sensor_unit": None,
  "_swversion": "20160704",
  "_tampered": None,
  "_type": "ZHASwitch",
  "_uniqueid": "00:15:8d:00:02:76:ee:0d-03-000c"
}
2019-04-23 07:30:31 DEBUG (MainThread) [pydeconz.deconzdevice] Aqara Cube created as 
{
  "_async_callbacks": [],
  "_battery": 98,
  "_buttonevent": 7000,
  "_deconz_id": "/sensors/26",
  "_ep": 2,
  "_etag": "66825eca97fb61aaa4fb7729dd304096",
  "_lowbattery": None,
  "_manufacturername": "LUMI",
  "_modelid": "lumi.sensor_cube.aqgl01",
  "_name": "Aqara Cube",
  "_on": True,
  "_reachable": True,
  "_sensor_class": None,
  "_sensor_icon": None,
  "_sensor_unit": None,
  "_swversion": None,
  "_tampered": None,
  "_type": "ZHASwitch",
  "_uniqueid": "00:15:8d:00:02:76:ee:0d-02-0012"
}

@subzero79 hooray! thank you!
Now I can differentiate rotation actions and others.

Event 1 fired 11:01:
{
    "event_type": "deconz_event",
    "data": {
        "id": "switch_29",
        "event": 5006
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-24T08:01:48.794092+00:00",
    "context": {
        "id": "2e8e2fcc6aae45f1bbb72b0dca48a973",
        "parent_id": null,
        "user_id": null
    }
}
Event 0 fired 11:01:
{
    "event_type": "deconz_event",
    "data": {
        "id": "switch_28",
        "event": 6265
    },
    "origin": "REMOTE",
    "time_fired": "2019-04-24T08:01:46.627313+00:00",
    "context": {
        "id": "833218d81375442f8a158b9dcbcb5781",
        "parent_id": null,
        "user_id": null
    }
}

But there is still something to fix somewhere in the component, I think.

Looking more into this I'd say it is up to each user how they want it. I've checked with other users and they are fine with how it is now, they have different names for their sensors. So the recommendation is to use different names from deCONZ. The deconz event in HASS only takes the name and it would be a big breaking change if that'd change

Just renamed cube from "Switch 28" to "Aqara Cube" in Phoscon and now it again in HA event log with one id "aqara_cube". Rotation and other actions.

@fantomnotabene you can rename them separately using the deconz service in hass

@Kane610 yeah! Thank you so much!
I renamed switch_34 (/sensor/34) to cube_rotation via deCONZ API and now it works as expected.
This _completely_ solves my problem.

Can can you please post the service data parameters for the call. Is not clear from the panel description neither the docs how to change the name.

@subzero79
Service data for deconz.configure:
小薪懈屑芯泻 褝泻褉邪薪邪 2019-04-26 胁 12 17 11
is

{
  "field": "/sensors/33", 
  "data": {
    "name": "cube"
  }
}

or just

{
  "name": "cube"
}

inside of PUT-request to http://<ip>:<port>/api/<api_key>/sensors/<id> if using deCONZ API directly.

Was this page helpful?
0 / 5 - 0 ratings