Notify Error executing script. Invalid data for call_service

# Aussentemperatur Notify
.....
  action:
    - service: notify.mobile_app_xxx
      data:
        message: " {{ states.sensor.0x00158d00023cfb3a_temperature.state }} "
        title: "Temperatur"

or this on

action:
    - service: notify.mobile_app_xxx
      data:
        message: " {{ states(sensor.0x00158d00023cfb3a_temperature) }} "
        title: "Temperatur"

what am I doing wrong, i read out the aqara temp sensor with zigbee2mqtt

sensor.0x00158d00023cfb3a_temperature

battery: 97
voltage: 2995
temperature: 23.69
humidity: 60.64
pressure: 944.4
linkquality: 141
unit_of_measurement: °C
friendly_name: aqara_temp_outside_temperature
device_class: temperature

Protokolldetails ( ERROR )

Logger: homeassistant.components.automation
Source: helpers/script.py:188
Integration: Automatisierung (documentation, issues)
First occurred: 20:08:14 (1 occurrences)
Last logged: 20:08:14

Aussentemperatur Notify: Error executing script. Invalid data for call_service at pos 1: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘x00158d00023cfb3a_temperature’) for dictionary value @ data[‘message’]

I think data: needs to be data_template:

1 Like

Correct. Also, missing quotes for the second (and preferable) template version:

message: "{{ states('sensor.0x00158d00023cfb3a_temperature') }}"

data_template

and

message: "{{ states(‘sensor.0x00158d00023cfb3a_temperature’) }}"

together we agreed on it, great now it works … many thanks for the help