Hi everybody.
I will try to be as clear as possible with my challenge and i am a bit of a beginner so please bear with me .
I have solar at home and i have recently installed a battery pack. At the moment my battery pack can’t send it’s state of charge to the inverter but my inverter does have some sensors i can use to hopefully calculate a rough state of charge.
I have:
-
sensor.lux_battery_charge_daily
(this is the number of KWhs sent into the battery and reset at midnight) -
sensor.lux_battery_discharge_daily
( this is the number of KWa used from the battery, reset to 0 at midnight. -
My total battery capacity is 30KWa
I would love some advise from the community as i think i have a starting point but i am struggling a bit. Here is what i have created so far. this is a linked custom sensor.yaml file.
###End of day Capacity before everything is reset####
- platform: template
sensors:
custom_battery_end_of_day_capacity:
friendly_name: "Battery End of Day"
value_template: "{{15 | float}}" ##i have manually set this as 15 because i need a way to update this value just before midnight when everything resets. ###
unit_of_measurement: "KWh"
### Charge or discharge value today #####
- platform: template
sensors:
custom_charge_discharge_amount:
friendly_name: "charge or discharge amount today"
value_template: "{{states('sensor.lux_battery_charge_daily') | float - states('sensor.lux_battery_discharge_daily') | float }}"
unit_of_measurement: "KWh"
#### Current capacity since yesterdays status ####
- platform: template
sensors:
custom_battery_capacity:
friendly_name: "Battery counter"
value_template: "{{states('sensor.custom_battery_end_of_day_capacity')| float + states('sensor.custom_charge_discharge_amount') | float}}"
unit_of_measurement: "KWh"
#### SOC as a percentage ####
- platform: template
sensors:`
custom_soc:
friendly_name: "Calculated state of charger"
value_template: "{{states('sensor.custom_battery_capacity') | float / 30 * 100 | round (1)}}"
unit_of_measurement: "%"
I am sure am doing this in a ‘haphazard’ kind of way and seeking some advice.
Thanks again.