ZHA_event trigger data arg to template sensor

Trying to make a sensor out of a ZHA_event arg

It’s for an Aqara vibration sensor

The event:

event_type: zha_event
data:
  device_ieee: 00:15:8d:00:02:b7:a2:d7
  unique_id: 00:15:8d:00:02:b7:a2:d7:1:0x0500
  device_id: a3fe4eb7b7facfb392286af39e140f35
  endpoint_id: 1
  cluster_id: 1280
  command: current_orientation
  args:
    rawValueX: 905
    rawValueY: 65344
    rawValueZ: 576
    X: 1
    "Y": 89
    Z: 1
  params: {}
origin: LOCAL
time_fired: "2022-09-10T13:11:31.312986+00:00"
context:
  id: 01GCKRDN7GTPA0FS36N0D5H4BH
  parent_id: null
  user_id: null

Tried a lot of variations but none worked

template:
  - trigger:
      - platform: event
        event_type: zha_event
        event_data:
          device_id: a3fe4eb7b7facfb392286af39e140f35
          command: current_orientation

    sensor:
      - unique_id: testbid
        state: "{{ trigger.event.data.args[0] }}"
      - unique_id: testbid2
        state: "{{ trigger.event.data.args.0.rawValueZ | int }}"

State of the sensors remain Unknown instead of getting the corresponding values.

Already spent a whole day on this, thought I try to ask for help.

1 Like