ZHA & Aqara Vibration Sensor DJT11LM missing values/sensors

Hi,
I recently move from zigbee2mqtt to ZHA - works very well.

I have a question though, why ZHA doesn’t make available all the x, y, z, tilt/vibration/drop data that this sensor is able to provide (and which is available under zigbee2mqtt)… ?

Is there any way to get them, or any chance to have ZHA improved in order to get all data available by every supported zigbee devices ?

1 Like

Did you find a solution to this problem, I ran into this aswell

I’m using this sensors as part of an intruder alert and I found it works correclty under ZHA platform but only with tilt and/or drop event … still missing the vibration event.

- alias: Alarm
  trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: 'XX:XX:XX:XX:XX:XX:XX:XX'

as a workaround for vibration event i use this setup:

- alias: Alarm
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_vibration_sensor
    from: 'off'
    to: 'on'

…but it gives me also random triggering…
still dunno how to solvw this issue

Hello @MAurOsX have you found a solution for the random triggering?
I have also opened an issue Here Aqara Vibration Sensor DJT11LM False Trigger[BUG] · Issue #642 · zigpy/zha-device-handlers · GitHub

If you have found useful info regarding this…

I love how ZHA works and i hope we can find a solution because i have the Zigbee devices for alarm and in this way i can’t use… :frowning:

yep did it!
I switched to zigbee2mqtt + conbee2 cofig instead of ZHA integration / deCONZ integration and now I can manage tilt, drop and vibration, it’s also much more easier to set and read the sensitivity. …but most of all, I’ve had nolonger random triggering :slightly_smiling_face:

Thanks a lot for your reply.
Before the switch to ZHA i have zigbee2mqtt but i have many problmes (device disconnection, slow network, ecc)
Also ZHA is more simple because you don’t need to search everytime for the MQTT command

I hope someone could fix this.

Stefano

UPDATE!!
I have fixed this issue by removing this string:
before

            elif attrid == RECENT_ACTIVITY_LEVEL_ATTR:
                # these seem to be sent every minute when vibration is active
                self.endpoint.device.motion_bus.listener_event(MOTION_EVENT)

In this file:
/usr/local/lib/python3.8/site-packages/zhaquirks/xiaomi/aqara/vibration_aq1.py

Remeber to access at this file via portainer using homeassistant docker console!!!

Best Regards
Stefano

1 Like

@woodmoose or @Bartleby, did either of you ever find a solution to the original question of the missing attributes? I seems like this got off topic and the original issue never figured out.

Did you find this out?

I recently made a pull request for adding this functionality to ZHA where you can use an event to read the current orientation. I tested this using the garage of my dad where he’s using it to detect if the garage door is open or not. It works great for him.
Should hopefully be added to the next HA release.

When using ZHA, here are all the sensors that can be created based on anything issued on the zha_event topic, which seems to be the only way to create sensors for orientation, tilt, drop, and vibration strength when you don’t use the zigbee2mqtt integration:

template:
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitalphanumericcodegoeshere
          command: 'current_orientation'
    sensor:
      - name: "Aqara Vibration Sensor X Orientation"
        state: "{{ trigger.event.data.args.X }}"
        unique_id: aqara_vibration_sensor_x_orientation
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Aqara Vibration Sensor Y Orientation"
        state: "{{ trigger.event.data.args.Y }}"
        unique_id: aqara_vibration_sensor_y_orientation
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Aqara Vibration Sensor Z Orientation"
        state: "{{ trigger.event.data.args.Z }}"
        unique_id: aqara_vibration_sensor_z_orientation
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitalphanumericcodegoeshere
          command: 'Drop'
    binary_sensor:
      - name: "Aqara Vibration Sensor Drop"
        state: "true"
        unique_id: aqara_vibration_sensor_drop
        auto_off: 5
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitalphanumericcodegoeshere
          command: 'Tilt'
    sensor:
      - name: "Aqara Vibration Sensor Tilt"
        state: "{{ trigger.event.data.args.degrees }}"
        unique_id: aqara_vibration_sensor_tilt
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitalphanumericcodegoeshere
          command: 'vibration_strength'
    sensor:
      - name: "Aqara Vibration Sensor Vibration Strength"
        state: "{{ trigger.event.data.args.strength }}"
        unique_id: aqara_vibration_sensor_vibration_strength
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"

Edit: added state_class and unit_of_measurement where applicable, which affects how the frontend displays them.

1 Like

Very helpful - many thanks!
It helped me a lot to get lots of insights about the aqara vibration sensor.

It seems to have very different sensitivity for the mentioned events. e.g. strength is firing far more often than tilt and orientation

Hello,

First, thank you very much for this. It was very helpful.

Let me start by stating the obvious: I am not yet very proficient at independently changing files. I have primarily used the GUI. However, I can proficiently read and follow instructions.

I used the template to read the sensors (X, Y, Z, etc) as listed in your post. I substituted the Device ID and name, which worked like a charm.

When I tried to add a second sensor, adding the same block with a different device_id and name, it seemed that HA substituted the first entry with the new one and stopped working. Even after removing the second sensor, its name remained for the first sensor.

It was a pain to revert the changes, I think it was cached. Maybe because the new sensor has the same unique_id.

I also unsuccessfully tried to change the unique_id by adding “_2”.

Could you or someone please advise me on what additional changes I would need to make to add additional Aqara DJT11LM? What else do I need to change on top of device_id and name?

Many thanks

thanks rick but where do I put this code i’m new to home assistant is a file or somewhere in home assistant please can you help

template:

  • trigger:
    • platform: event
      event_type: “zha_event”
      event_data:
      device_id: 32digitalphanumericcodegoeshere
      command: ‘current_orientation’
      sensor:
    • name: “Aqara Vibration Sensor X Orientation”
      state: “{{ trigger.event.data.args.X }}”
      unique_id: aqara_vibration_sensor_x_orientation
      state_class: measurement
      unit_of_measurement: “°”
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”
    • name: “Aqara Vibration Sensor Y Orientation”
      state: “{{ trigger.event.data.args.Y }}”
      unique_id: aqara_vibration_sensor_y_orientation
      state_class: measurement
      unit_of_measurement: “°”
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”
    • name: “Aqara Vibration Sensor Z Orientation”
      state: “{{ trigger.event.data.args.Z }}”
      unique_id: aqara_vibration_sensor_z_orientation
      state_class: measurement
      unit_of_measurement: “°”
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”
  • trigger:
    • platform: event
      event_type: “zha_event”
      event_data:
      device_id: 32digitalphanumericcodegoeshere
      command: ‘Drop’
      binary_sensor:
    • name: “Aqara Vibration Sensor Drop”
      state: “true”
      unique_id: aqara_vibration_sensor_drop
      auto_off: 5
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”
  • trigger:
    • platform: event
      event_type: “zha_event”
      event_data:
      device_id: 32digitalphanumericcodegoeshere
      command: ‘Tilt’
      sensor:
    • name: “Aqara Vibration Sensor Tilt”
      state: “{{ trigger.event.data.args.degrees }}”
      unique_id: aqara_vibration_sensor_tilt
      state_class: measurement
      unit_of_measurement: “°”
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”
  • trigger:
    • platform: event
      event_type: “zha_event”
      event_data:
      device_id: 32digitalphanumericcodegoeshere
      command: ‘vibration_strength’
      sensor:
    • name: “Aqara Vibration Sensor Vibration Strength”
      state: “{{ trigger.event.data.args.strength }}”
      unique_id: aqara_vibration_sensor_vibration_strength
      state_class: measurement
      attributes:
      time_fired: “{{ trigger.event.time_fired }}”

If you need a second sensor, just duplicate the entire code block (triggers and sensors) and change the following in the duplicated code:

  • device_id in each trigger (this needs to match the device_id of your 2nd sensor)
  • name in each sensor (this should be different from your first sensor. You could add a “2” or call it whatever you want)
  • unique_id in each sensor (it just needs to be unique, you can add _2 or change it to jibberish or use a UUID)

It depends how you have home assistant configured. If you are new, you likely haven’t customized where to put various configuration files, and therefore everything is located in your configuration.yaml file in your config directory. See this page in the docs for further information.