I find all the solutions above a bit more complicated than they need to be. Here’s what I did:
template:
- trigger: # rate-limit the template a bit, which would otherwise re-calculate every minute
- platform: time_pattern
hours: "*" # calculate hourly should be fine
sensor:
# Increases every day by 1W to fake a daily supply charge in energy dashboard.
- state: >-
{{ 0.001 * (now() - "2022-09-26" | as_datetime | as_local).days }}
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
unique_id: CHANGE_ME_TO_ANYTHING_JUST_MAKE_IT_UNIQUE
name: "Daily supply charge"
Just set the date "2022-09-26"
to the day or day before whenever you add this, so it doesn’t have a big jump on the first entry.
Then I just added it directly as a type of grid consumption with a fixed price set to 1000x my real daily supply charge:
This only adds 1W of “fake” usage and will update daily without any automation or need for a utility meter entity.
With total_increasing
, I think it could even work to just have a sensor which toggled between 0 and 1 every 12 hours as the 0
will be interpreted as a start of new cycle, but I haven’t tested that.