How can I fix it: extra keys not allowed @ data['data_template']

" isnt working. It says invalid json. So I have used ‘’. But it says Fehler beim Aufrufen des Service persistent_notification/create. invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data[‘message’]
call service test

{
“message”: “{{ now().strftime(‘’%d.%m.%Y %H:%M:%S’') }}”,
“title”: “{{ now().strftime(‘’%d.%m.%Y %H:%M:%S’') }}”,
“notification_id”: “wdfiregoj”
}

ive entered this, and the result is ok:

had to correct some fancy quotes to straight quotes

copy this and you should be good:

    - service: persistent_notification.create
      data_template:
        title: 'System message: {{ trigger.to_state.name }} offline!'
        message: >
          {{ as_timestamp(now()) | timestamp_custom('%X') }}:
          {{ trigger.to_state.name }} has gone offline. Check status to restore functionality.
        notification_id: >
          {{trigger.to_state.name}}-hub-notification

of course this is a format, change to your liking

2019-05-14 18:03:46 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: ‘trigger’ is undefined

I have Hassio 0.92.2 installed

Please explain how you are triggering this automation. How are you making sensor.higrow_battery fall below 3.00 for 3 seconds?

you’re supposed to get that error if you test the automation manually in dev-template or dev-service, since the trigger isnt set in the trigger section of the automation.

that only happens in real life.

Thats why I suggested you take out the trigger templates everywhere in the action part, so we can test if the rest is ok… unless you do that, we can’t help you.

only thing we might check is wether the triggering entity is correct, so maybe show us the sensor in dev-state with a screenshot to see the state and attributes.

The plant sensor publishes every second(for testing) the value after 20 publishes it will go to deep sleep for 40 Minutes. The mqtt sensor is working fine. But I want a good automation: I want one automation for ca. 20 sensors

- platform: mqtt
  name: "HiGrow Battery"
  state_topic: "homeassistant/HiGrow/battery"
  unit_of_measurement: "V"
  qos: 0
- platform: template
  sensors:
     higrow_battery_state:
       value_template: "{{ 'Geladen' if states.sensor.higrow_battery.state | float >3.0  else 'Leer' }}"
       icon_template: "{{ 'mdi:battery' if states.sensor.higrow_battery.state | float >3.0  else 'mdi:battery-10' }}"

The automation runs if the voltage drops. What I have to edit Mariusthvdb With what I have to replace the trigger? Thanks

anything you like really, since it is merely for testing purposes…

replace each {{ trigger.to_state.attributes.friendly_name }} with Higrow sensor
if you do so, the trigger is no longer needed in the action bit, and we can see if the rest is ok

as said, go to dev-state, and show us the sensor

btw, you can also use this template for the sensor itself, you dont need the 3.0, which makes life easier…

sensors:
     higrow_battery_state:
       value_template: >
         {{ 'Geladen' if states('sensor.higrow_battery') | float > 3  else 'Leer' }}
       icon_template:  >
         {{ 'mdi:battery' if states('sensor.higrow_battery') | float > 3  else 'mdi:battery-10' }}


That isnt working

it has a wrong quote, as I warned you before.

but why are you testing that? you should be testing your own automation.

With replacing that its working but I have to comment out tag, because I have got this error:
Invalid data for call_service at pos 1: extra keys not allowed @ data[‘tag’]
json:
https://hastebin.com/cijulunedi.pl

{{ trigger.to_state.attributes.friendly_name }} or {{ trigger.entity_id.attributes.friendly_name }}
wont work

yes, wondered about that ‘tag’, never had that before…

what were you expecting that to do?

also, what does the conditional template test for. What is ‘nan’, and have you ever seen that happen? iow, could it be this is an incorrect template?

lastly about the triggers:

you might have better luck with {{ trigger.to_state.attributes.name }}, since I dont recall you posting a customization with friendly_name, and it cant be set in the template_sensor itself.

If it coudnt get any voltage it goes to nan

Hey guys! Anyone can help me with this, in latest versions of HA, were made breaking changes in templating, and I get not correctly a this thing: data_template with data, how I can fix it?

  action:
    service: notify.telegram
    data_template:
      message: "\U0001F4DE Intercom call {% if is_state('switch.intercom_automatically_open', 'on') or is_state('switch.intercom_automatically_open_once', 'on') %}(auto opens){% endif %}"
      data:
        inline_keyboard:
          - "{{ '0' if is_state('switch.intercom_automatically_open', 'on') or is_state('switch.intercom_automatically_open_once', 'on') else 'Open:/intercom_open, Cancel:/intercom_reject' }}"

Everything worked like a charm, but in the latest versions of HA I ran into a problem:


[13985834342246225824] extra keys not allowed @ data['data_template']

Solved by:

- "{{ '-' if is_state('switch.intercom_automatically_open', 'on') or is_state('switch.intercom_automatically_open_once', 'on') else 'Open:/intercom_open, Cancel:/intercom_reject' }}"