Multiple orientation sensors with Aqara DJT11LM

Hello,

Using ZHA, I configured the orientation sensors for an Aqara DJT11LM following the steps in this post (thanks, it was very helpful)

https://community.home-assistant.io/t/zha-aqara-vibration-sensor-djt11lm-missing-values-sensors/227757/11

Let me start by stating that I am not yet 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 the 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 overwriting the first sensor’s name. It was a pain to revert the changes; I think it was cached.

I thought it was related to the new sensor’s unique_id being the same when copying the configuration block, so I tried changing the unique_id by adding “_2”. Did not work.

Could 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? How must that section of configuration be for multiple sensors?

Many thanks

It would be helpful if you showed the code so we could see what you did wrong. There are multiple blocks and the indentation is important so “adding the same block” isn’t nearly descriptive enough.

Here’s an example for just the x-orientation for two different sensors:

template:
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device: 32digitcodeforfirstsensor
          command: 'current_orientation'
    sensor:
      - name: "Aqara Vibration Sensor Number 1 X Orientation"
        state: "{{ trigger.event.data.args.X }}"
        unique_id: aqara_vibration_sensor_x_orientation_1
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor2ndsensor
          command: 'current_orientation'
    sensor:
      - name: "Aqara Vibration Sensor Number 2 X Orientation"
        state: "{{ trigger.event.data.args.X }}"
        unique_id: aqara_vibration_sensor_x_orientation_2
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"

To add the other sensors (y orientation, drop, etc) don’t do anything with the trigger block. Just add a new name and other detail below each sensor: block.

Thank you. I had to travel and returned on Friday. I will look into it in detail this week and reply with the code I used.

I appreciate your reply.

Happy Holidays and a Prosperous New Year 2024.

Here is the code. Thanks!

  - trigger:
      - platform: event
        event_type: "zha_event"
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor1stsensor
          command: 'current_orientation'
    sensor:
      - name: "Room1 Sensor X Orientation"
        state: "{{ trigger.event.data.args.rawValueX }}"
        unique_id: aqara_vibration_sensor_x_orientation_room1
        state_class: measurement
        attributes: 
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Room1 Sensor Y Orientation"
        state: "{{ trigger.event.data.args.rawValueY }}"
        unique_id: aqara_vibration_sensor_y_orientation_room1
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Room1 Sensor Z Orientation"
        state: "{{ trigger.event.data.args.rawValueZ }}"
        unique_id: aqara_vibration_sensor_z_orientation_room1
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor1stsensor
          command: 'Drop'
    binary_sensor:
      - name: "Room1 Sensor Drop"
        state: "true" 
        unique_id: aqara_vibration_sensor_drop_room1
        auto_off: 5
        attributes: 
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor1stsensor
          command: 'Tilt'
    sensor:
      - name: "Room1 Sensor Tilt"
        state: "{{ trigger.event.data.args.degrees }}"
        unique_id: aqara_vibration_sensor_tilt_room1
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event" 
        event_data:
          device_id: 32digitcodefor1stsensor
          command: 'vibration_strength'
    sensor:
      - name: "Room1 Sensor Vibration Strength"
        state: "{{ trigger.event.data.args.strength }}"
        unique_id: aqara_vibration_sensor_vibration_strength_room1
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"

  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor2ndsensor
          command: 'current_orientation'
    sensor:
      - name: "Room2 Sensor X Orientation"
        state: "{{ trigger.event.data.args.rawValueX }}"
        unique_id: aqara_vibration_sensor_x_orientation_room2
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Room2 Sensor Y Orientation"
        state: "{{ trigger.event.data.args.rawValueY }}"
        unique_id: aqara_vibration_sensor_y_orientation_room2
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
      - name: "Room2 Sensor Z Orientation"
        state: "{{ trigger.event.data.args.rawValueZ }}"
        unique_id: aqara_vibration_sensor_z_orientation_room2
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor2ndsensor
          command: 'Drop'
    binary_sensor:
      - name: "Room2 Sensor Drop"
        state: "true"
        unique_id: aqara_vibration_sensor_drop_room2
        auto_off: 5
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor2ndsensor
          command: 'Tilt'
    sensor:
      - name: "Room2 Sensor Tilt"
        state: "{{ trigger.event.data.args.degrees }}"
        unique_id: aqara_vibration_sensor_tilt_room2
        state_class: measurement
        unit_of_measurement: "°"
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"
  - trigger:
      - platform: event
        event_type: "zha_event"
        event_data:
          device_id: 32digitcodefor2ndsensor
          command: 'vibration_strength'
    sensor:
      - name: "Room2 Sensor Vibration Strength"
        state: "{{ trigger.event.data.args.strength }}"
        unique_id: aqara_vibration_sensor_vibration_strength_room2
        state_class: measurement
        attributes:
          time_fired: "{{ trigger.event.time_fired }}"