Last active
April 5, 2024 14:10
-
-
Save wwerther/8cfb58e6cd08fbfda3d2df96909b895f to your computer and use it in GitHub Desktop.
AWTRIX - Solaredge with batterie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
blueprint: | |
name: ☼ AWTRIX - SolarEdge Energy Monitor | |
description: > | |
This blueprint will show the current solar energy received, the amount of energy consumed by the household, | |
and the amount of energy stored in the battery. | |
Based on https://flows.blueforcer.de/flow/YjJZo6m7AyrL | |
Uses entities provided by https://github.com/Remko76/hasolarcfg/tree/master | |
It uses icons 21585 for loading battery, and 21586 for discharge | |
Test | |
domain: automation | |
author: Walter | |
input: | |
awtrix: | |
name: AWTRIX Device | |
description: Select the Awtrix light | |
selector: | |
device: | |
integration: mqtt | |
manufacturer: Blueforcer | |
model: AWTRIX Light | |
multiple: true | |
grid_power: | |
name: Grid Power Sensor | |
description: A sensor providing the current power sent or received from the grid | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solaredge_m1_ac_power | |
house_consumption: | |
name: Energy consumption of household | |
description: How much total energy is consumed in the household Grid + Batteries + Panels | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solar_house_consumption_w | |
battery_status: | |
name: Battery Status | |
description: | |
A sensor providing the state of your battery | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solaredge_b1_status | |
battery_power: | |
name: Battery Power | |
description: | |
A sensor providing the state of your battery | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solaredge_b1_dc_power | |
battery_soe: | |
name: Load level of battery 0-100% | |
description: | |
A sensor providing the state of your battery | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solaredge_b1_state_of_energy | |
panel_power: | |
name: Power from the panels | |
description: | |
A sensor providing the power coming from your panels | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
default: sensor.solar_panel_production_w | |
bat_threshold_high: | |
name: Threshold for high battery color (%) | |
description: The threshold above which the battery state will be shown with high | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
unit_of_measurement: '%' | |
mode: slider | |
default: 75 | |
bat_threshold_low: | |
name: Threshold for low battery color (%) | |
description: The threshold above which the battery state will be shown with low | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
unit_of_measurement: '%' | |
mode: slider | |
default: 25 | |
bat_col_high: | |
name: high battery color | |
selector: | |
color_rgb: | |
default: [00,255,00] | |
bat_col_normal: | |
name: normal battery color | |
selector: | |
color_rgb: | |
default: [255,255,00] | |
bat_col_low: | |
name: low battery color | |
selector: | |
color_rgb: | |
default: [255,00,00] | |
threshold_high: | |
name: Threshold for high solar production (W) | |
description: The threshold above which the energy production of your solar system should be visualized as high. Input in Watts (W). | |
selector: | |
number: | |
min: 0 | |
max: 100000 | |
unit_of_measurement: Watt | |
mode: slider | |
default: 400 | |
threshold_low: | |
name: Threshold for low solar production (W) | |
description: The threshold below which the energy production of your solar system should be visualized as low. Input in Watts (W). | |
selector: | |
number: | |
min: 0 | |
max: 100000 | |
unit_of_measurement: Watt | |
mode: slider | |
default: 100 | |
skip_if_zero_watts: | |
name: Hide solar production if at 0 Watts | |
description: 'This will not show the solar energy production on your awtrix if the production is below 0 Watts.' | |
selector: | |
boolean: | |
default: false | |
skip_during_night_hours: | |
name: Hide solar production during night time | |
description: 'This will not show the solar energy production on your awtrix during night hours (as specified below).' | |
selector: | |
boolean: | |
default: false | |
night_starts_after_time: | |
name: Night Time Start | |
description: Set the start of the night time. | |
default: 00:00:00 | |
selector: | |
time: {} | |
night_ends_after_time: | |
name: Night Time End | |
description: Set the end of the night time. | |
default: 00:00:00 | |
selector: | |
time: {} | |
mode: single | |
variables: | |
# The list of AWTRIX devices that should receive the data | |
device_ids: !input awtrix | |
# Topics that we need for receiving the messages | |
devices_topics: >- | |
{%- macro get_device_topic(device_id) %} | |
{{ states((device_entities(device_id) | select('search','device_topic') | list)[0]) }} | |
{%- endmacro %} | |
{%- set ns = namespace(devices=[]) %} | |
{%- for device_id in device_ids %} | |
{%- set device=get_device_topic(device_id)|replace(' ','') %} | |
{% set ns.devices = ns.devices + [ device ~ '/custom/solar' ] %} | |
{%- endfor %} | |
{{ ns.devices }} | |
devices_topics_bat: >- | |
{%- macro get_device_topic(device_id) %} | |
{{ states((device_entities(device_id) | select('search','device_topic') | list)[0]) }} | |
{%- endmacro %} | |
{%- set ns = namespace(devices=[]) %} | |
{%- for device_id in device_ids %} | |
{%- set device=get_device_topic(device_id)|replace(' ','') %} | |
{% set ns.devices = ns.devices + [ device ~ '/custom/solarbat' ] %} | |
{%- endfor %} | |
{{ ns.devices }} | |
power_sensor: !input grid_power | |
bpow: !input battery_power | |
bsoe: !input battery_soe | |
bstatus: !input battery_status | |
bch: !input bat_col_high | |
bth: !input bat_threshold_high | |
bcn: !input bat_col_normal | |
btl: !input bat_threshold_low | |
bcl: !input bat_col_low | |
b_soe: >- | |
{{ states[bsoe].state | int(0) }} | |
b_pow: >- | |
{{ states[bpow].state | int(0) | abs }} | |
b_pow_text: >- | |
{%- if int(b_pow) > 1000 %}{{ ((b_pow | float(default=0)) / 1000) | round(1)}} kW{%- else %}{{ b_pow }} W{%- endif %} | |
b_icon: >- | |
{% if is_state(bstatus,"B_STATUS_DISCHARGE") -%} | |
21586 | |
{%- else %} | |
21585 | |
{%- endif %} | |
g_icon: >- | |
{% if is_state(bstatus,"grid import") -%} | |
53743 | |
{%- else %} | |
54367 | |
{%- endif %} | |
payload: >- | |
{ | |
"icon": {{ b_icon }}, | |
"pushIcon": "0", | |
"text": "{{ b_pow_text }}", | |
"progress": {{ b_soe }} | |
} | |
trigger: | |
- platform: time_pattern | |
minutes: "/1" | |
condition: | |
action: | |
- choose: | |
- alias: "Skipping" | |
conditions: | |
- condition: template | |
value_template: > | |
{% set now_time = now().strftime("%H:%M") %} | |
{% set night_start = night_start %} | |
{% set night_end = night_end %} | |
{{ (skip_during_night_hours and ((now_time < night_end) or (now_time > night_start))) or (skip_if_zero_watts and (power_level == 0)) }} | |
sequence: | |
# It is night time, skipping sending solar power data to Awtrix Light. | |
- repeat: | |
for_each: "{{ devices_topics }}" | |
sequence: | |
- service: mqtt.publish | |
data: | |
qos: 0 | |
retain: false | |
topic: "{{ repeat.item }}" | |
payload: '{}' | |
- alias: "Not skipping" | |
conditions: | |
- condition: template | |
value_template: > | |
{% set now_time = now().strftime("%H:%M") %} | |
{% set night_start = night_start %} | |
{% set night_end = night_end %} | |
{{ not((skip_during_night_hours and ((now_time < night_end) or (now_time > night_start))) or (skip_if_zero_watts and (power_level == 0))) }} | |
sequence: | |
- repeat: | |
for_each: "{{ devices_topics }}" | |
sequence: | |
- service: mqtt.publish | |
data: | |
qos: 0 | |
retain: false | |
topic: "{{ repeat.item }}" | |
payload: > | |
{{ payload }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment