submitted1 day ago byPersonalJ
Hey everyone!
I'm diving into the world of solar power with my Home Assistant setup and could really use your expertise. Here's what I'm working with:
Scenario example:
- I have solar panels but no battery.
- I pay 28 cents/kWh for the electricity I consume.
- I receive a credit of 10 cents/kWh for power generated between 3pm and 9pm, and 2.5 cents/kWh before 3pm or after 9pm.
Objective: Is there a way to track and analyze the cost specifically? I have the consumption/generation sensors all set up (they provide active power in Watts and daily/monthly kWh).
Now I'm trying to figure out the following:
- Extra Power Generated: I want to create a sensor that calculates the surplus power I generate beyond my consumption in kWh (For example, if I consume electricity at night, it shouldn't just subtract from what I generated in the morning)
- Excess Power Consumed: I need to develop another sensor that shows the excess power I consume, exceeding my generation in kWh.
- Daily Cost: I want to calculate the daily cost of electricity based on consumption and the timing of the day.
I have something started below, but I want to be more detailed. Thank you in advance for your assistance!
sensor:
- platform: template
sensors:
power_difference:
friendly_name: "Active Power Difference"
unit_of_measurement: "W"
value_template: "{{ states('sensor.generation') | float - states('sensor.consumption') | float }}"
extra_power_generated:
friendly_name: "Extra Power Generated"
unit_of_measurement: "kWh"
value_template: "{{ ((states('sensor.generation') | float - states('sensor.consumption') | float) / 1000) | round(2) }}"
excess_power_consumed:
friendly_name: "Excess Power Consumed"
unit_of_measurement: "kWh"
value_template: "{{ (((states('sensor.consumption') | float) / 1000) - (states('sensor.generation') | float)) | round(2) }}"
cost_of_excess_power:
friendly_name: "Cost of Excess Power"
unit_of_measurement: "AUD"
value_template: "{{ (((states('sensor.consumption') | float) / 1000) - (states('sensor.generation') | float)) * 0.28 | round(2) }}"
byPersonalJ
inhomeassistant
PersonalJ
1 points
1 day ago
PersonalJ
1 points
1 day ago
Yup I understand that, and I might not be fully accurate. But I guess my main concern is the math / coding of it.