Problems with messages with sum of states

My actual code are:

alias: Sprachansage Fahrt Abfahrt im Geschäft (statisch)
description: ''
trigger:
  - platform: state
    entity_id:
      - person.manuel
    from: Brütsch/Rüegger
    to: not_home
condition: []
action:
  - service: script.alexa_sprachausgabe_eg_komlett
    data:
      message: >-
        Ich fahre jetzt im Geschäft los. Geschätzte Ankunftszeit  {{
        (now()|as_timestamp + (25*60))|timestamp_custom("%H:%M", True) }} Uhr
      type: announce
  - service: notify.telegram_familie
    data:
      title: Info!
      message: >-
        Ich fahre jetzt im Geschäft los. Geschätzte Ankunftszeit  {{
        (now()|as_timestamp + (25*60))|timestamp_custom("%H:%M", True) }} Uhr
mode: single

Now I would like to replace this part:

(25*60)

with

 +  float(states('sensor.fahrt_1'))  +
    float(states('sensor.fahrt_2'))  +
    float(states('sensor.fahrt_3'))  +
    float(states('sensor.fahrt_4')) 

I have try so:

alias: Sprachansage Fahrt Abfahrt im Geschäft
description: ''
trigger:
  - platform: state
    entity_id:
      - person.manuel
    from: Brütsch/Rüegger
    to: not_home
condition: []
action:
  - service: script.alexa_sprachausgabe_og_komlett
    data:
      message: >-
        Ich fahre jetzt im Geschäft los. Aktuelle Ankunftszeit  {{
        (now()|as_timestamp + 
        float(states('sensor.fahrt_1'))  +
        float(states('sensor.fahrt_2'))  +
        float(states('sensor.fahrt_3'))  +
        float(states('sensor.fahrt_4')) )
        |timestamp_custom("%H:%M", True) }} Uhr
      type: announce
  - service: notify.telegram_manuel
    data:
      title: Info!
      message: >-
        Ich fahre jetzt im Geschäft los. Aktuelle Ankunftszeit  {{
        (now()|as_timestamp + 
        float(states('sensor.fahrt_1'))  +
        float(states('sensor.fahrt_2'))  +
        float(states('sensor.fahrt_3'))  +
        float(states('sensor.fahrt_4')) )
        |timestamp_custom("%H:%M", True) }} Uhr
mode: single

But with this code, I don´t get the two messages (Telegram and Alexa).

What make I wrong?

Your float() functions need a default… if you check your logs, you will likely see an error message.

alias: Sprachansage Fahrt Abfahrt im Geschäft
description: ''
trigger:
  - platform: state
    entity_id:
      - person.manuel
    from: Brütsch/Rüegger
    to: not_home
condition: []
action:
  - variables:
      message: >
        Ich fahre jetzt im Geschäft los. Aktuelle Ankunftszeit  {{
        (now() | as_timestamp + 
        float(states('sensor.fahrt_1'), 0)  +
        float(states('sensor.fahrt_2'), 0)  +
        float(states('sensor.fahrt_3'), 0)  +
        float(states('sensor.fahrt_4'), 0) )
        | timestamp_custom("%H:%M", True) }} Uhr
  - service: script.alexa_sprachausgabe_og_komlett
    data:
      message: '{{message}}'
      type: announce
  - service: notify.telegram_manuel
    data:
      title: Info!
      message: '{{message}}'
mode: single

Thank you for your answer.

But the output time (text and text-to-spreach) is only the now() time and not with the addition of the four statuses

Have you tries to see what the states you add give in the template editor? What exactly is the state the four sensors return?

Yes I try to see what the four states give back in the template editor.

for example:

{{ float(states('sensor.fahrt_1'), 0) }}

give back 8.0

maybe the .0 is the problem?

ok I try an other code:

This give me back 23 at the moment

{{ float(states('sensor.fahrt_1'), 0) | round(0) 
+ float(states('sensor.fahrt_2'), 0) | round(0)
+ float(states('sensor.fahrt_3'), 0) | round(0)
+ float(states('sensor.fahrt_4'), 0) | round(0) }}

but if I add this piece of code to the rest:

Ich fahre jetzt im Geschäft los. Aktuelle Ankunftszeit  
{{ (now() |
    as_timestamp 
    + float(states('sensor.fahrt_1'), 0) | round(0) 
+ float(states('sensor.fahrt_2'), 0) | round(0)
+ float(states('sensor.fahrt_3'), 0) | round(0)
+ float(states('sensor.fahrt_4'), 0) | round(0) ) |
    timestamp_custom("%H:%M", True) 
}} 
Uhr

I only got back the actual time. But I need the actual time + f. e. 23 minutes

Shouldn’t you multiply the result by 60? I think you’re just adding 23 seconds now.

yes you are right.

With this code it works:

Ich fahre jetzt im Geschäft los. Aktuelle Ankunftszeit  
{{ (now() |
    as_timestamp 
    + (float(states('sensor.fahrt_1'), 0) | round(0) *60)
+ (float(states('sensor.fahrt_2'), 0) | round(0) *60)
+ (float(states('sensor.fahrt_3'), 0) | round(0) *60)
+ (float(states('sensor.fahrt_4'), 0) | round(0) *60) ) |
    timestamp_custom("%H:%M", True) 
}} 
Uhr
1 Like