Text helper not filled with name of the sensor

Hello,

When activated my alarm I fill in a helper (text) with the text “Sensor onbepaald” :

      - service: input_text.set_value
        data:
          value: Sensor onbepaald
        target:
          entity_id: input_text.text_sensor_die_alarm_activeert

When a sensor detects motion I do 2 things : setting a helper (boolean) on ‘on’ and filling the text helper with the name (and date/hour) of the sensor :

  - service: input_text.set_value
    data:
      value: >-
        Sensor gang op {{ as_timestamp( now() | as_local, 0)|    
        timestamp_custom('%d/%-m/%-Y ''om'' %H:%M:%S') }}
    target:
      entity_id: input_text.text_sensor_die_alarm_activeert
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.toggle_alarm_activeren

An automatisation based on that boolean gives the alarm :

trigger:
  - platform: state
    entity_id: input_boolean.toggle_alarm_activeren
    to: 'on'
condition: []
action:
  - service: notify.notification_devices
    data:
      message: >-
        INTRUDER ALERT! ({{ states('input_text.text_sensor_die_alarm_activeert')
        }}) !
      data:
        actions:
          - action: URI
            title: Camera's
            uri: /my-home/camera
          - action: DISABLE_ALARM_ONCE
            title: Vals Alarm ?
          - action: DISABLE_ALARM
            title: Alarm uit
...

Now, I get the alarm on my phone but the helper input_text.text_sensor_die_alarm_activeert is still on ‘Sensor onbepaald’…so I don’t know which sensor is causing the alarm.

What am I missing ?

change this template to

    Sensor gang op {{ now().strftime("%d/%-m/%-Y om %H:%M:%S") }}

Both versions work in the developer tools :

But the problem seems indeed this date/time format. When I just put simple text, then it shows up.

Your method doesn’t work because you have 3 strings in a row, it will result in errors. What I posted is a single format and it should work.

I did this :

action:
  - service: input_text.set_value
    data:
      value: Sensor gang op {{ now().strftime("%d/%-m/%-Y om %H:%M:%S") }}
    target:
      entity_id: input_text.text_sensor_die_alarm_activeert

In that case the textfield isn’t filled in at all.

With this it is filled (without date/time of course) :

action:
  - service: input_text.set_value
    data:
      value: Sensor gang op 
    target:
      entity_id: input_text.text_sensor_die_alarm_activeert

Now I was wondering if it is posible to use templates… ?

because you have to use multiline notation or wrap the template in quotes. Seeing that you have quotes in your template, you should have just done what you did before.

  - service: input_text.set_value
    data:
      value: >-
        Sensor gang op {{ now().strftime("%d/%-m/%-Y om %H:%M:%S") }}
    target:
      entity_id: input_text.text_sensor_die_alarm_activeert

Don’t shoot me, I found the problem : the length of my text helper was only 20 :pleading_face:

Thanks for helping me out of this !