Help converting energy usage to cost

Could someone please help me make cards that show a table of daily energy (heating) usage and cost?

I maintain multiple locations, some use oil, some gas, some electric.

The electric usage is monitored with an Emporia Vue and I have been able to make these cards showing the daily usage in KwH. Energy costs aren’t strictly $/KWH because of separately calculated delivery vs. energy costs, taxes, etc. that make it a non-linear function (I think that’s the correct phrase). But, I would be fine calling is $0.20/KwH.

Propane gas is also monitored and I can see the daily levels:

This is the code:

type: custom:plotly-graph
defaults:
  entity:
    show_value: true
entities:
  - entity: sensor.tank_utility_003200223638383015473830
    name: |
      $ex "355: " + Math.round(ys[ys.length -1]*10)
    filters:
      - map_y: y*10
    show values: "yes"
    line:
      color: Magenta
    unit_of_measurement: Gallons
    yaxis: y2
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_371_gallons
    name: |
      $ex "371: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: red
    yaxis: y1
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_125_gallons
    name: |
      $ex "125: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: blue
    yaxis: y1
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_76_gallons
    name: |
      $ex "76: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: black
    yaxis: y1
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_255_gallons
    name: |
      $ex "255: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: green
    yaxis: y1
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_629_gallons
    name: |
      $ex "629: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: yellow
    yaxis: y1
    extend_to_present: true
  - entity: sensor.propane_tank_neevo_630_gallons
    name: |
      $ex "630: " + Math.round(ys[ys.length - 1])
    show values: "yes"
    line:
      color: purple
    yaxis: y1
    extend_to_present: true
layout:
  height: 700
  showlegend: true
  yaxis:
    fixedrange: false
    range:
      - 1
      - 200
  yaxis2:
    fixedrange: false
    range:
      - 1
      - 850
title: Propane Gallons
hours_to_show: 240

I do not have any HA monitoring of oil. All I have are paper invoices which come in at random times (well, random to me) that I then manually extract the data from. I use a rough $3.50/gallon to derive the gallons used.

I do apologize, but I am not particularly well-versed at HA, so kindly include what you might consider very basic info, like what card to use and how to manuipulate the data. I would like to see daily usage in kwh or gallons as well as daily cost.

Thank you very much!

Does anyone have any experience hiring someone from Fiverr or upwork to do something specific like this?

add a template sensor in your configuration.yaml

template:
  - sensor:
      - name: "Daily Electricity Cost"
        unit_of_measurement: "$"
        state: >
          {{ states('sensor.daily_electricity_usage') | float * 0.20 }}

daily usage of propane

utility_meter:
  propane_daily_usage:
    source: sensor.propane_level
    cycle: daily
template:
  - sensor:
      - name: "Daily Propane Cost"
        unit_of_measurement: "$"
        state: >
          {{ states('sensor.propane_daily_usage') | float * 3.50 }}

and oil will be an input number

input_number:
  daily_oil_usage:
    name: Daily Oil Usage
    min: 0
    max: 100
    step: 1
    unit_of_measurement: "gallons"
template:
  - sensor:
      - name: "Daily Oil Cost"
        unit_of_measurement: "$"
        state: >
          {{ states('input_number.daily_oil_usage') | float * 3.50 }}

the lovelace cards themselves should be something along the lines of

type: statistics-graph
entities:
  - sensor.daily_electricity_usage
  - sensor.daily_electricity_cost
chart_type: bar
period: day
title: Daily Electricity Usage and Cost
type: custom:plotly-graph
entities:
  - entity: sensor.propane_daily_usage
    name: Daily Propane Usage
    type: bar
    line:
      color: blue
  - entity: sensor.daily_propane_cost
    name: Daily Propane Cost
    type: bar
    line:
      color: red
layout:
  height: 400
  title: Propane Usage and Cost
type: entities
entities:
  - entity: input_number.daily_oil_usage
    name: Daily Oil Usage
  - entity: sensor.daily_oil_cost
    name: Daily Oil Cost
title: Oil Usage and Cost

I have not tested this so please let me know how it works. Does Fiverr have home assistant specialists?

Thank you very much!

I don’t understand where the data comes from. Taking electric as an example:

template:
  - sensor:
      - name: "Daily Electricity Cost"
        unit_of_measurement: "$"
        state: >
          {{ states('sensor.daily_electricity_usage') | float * 0.20 }}

What populates: sensor.daily_electricity_usage ?

That’s the basics you will need to calculate the cost: a device (sensor) that measures your electricity usage.

1 Like

That’s where I’m stuck.

How do I calculate/convert from daily gallons on hand, or daily kwh used, to a sensor or variable (or on the fly calculation) cost?