Hi Fionn,
Welcome aboard!! I’m no expert on HA, but I have spent countless hours setting up my energy monitoring, mainly due to having an old ‘dumb’ gas meter where I had to make and test my own sensor to read the values.
As part of all this faff of setting up, I wanted to create a dashboard so I could see Daily Cost, Weekly Costs, etc. To do this I had to create what you would call “bespoke sensors” or “custom sensors”. These were not physical components to take readings from things but bits of YAML code that undertook calculations using the data from other sensors, as can be seen below.
- sensor:
- name: "Daily Gas Cost"
unique_id: daily_gas_cost
state: "{{ (((((states('sensor.gas_consumption_daily_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6) * 0.0621)|round(2) }}" #The 0.0621 is gas cost in £'s per kwh
availability: "{{ states('sensor.gas_consumption_daily_v2')|is_number }}"
unit_of_measurement: "£"
device_class: monetary
state_class: total
- name: "Weekly Gas Consumption kWh"
unique_id: weekly_gas_usage_kwh
state: "{{ ((((states('sensor.gas_consumption_weekly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6)|round(2) }}"
availability: "{{ states('sensor.gas_consumption_weekly_v2')|is_number }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
- name: "Weekly Gas Cost"
unique_id: weekly_gas_cost
state: "{{ (((((states('sensor.gas_consumption_weekly_v2')|float * 0.0283) * 1.02264) * 39.9) / 3.6) * 0.0621)|round(2) }}" #The 0.0621 is gas cost in £'s per kwh
availability: "{{ states('sensor.gas_consumption_weekly_v2')|is_number }}"
unit_of_measurement: "£"
device_class: monetary
state_class: total
type or paste code here
As you can see from the YAML above there are simple maths calculations taking place on Meter Helpers that I set up. On the last entry, named “Weekly Gas Cost”, it takes a Meter Helper I set up (sensor.gas_consumption_weekly_v2) to log that week’s gas consumption, and then uses all the relevant maths from my gas bill to convert the ft3 reading off the meter to a cost in £’s where it makes more sense.
You would have to create something similar to suit your setup, and use the three Meter Helpers you have already created, perhaps add them together, and then multiply by your oil flow rate. This should provide the total usage, according to whatever time-frequency (days, weeks, months) you set the Meter Helpers in.
In the YAML code noted above, the items such as Name: and unique_id: can be whatever you want, so use something that makes sense and is logical to you, but is different from something already created. I wouldn’t just cut and copy the code verbatim, but just use it as a basis to see how the formatting of YAML works - it is finicky if your lines are not indented properly (Admittedly, I am YAML Challenged BTW… )
You can create as many bespoke sensors as you want to report back costs, etc. These little bits of code are pasted into the main ‘configuration’ section within HA - see screenshot below of where I stuck mine.
I use a plugin called Studio Code Server to view these YAML files - may be available from HACS (I can’t remember now!)
I hope the above helps, and if you need any further help, just shout and I’ll do what I can to assist.
Cheers,
Mike.