i have 13 panels. right now, the average is 19W as you can see.
how to set up an alert for a panel that is outputting less than 30% of all the average of 19w? so if inverter 993 is outputting 12w, i would get an alert instantly.
Create a min/max sensor that averages all your inverter powers. Name it PV Inverter Average Power
Notification automation:
Use a state trigger to trigger whenever any of the inverter powers change:
trigger:
- platform: state
entity_id:
- sensor.invet_038
- sensor.invet_164
# list all the inverter power sensors here, I've only shown a few
- sensor.invet_993
not_from:
- unknown
- unavailable
not_to:
- unknown
- unavailable
Use a template condition to check if the triggering inverter is 30% below the average:
condition:
- condition: template
value_template: >
{{ states(trigger.entity_id)|float(0) < states('sensor.pv_inverter_average_power')|float(0) * 0.7 }}
Send a notification telling you which one is low in the actions:
action:
- service: notify.foobar # change to your notification service
data:
message: >
The {{ trigger.to_state.name }} power is low.
Average: {{ states('sensor.pv_inverter_average_power')|float(0)|round(0) }} W
{{ trigger.to_state.name }}: states(trigger.entity_id) W
If you leave the extra blank lines in there it should create a message like this:
The invert 362 power is low.
Average: 19 W
invert 362: 13 W
you are amazing!
i copied and pasted 95% of your code and now we wait for it to work tomorrow.
actually, let me change the .7 to .95 later, so if anything differs by 5%, then we know the code is working flawlessly.
alias: alert solar panel is not working well
description: ""
trigger:
- platform: state
entity_id:
- sensor.invert_038
- sensor.invert_164
- sensor.invert_362
- sensor.invert_374
- sensor.invert_456
- sensor.invert_484
- sensor.invert_506
- sensor.invert_669
- sensor.invert_699
- sensor.invert_854
- sensor.invert_861
- sensor.invert_944
- sensor.invert_993
not_from:
- unknown
- unavailable
not_to:
- unknown
- unavailable
condition:
- condition: template
value_template: >
{{ states(trigger.entity_id)|float(0) <
states('sensor.pv_inverter_average_power')|float(0) * 0.7 }}
action:
- service: notify.telegram
data:
message: >
The {{ trigger.to_state.name }} power is low.
Average: {{
states('sensor.pv_inverter_average_power')|float(0)|round(0) }} W
{{ trigger.to_state.name }}: states(trigger.entity_id) W
mode: single
What was the 5% you left out?
You can also test it by going to developer tools → states and changing the value of one of the sensors there. It is only a temporary change until it receives its next update.
you are right, i just go to Dev tab and manual set the watt value and the automation was triggered
BUT i get nothing on my Telegram.
is there something wrong with my copy n pasted code from you? the syntax part is always confusing for me to troubleshoot
action:
- service: notify.telegram
data:
message: >
The {{ trigger.to_state.name }} power is low.
Average: {{
states('sensor.pv_inverter_average_power')|float(0)|round(0) }} W
{{ trigger.to_state.name }}: states(trigger.entity_id) W
mode: single
That looks ok. If using telegram you can use a message title, emojis and formatting too:
action:
- service: notify.telegram
data:
title: "⚠️<b>The {{ trigger.to_state.name }} power is low.</b>"
message: >
Average: {{
states('sensor.pv_inverter_average_power')|float(0)|round(0) }} W
{{ trigger.to_state.name }}: states(trigger.entity_id) W
mode: single
Check the automation trace. Maybe the condition stopped the action because the power was not set low enough?
Otherwise check Settings → System → Logs for errors or warnings about the automation or notify service.