Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions HomeAssistant/config/automations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,43 @@
mode: single
- id: '1793462400101'
alias: '⚠️ Alert: Grid Voltage Out of Range'
description: 'Mains is there but outside 185-250 V (the firmware''s grid_safe, on = UNSAFE) and grid protection is on, so the firmware has moved the house to battery. With protection off the inverter keeps running on the grid and nothing pages. A real outage is the Grid Outage alert''s: grid_down is on by the time the 20 s hold ends, and the condition skips it.'
description: 'Mains is there but outside 185-250 V (the firmware''s grid_safe, on = UNSAFE) and grid protection is on, so the firmware has moved the house to battery. With protection off the inverter keeps running on the grid and nothing pages. The voltage is read at the trip, when it has been out of range for grid_safe''s 5 s: 20 s later a spike has usually passed, and the alert used to report 248 V as Low. The 20 s hold is in the actions. A real outage is the Grid Outage alert''s: if grid_down is still on 20 s after the hold, that alert has fired and this run stops; a shorter dropout pages here as Low.'
triggers:
- trigger: state
entity_id: binary_sensor.powmr_inverter_grid_condition_safe
from: 'off'
to: 'on'
for:
seconds: 20
conditions:
- condition: state
entity_id: binary_sensor.grid_down
state: 'off'
- condition: state
entity_id: switch.powmr_inverter_auto_grid_protection
state: 'on'
actions:
- variables:
trip_volts: "{{ states('sensor.powmr_inverter_grid_voltage') | float(0) | round(0) | int }}"
- delay:
seconds: 20
- condition: state
entity_id: binary_sensor.powmr_inverter_grid_condition_safe
state: 'on'
- wait_template: "{{ is_state('binary_sensor.grid_down', 'off') }}"
timeout: '00:00:20'
continue_on_timeout: false
- variables:
volts: "{{ states('sensor.powmr_inverter_grid_voltage') | float(0) | round(0) | int }}"
title: "⚠️ Grid Voltage {{ 'High' if volts | int >= 250 else 'Low' }}"
title: "⚠️ Grid Voltage {{ 'High' if trip_volts | int >= 250 else 'Low' if trip_volts | int <= 185 else 'Out of Range' }}"
battery_line: "{% set r = states('sensor.battery_runtime_remaining') %}{% set s = states('sensor.jkbms_gateway_bms_state_of_charge') %}{% if r | is_number and s | is_number %}Battery {{ s | float | round(0) }}%, about {{ r | float | round(1) }} h left at the current draw.{% elif s | is_number %}Battery {{ s | float | round(0) }}%.{% endif %}"
- action: notify.household
data:
title: '{{ title }}'
message: 'Mains is at {{ volts }} V, outside 185-250 V. Grid protection has moved the house to battery until the grid is steady in range for 5 minutes. {{ battery_line }}'
message: 'Mains went to {{ trip_volts }} V, outside 185-250 V ({{ volts }} V now). Grid protection has moved the house to battery until the grid is steady in range for 5 minutes. {{ battery_line }}'
data:
ttl: 0
priority: high
channel: Emergency
- action: notify.persistent_notification
data:
title: '{{ title }}'
message: 'Mains is at {{ volts }} V, outside 185-250 V. Grid protection has moved the house to battery until the grid is steady in range for 5 minutes. {{ battery_line }}'
message: 'Mains went to {{ trip_volts }} V, outside 185-250 V ({{ volts }} V now). Grid protection has moved the house to battery until the grid is steady in range for 5 minutes. {{ battery_line }}'
mode: single
- id: '1793462400102'
alias: ✅ Grid Voltage Normal
Expand Down
34 changes: 25 additions & 9 deletions HomeAssistant/tools/check_automations.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,32 @@ def walk(node):
print("\n2b. grid out of range: only when protection moved the house")
low_v = by_alias(autos, "Grid Voltage Out of Range")
trig = low_v["triggers"][0]
check("trigger: quality check unsafe for 20 s",
check("trigger: quality check unsafe, at once (the hold is in the actions)",
(trig.get("entity_id"), trig.get("from"), trig.get("to"), trig.get("for")),
("binary_sensor.powmr_inverter_grid_condition_safe", "off", "on", {"seconds": 20}))
check("conditions: mains present and protection on",
sorted((c["entity_id"], c["state"]) for c in low_v["conditions"]),
[("binary_sensor.grid_down", "off"),
("switch.powmr_inverter_auto_grid_protection", "on")])
title = low_v["actions"][0]["variables"]["title"]
for volts, want in (("180", "⚠️ Grid Voltage Low"), ("252", "⚠️ Grid Voltage High")):
check("%s V -> %s" % (volts, want), render(title, volts=volts), want)
("binary_sensor.powmr_inverter_grid_condition_safe", "off", "on", None))
check("conditions: protection on",
[(c["entity_id"], c["state"]) for c in low_v["conditions"]],
[("switch.powmr_inverter_auto_grid_protection", "on")])
acts = low_v["actions"]
check("reads the voltage at the trip, before the hold",
list(acts[0]["variables"]) + [list(acts[1])],
["trip_volts", ["delay"]])
check("held 20 s, still unsafe after it",
(acts[1]["delay"], acts[2].get("entity_id"), acts[2].get("state")),
({"seconds": 20}, "binary_sensor.powmr_inverter_grid_condition_safe", "on"))
check("grid still down 20 s on -> stops (Grid Outage has fired)",
("grid_down" in acts[3]["wait_template"], acts[3]["timeout"],
acts[3]["continue_on_timeout"]),
(True, "00:00:20", False))
title = acts[4]["variables"]["title"]
for trip, want in (("2", "⚠️ Grid Voltage Low"), ("180", "⚠️ Grid Voltage Low"),
("252", "⚠️ Grid Voltage High"), ("250", "⚠️ Grid Voltage High"),
("226", "⚠️ Grid Voltage Out of Range")):
check("tripped at %s V -> %s" % (trip, want), render(title, trip_volts=trip), want)
message = acts[5]["data"]["message"]
check("message: trip voltage, then now",
render(message, trip_volts="252", volts="248", battery_line="").startswith(
"Mains went to 252 V, outside 185-250 V (248 V now)."), True)

normal = by_alias(autos, "Grid Voltage Normal")
cond = normal["conditions"][0]["value_template"]
Expand Down
Loading