#Inline multiplication in notification

1 messages · Page 1 of 1 (latest)

idle turtle
#

Hi all

So I’ve made an automation which I’ll eventually pump to Alexa but for testing it’s sending a notification to my phone all whilst I test.

action: notify.mobile_app_inquisitor
metadata: {}
data:
  message: >-
    Your car has finished charging and Used {{
    states('sensor.wall_e_session_energy') | round(2) }} kWh and cost
    approximately £{{ states('sensor.wall_e_session_energy') | round(2) |
    multiply(states('sensor.octopus_energy_electricity_19l2434781_2700004730854_current_rate') 
    | round(2) )}}

This works fine but the price doesn’t get rounded and ends up with 5 decimal places. What’s wrong with syntax?

split fractal
#

how about

£{{ states('sensor.wall_e_session_energy') | round(2) |
    multiply(states('sensor.octopus_energy_electricity_19l2434781_2700004730854_current_rate') 
    | round(2) ) | round(2) }}

although you are rounding too many times if you ask me

idle turtle
#

If I’m honest I’ve been playing with the code to insert it in the first place which had a round for presentation purposes but actually I don’t need to round it until I’m finished

#

I’ll give that a try in the morning just got in bed. Thanks for your assistance

naive rain
#

Try this way:

action: notify.mobile_app_inquisitor
metadata: {}
data:
  message: >-
    Your car has finished charging and Used {{
    states('sensor.wall_e_session_energy') | round(2) }} kWh and cost
    approximately £{{ (states('sensor.wall_e_session_energy')  * states('sensor.octopus_energy_electricity_19l2434781_2700004730854_current_rate') ) | round(2) }}