Hi All
My solar inverter integration has an entity called sensor.power_meter_active_power
reports positive values if the system is importing power from the grid, and negative if its sending power to the grid.
Similarly, my battery integration has an entity sensor.battery_charge_discharge_power
which reports positive values when charging the battery, and negative values when the battery is discharging.
I want to split out these two entities out into four entities:
New entity name | Unit | Function
------------------------------------------------|-------------------|-----------------------------------
sensor.power_meter_active_power_grid_export | Watts | Power exported to grid
sensor.power_meter_active_power_grid_import | Watts | Power imported from grid
sensor.battery_charge | Watts | Power drawn from battery
sensor.battery_discharge | Watts | Power used to charge battery
To accomplish this, I set up these entities (via the documentation from the Tesla style solar power card
installed via HACS):
battery_discharging_power:
value_template: '{% set batt_dischg = sensor.battery_charge_discharge_power | int %}
{% if batt_dischg > 0 %}
{{ batt_dischg | int }}
{% else %}
0
{% endif %}'
device_class: power
unit_of_measurement: W
friendly_name: Battery Discharging Power
icon_template: mdi:battery-arrow-down-outline
battery_charging_power:
value_template: '{% set batt_chg = sensor.battery_charge_discharge_power | int %}
{% if batt_chg < 0 %}
{{ batt_chg | int }}
{% else %}
0
{% endif %}'
device_class: power
unit_of_measurement: W
friendly_name: Battery Charging Power
icon_template: mdi:battery-arrow-up
power_meter_exported_to_grid:
value_template: '{% set grid_export = sensor.power_meter_active_power | int %}
{% if grid_export < 0 %}
{{ grid_export | int }}
{% else %}
0
{% endif %}'
device_class: power
unit_of_measurement: W
friendly_name: Power Exported to Grid
icon_template: mdi:home-lightning-bolt
power_meter_imported_from_grid:
value_template: '{% set grid_import = sensor.power_meter_active_power | int %}
{% if grid_import > 0 %}
{{ grid_import | int }}
{% else %}
0
{% endif %}'
device_class: power
unit_of_measurement: W
friendly_name: Power Imported from Grid
icon_template: mdi:transmission-tower-import
However, all entities show unknown
. No syntax errors turn up. What am I doing wrong.