Aqara door sensors entities not available in HA

Hi all,

I have bought two Aqarea door sensors the same type I have many others… It seems to behave just like the new leak sensors that I am losing the main entities in HA,

Some bits are missing from the newer model Cluster info

New sensor

Old Sensor

In HA I only get the battery and the temperature.
Sensor look like the same firmware version.

New sensor

Old sensor

Sensor looks ok in Phosocon
New sensor


Old sensor

Running on latest deconz release.

Anyone knows what needs to be done, I am afraid these new sensors have something different that do not match the ddf…

Do you get events in home assistant?

On the old sensor, the capture is empty (the capture from deconz) need to have the manufacture name and the model id to compare, and they have the same firmware.

They are not working on phoscon ? (all seem fine on your capture)

used the button to wake up both sensors to get full info.

New one

Old one

They work fine in phoscon.
It is the same with the leak sensors…

as I removed it and re-add it it appeared… I forgot to mention that I managed to do that once but then it was marked as unavailable after a while…

I’ll keep an eye on it and report back.

Best to report in home assistant support channels , because this is not something we can fix.

Hi @Mimiix I would have said is a issue with HA but the device looks different in Deconz. I have 20 others Aqara door sensors and all look the same and behave ok.
For now the entity seems to be there and did not vanished.
Thank you so much for all your support.

IF phoscon shows it correctly, it has nothing to do with the rest api. Because HA and phoscon use the same api.

HA restart and is gone :frowning: Odd is that is just the main sensor, temperature is OK… It is very similar with the leak sensors issue to me… In both cases temperature and battery are there but the main sensor is gone.

it shows ok in Phoscon…

I will check the deconz events when I have a chance.

this is how it shows up…

The problem is probably from the HA plugin.
It use the same API than phoscon, if it work on phoscon, need to work too in HA.

You can too check in phoscon/help/API Information to check if your sensors are here, but for me too, all is fine.

I think this error from HA logs is what is causing the entity not to be available

First occurred: September 16, 2023 at 19:28:38 (1 occurrences)
Last logged: September 16, 2023 at 19:28:38
Error while setting up deconz platform for binary_sensor

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 359, in _async_setup_platform
await asyncio.shield(task)
File “/usr/src/homeassistant/homeassistant/components/deconz/binary_sensor.py”, line 221, in async_setup_entry
gateway.register_platform_add_device_callback(
File “/usr/src/homeassistant/homeassistant/components/deconz/gateway.py”, line 182, in register_platform_add_device_callback
async_add_device(EventType.ADDED, device_id)
File “/usr/src/homeassistant/homeassistant/components/deconz/gateway.py”, line 172, in async_add_device
add_device_callback(EventType.ADDED, device_id)
File “/usr/src/homeassistant/homeassistant/components/deconz/binary_sensor.py”, line 216, in async_add_sensor
) or description.value_fn(sensor) is None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/deconz/binary_sensor.py”, line 129, in
value_fn=lambda device: device.open,
^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/pydeconz/models/sensor/open_close.py”, line 28, in open
return self.raw[“state”][“open”]
~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: ‘open’

I think indeed the Home assistant is responsible for this code and for whatever reason it fails.

If it doesn’t report the open state then the device is useless. It would be on deconz side in that case to make sure the device provides the expected properties.

How does the event emitted from deconz looks like?

I have tested the API

"181": {
    "config": {
        "battery": 100,
        "on": true,
        "reachable": true,
        "temperature": 2400
    },
    "ep": 1,
    "etag": "xxxxxxxxxxxxxxxxxx",
    "lastannounced": "2023-09-16T08:15:25Z",
    "lastseen": "2023-09-17T13:41Z",
    "manufacturername": "LUMI",
    "modelid": "lumi.sensor_magnet.aq2",
    "name": "Main Bathroom Door",
    "state": {
        "lastupdated": "2023-09-17T13:41:08.653",
        "open": true
    },
    "swversion": "0.0.0_0003",
    "type": "ZHAOpenClose",
    "uniqueid": "xxxxxxxxxxxxxxxxxx:02-01-0006"
}

This is an older

"18": {
    "config": {
        "battery": 100,
        "on": true,
        "reachable": true,
        "temperature": 2100
    },
    "ep": 1,
    "etag": "xxxxxxxxxxxxxxxxxxxxxxxx",
    "lastannounced": null,
    "lastseen": "2023-09-17T13:04Z",
    "manufacturername": "LUMI",
    "modelid": "lumi.sensor_magnet.aq2",
    "name": "Back Door",
    "state": {
        "lastupdated": "2023-06-27T17:56:57.622",
        "open": true
    },
    "swversion": "0.0.0_0003",
    "type": "ZHAOpenClose",
    "uniqueid": "xxxxxxxxxxxxxc2-01-0006"
}

The only difference I see is that the for sensors that are visible in HA
“lastannounced”: null
Does this ring any bells?

also the number generated does not make sense., it should have been 181 for both battery and temperature…

sorry to shoot so many updates but maybe some of them would make sense to an expert :slight_smile:

But on the DDF, the state/open is present

and both have it Aqara door sensors entities not available in HA - #15 by andys73

Can be a problem where deconz take to much time to fill the complete json ?

That’s fine, better to update as you investigate

Not used by HA

Can you share the event?

It can be found under help - api information .