Putting information from sensor into mobile notification

Hello guys,

First off - I readed documentation and forums so either I’m moron or it doesn’t describe what I need :slight_smile:
I have a solar panels which after integrating with HA give me some information like current power of production, energy produced this day and few others. I want to make automation that when production drops to 0W it will send me mobile notification telling how much energy was produced today. It looks like this:

alias: 'SolarEdge [NOT PRODUCING] -> Kuba Telefon [NOTIFICATION]'
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.solaredge_current_power
    below: '1'
condition: []
action:
  - device_id: c593fadfd2c2d134bc507567b588b2ae
    domain: mobile_app
    type: notify
    message: Energy production ended. Energy produced today: 
    title: SolarEdge
mode: single

Now - how do I make that after words “Energry produced today” it will put actual today produced energy from sensor.solaredge_energy_today?

Maybe the question is silly but I can’t find an answer.

You could try something like this:

message: Energy production ended. Energy produced today: {{states('sensor.solaredge_current_power')}}

or if it is an attribute of the sensor:

message: Energy production ended. Energy produced today: {{state_attr('sensor.solaredge_current_power','the_state_you_want')}}

Maaan. I love you! (no homo). First option works!!!

Thanks for ultra fast reply :slight_smile:

1 Like

I don’t know if this works with automations in the UI, but the template for this would be.

message: >
  Energy production ended. Energy produced today:  {{ states('sensor.solaredge_energy_today') }}

Yes!

Same as CO_4X4 suggested just a minute before you it works!!!.

Thank you both for very quick answer :slight_smile:

Just don’t forget to swap out the entity with sensor.solaredge_energy_today, otherwise you’ll always get 0 :slight_smile:

Of course.

CO_4X4 putted wrong sensor but I got what he meant :slight_smile:

So final code:

alias: 'SolarEdge [NOT PRODUCING] -> Kuba Telefon [NOTIFICATION]'
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.solaredge_current_power
    below: '1'
condition: []
action:
  - device_id: c593fadfd2c2d134bc507567b588b2ae
    domain: mobile_app
    type: notify
    message: >-
      Energy production ended. Energy produced today: 
      {{states('sensor.solaredge_energy_today')}} Wh.
    title: SolarEdge
mode: single

And final result:

You are all great!!!

Thanks again :slight_smile:

2 Likes

As a quality of life improvement you could probably mess with it to format that number with a comma in it with something like:

"{{ '{:,}'.format(states('sensor.solaredge_energy_today') }}"

I haven’t tried it but that is the Python code to do it, theoretically it should work.

This thread is old but i hope someone can help me.
Almost the same as @BooBoss but I want my solar to give me produced electricity, sold and imported.
Everything works great if i put below 1 kWh (below: ‘1’) but my solar panels will produce under 1kwh a few hours so I want it to be “below: 0” but that does not work, I tried 0.1 and that will not work.
How can a make it work with 2 or 3 decimals? Like 0.100? or even better just with 0.

I have other automations that i want this to work on, it just works on 1, 2. 3. 4. and so on, no decimals.

Here is my code:

alias: Producerat, sålt, köpt idag
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.active_power
    below: "0.000"
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: notify.notify
    data:
      message: >-
        Energiproduktionen upphörde idag.  Producerad El idag: 
        {{states('sensor.daily_yield')}} kwh.  Köpt idag: 
        {{states('sensor.grid_import_solar_daily_energy')}} kWh.  Sålt idag: 
        {{states('sensor.grid_export_solar_daily_energy')}} kWh.
mode: restart