Hi @Stake63,
When you only have 1 tariff, you probably don’t need an if statement.
When you have an if statement, i think you might need an else statement, otherwise it doesnt know what to do when your if statement doesnt match.
Try this instead
template:
- sensor:
- name: Tariff Price
unit_of_measurement: AUD/kWh
state: >
{{ 0.2844 }}
Now for the energy cost
To be fair, this one looks good already. I have only messed with formatting to help me understand it.
- sensor:
- name: Energy Cost
device_class: monetary
state_class: measurement
unit_of_measurement: AUD
state: >
{{ (states('sensor.daily_energy_Peak') | float * 0.2844 +
0.8702) | round(2) }}
I often use Developer tools to work out the logic.
Example:
As my retailer currently does not charge peak for Spring months (Sept-Oct), your code will not match mine exactly. Using your code, we can see the $0.87 result on the right of the picture. This deliberately unmatched sensor pretty much simulates what will happen at the start of every day (midnight) when the daily_energy_peak gets reset.
When I change the sensor to match one of my sensors, I can see the 0.87 being added to the current value of that sensor
Here is the value of my sensor
Lets break down the code using my sensor value above as an example.
4.457 kWh (energy consumed today) * $0.2844 (your peak rate per kWh) = $1.2675708
$1.2675708 + $0.8702 (daily service charge) = $2.1377708
That is your cost for the whole day including daily service charge. Note: this does not include solar compensation as its not in your code. Otherwise, looks good to me if you if you do not have solar.
My code also includes the solar compensation so I can see 3 elements…
1 - the whole daily grid import usage cost
2 - excess solar grid export compensation
3 - daily service charge
…all in 1 number that represents what I paid for power for the whole day.
That is the whole point of this whole project really