Weasel I can easily use GivTCP to determine the battery load, but how best do i determine whether the system is attached to the grid?
Not heard of smart RCBs that you can control by HA. Clever stuff.
The way most of us detect whether the grid is connected is to look at the givtcp grid frequency sensor. If less than 49Hz then grid power is lost, if greater than 49 then grid power is restored.
I have the following automation notification copied from someone else on this forum:
alias: Grid Status Notifications
description: Notifies loss / resumption of grid status to home battery system
mode: single
triggers:
- entity_id:
- sensor.givtcp_xxxx_grid_frequency
for:
seconds: 10
below: 49
id: grid_lost
trigger: numeric_state
- entity_id:
- sensor.givtcp_xxxx_grid_frequency
for:
seconds: 10
above: 49
id: grid_resumed
trigger: numeric_state
conditions:
- alias: Uptime is more than 1 min
condition: template
value_template: "{{ as_timestamp(now()) - as_timestamp(states('sensor.uptime')) >= 60 }}"
actions:
- if:
- condition: trigger
id:
- grid_lost
then:
- data:
title: Power Cut
message: >
Connection to the grid lost - house is on battery. Current load is
{{ states('sensor.givtcp_xxxx_load_power')|int }}kW. Current SoC is
{{ states('sensor.givtcp_xxxx_soc')|int }}%. Battery will last
approximately {{
((states('sensor.givtcp_xxxx_discharge_time_remaining')|int)/60)|int
}} hours.
critical: "Y"
action: script.notify_all_devices
- if:
- condition: trigger
id:
- grid_resumed
then:
- data:
title: Grid Power Restored
message: >
Connection to the grid resumed. Current load is {{
states('sensor.givtcp_xxxx_load_power')|int }}kW. Current SoC is {{
states('sensor.givtcp_xxxx_soc')|int }}%.
action: script.notify_all_devices
The check on uptime (you have to enable this sensor) is to detect whether HA has been running as otherwise you get a false alert when you first start HA up. If however I reboot HA I still get a false alert, so its not perfect yet