Template_value as trigger

Hello! I tried to trigger an MQTT topic with a template (sensor):

part of my templates.yaml and automation below.

What is the mistake? Could anyone help me?

sensor:
  - name: "NetzbezugABC"
    unique_id: xxx
    unit_of_measurement: "W"
    device_class: power
    state: >
      {{ [ states('sensor.shellyem3_xxx_channel_a_power'),
           states('sensor.shellyem3_xxx_channel_b_power'),
           states('sensor.shellyem3_xxx_channel_c_power') ]
           | map('float') | sum }}

Automation:

alias: Wallbox_max_Strom_5min
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.netzbezugabc
    for:
      hours: 0
      minutes: 1
      seconds: 0
    below: 16000
condition: []
action:
  - service: mqtt.publish
    data:
      topic: warp2/xxx/evse/external_current
      payload: "{\\\"current\\\": 16000}"
mode: single
template: 
  - sensor:
      - name: "NetzbezugABC"
        unique_id: xxx
        unit_of_measurement: "W"
        device_class: power
        state: >
          {{ [ states('sensor.shellyem3_xxx_channel_a_power'),
               states('sensor.shellyem3_xxx_channel_b_power'),
               states('sensor.shellyem3_xxx_channel_c_power') ]
             | map('float') | sum }}

Reference: Template Sensor

Thanks for your Response.
Unfortunately this doesn’t work either…
Any other ideas?

Where have you put that YAML? It should either be in configuration.yaml at the top level or under a !include for template:. It should not be under a top-level sensor:.

If your Shelly sensors are returning numbers (strictly, strings that look like numbers), that sensor definition is good.

Note that your automation trigger will only fire if the sensor output changes from above 16000 to below 16000.

When you say “doesn’t work”, what’s not working? Can you see the sensor state under Developer Tools / States? Does the automation do what you want if you manually execute it?

I’ve tried both. in the configuration.yaml and with
template: !include templates.yaml

I changed the value (16000) to see, whether the automation triggers. but she doesn’t.
Manually execution works fine.

Under developer - Conditions - i can see the addition of the three Shelly sensors

When I trigger “change” with this entity and then give below: 16000 as a condition, it works. but then I can’t enter a period of time for which the condition must be fulfilled

As an experiment, try this version. Test it by going to Developer Tools States, selecting sensor.netzbezugabc, change its state value and click the Set State button. That should be sufficient to trigger the automation and produce a notification containing the current time and sensor’s new value.

alias: Wallbox_test
description: ""
trigger:
  - platform: state
    entity_id: sensor.netzbezugabc
condition: []
action:
  - service: notify.persistent_notification
    data:
      title: "{{ now().timestamp() | timestamp_custom }}"
      message: "{{ trigger.to_state.state }}"
mode: single

If it fails to work then there may be something wrong with the configuration of the sensor.netzbezugabc.

I don’t really undestand what to do… i copied your script to “Entwicklerwerkzeuge”, “Zustände”.
Entität: netzbezugabc
Statusattribute
in this field the script
and Status setzen
Nothing happens aftes this. Where can I see this notification?
Below I can see the realtime status of the entity with changes every few seconds.

In the logfile i can see the actual value and a time stamp

The example I posted is an automation, not a script.

Sorry but I don’t understand the language you’re using so the rest of your post is unclear to me.