DJT11LM (Aqara Vibration Sensor) in Home Assistant

#1

Hi there!

Today I was trying to integrate a DJT11LM (Aqara Vibration Sensor) with Home Assistant, and I’m having some issues.

I was able to join it to Zigbee2MQTT, but the problem is that the sensor is reporting several actions in a quick row, so I’m not able to detect it using binary_sensor in Home Assistant.

This is an example of what’s returning in the logs:

zigbee2mqtt:info 5/5/2019, 3:01:44 PM MQTT publish: topic ‘zigbeePSup/vibracionDormLateral’, payload ‘{“linkquality”:70,“angle_x”:2,“angle_y”:-2,“angle_z”:87,“angle_x_absolute”:88,“angle_y_absolute”:92,“angle”:79,“battery”:100,“voltage”:3045,“last_seen”:“2019-05-05T15:01:44+00:00”,“elapsed”:423069,“action”:“vibration”}’
zigbee2mqtt:info 5/5/2019, 3:01:45 PM MQTT publish: topic ‘zigbeePSup/vibracionDormLateral’, payload ‘{“linkquality”:52,“angle_x”:2,“angle_y”:-2,“angle_z”:87,“angle_x_absolute”:88,“angle_y_absolute”:92,“angle”:173,“battery”:100,“voltage”:3045,“last_seen”:“2019-05-05T15:01:45+00:00”,“elapsed”:1135,“action”:“tilt”}’
zigbee2mqtt:info 5/5/2019, 3:01:45 PM MQTT publish: topic ‘zigbeePSup/vibracionDormLateral’, payload ‘{“linkquality”:55,“angle_x”:4,“angle_y”:-2,“angle_z”:-85,“angle_x_absolute”:86,“angle_y_absolute”:92,“angle”:173,“battery”:100,“voltage”:3045,“last_seen”:“2019-05-05T15:01:45+00:00”,“elapsed”:21}’

As you can see in the timing, it changes from vibration, to tilt, to nothing, in just 2 seconds.

I’m using a binary_sensor in HomeAssistant to get it:

- platform: "mqtt"
  name: "Vibracion Ventana Dormitorio Lateral"
  state_topic: "zigbeePSup/vibracionDormLateral"
  availability_topic: "zigbeePSup/bridge/state"
  payload_on: on
  payload_off: off
  value_template: 
    "{% if state_attr('value_json', 'action') %}
        on
    {% else %}
        off
    {% endif %}"
  device_class: "vibration"
  json_attributes_topic: "zigbeePSup/vibracionDormLateral"

I’ve tried several value_templates, and I’ve also tested it in HomeAssistant in the template, and my conclusion is that the action changes so fast that HomeAssistant is just not able to detect it.

Have somebody faced this? Any suggestion for the binary_sensor configuration?

Regards

1 Like