Message malformed: required key not provided @ data[‘trigger’]

Hi guys

I am trying to do a notification automation when one of my smoke sensors fire.
I want the notification to include which sensor fired.

Below is my automation, but I get the following error - can anybody point in the right direction?


Message malformed: required key not provided @ data[‘trigger’]


description: ''
  - platform: state
      - binary_sensor.rogalarm_alrum_smoke_detected
      - binary_sensor.rogalarm_gang_smoke_detected
      - binary_sensor.rogalarm_garage_smoke_detected
      - binary_sensor.rogalarm_loft_smoke_detected
      - binary_sensor.rogalarm_stue_smoke_detected
    from: clear
    to: detected
    for: '0:00:30'
condition: []
  - scene: scene.udendors_taend
  - service: notify.mobile_app_thomas_telefon
      title: BRANDALARM!
      data: {}
      message: '{{ }}' har er detekteret røg!
  - service: notify.mobile_app_tines_telefon
      title: BRANDALARM!
      data: {}
      message: '{{ }}' har er detekteret røg!
mode: parallel
max: 10

Try putting quotes around the whole message e.g.

message: "{{ }} har er detekteret røg!"

In case it is of interest, I use alerts rather than automations for many of my noficiations e.g.

  name: "Battery Alert"
  title: "Information - Battery alert at {{ states('sensor.time') }}"
  message: "Check following equipment - {{ state_attr('binary_sensor.battery_alert', 'Below') }}"
    channel: Information
  entity_id: binary_sensor.battery_alert
  state: 'on'
  repeat: 1440
  can_acknowledge: true
  skip_first: true
    - mobile_app_sm_g970f

Have you checked the actual binary_sensor state in Developer Tools?

For motion: on means motion detected, off means no motion (clear)

Maybe you need to change clear to off and detected to on.

Thanks @Jonah1970 , that seemed to do the trick.

Nice info - where do you create alerts? (I’m rather new at HA :slight_smile: )

Aaaah! :slight_smile:
Just checked - based on the below input, I should actually state On/Off as trigger rather than clear/detected - correct?

Yes. Keep in mind that On and on is different. Make sure to always reference the one in Developer Tools.

1 Like

I have a separate alert.yaml file and the following command in my configuration.yaml to reference it:

alert: !include alert.yaml

Further info is available in the docs …

1 Like

Thank you very much @ardysusilo

Excellent, @Jonah1970 - I will take a look at it!

Thanks you for your input!