How to manually configure an Aqara vibration sensor

Hello,

I need to configure on HA some Aqara vibration sensors connected to a Tasmota zbbridge.

I’m seeing that the messages sent on the MQTT topic are like:

21:12:30.115 MQT: tele/tasmota_zbbridge/SENSOR = {“ZbReceived”:{“0x6828”:{“Device”:“0x6828”,“AqaraVibrationMode”:“vibrate”,“Endpoint”:1,“LinkQuality”:97}}}

Where AqaraVibrationMode can be “vibrate”, “tilt” or “drop”
AFAIK, there’s not a message for a “normal” state (after the vibration ends): therefore I suppose that I have to automatically set a “normal” state after some (fixed) timeout.

How can I do this in configuration.yaml? Here is a sketch for the template: please can you help me to complete it?

  - platform: mqtt
    name: "vibration-1"
    state_topic: "tele/tasmota_zbbridge/SENSOR"
    value_template: '{{ value_json["ZbReceived"]["0x6828"]["AqaraVibrationMode"] }}'
    payload_on: ... how to put "vibrate" "tilt" or "drop" ?
    payload_off: ... how to automatically set it after timeout ?

Thanks!

Here is the solution:

 - platform: mqtt
    name: "vibrazione-1"
    off_delay: 15
    state_topic: "tele/tasmota_zbbridge/SENSOR"
    value_template: >
      {{ 'on' if value_json["ZbReceived"]["vibrazione-1"]["AqaraVibrationMode"] in
          ('vibrate', 'tilt', 'drop') else 'off' }}
    payload_on: 'on'
    device_class: window

Sorry if this is slightly off topic but is the Aqara vibration sensor sensitive? I’ve just got one and set it up with Zigbee2MQTT - I’ve set sensitivity to high but it only seems to pick anything up if I shake it…