How to calculate daily and running totals

This is a better (I hope) formed question than my previous post.

I have a sensor: sensor.propane_tank_neevo_371_gallons

This sensor gets updated daily with the number of gallons of propane remaining in my tank.

For example, the daily readings might be:

1st of the month: 500 gallons
2nd of the month: 490
3rd of the month: 475

30th of the month: 200
31st of the mont: 180

What I would like is a card with a graph/chart/lines that show 4 things:

  1. Daily number of gallons used (i.e, yesterday’s total minus today’s total): X-axis=day-of-month; Y-axis=gallons

  2. Daily cost (i.e., daily number from #1 above * $3.50: X-axis=day-of-month; Y-axis=dollars

  3. Running monthly total for gallons used: X-axis=day-of-month; Y-axis=gallons (but posibly different scale from #1)

  4. Running monthly total for cost of gas: X-axis=day-of-month; Y-axis=dollars (but different scale from #2)

The sensor is created in configuration.yaml as follows:


command_line:
  - sensor:
      command: "curl -k -u <USER>:<PASSWORD> https://ws.otodatanetwork.com/neevoapp/v1/DataService.svc/GetAllDisplayPropaneDevices --header Content-Type:application/json"
      name: "Propane Tank Neevo 371 Gallons"
      unique_id: propane_tank_371_gallons
      value_template: "{{ value_json[0].Level|float(0) * 2.4 if value_json[0].Level is defined else this.state }}"
      scan_interval: 14400
      state_class: measurement
      unit_of_measurement: "Gallons"

Can someone please guide me on this (from scratch, like which card to use, what new variables/sensors/helpers/etc should be created, etc.)?

Of course, if there is a better way to visualize or present this data, I’d love to hear about it.

The goal is to be able to see ‘at a glance’ my heating fuel usage and cost by day and month

Thank you!

So the first thing to do is get 3 template sensors setup and define a time sequence of actions.

  1. Yesterdays Level - Trigger Template @ 11:30 PM {{ states(‘sensor,propane_current_level’) }} - this is going to copy that value of the propane take into a new sensor called yesterday.
  2. Command line sensor - Trigger@ 11:40 PM - this updates the values of current.
  3. Todays Usage - Trigger Template @ 11:50 PM - calculate difference between current and yesterday. This is how much was used today.

One that is working, then we can look at the next step of setting up weekly and monthly utility meters.

Is there UI way to create a Trigger Template?

Do I understand correctly:

  1. Copy day 0’s propane value into a sensor named ‘yesterday’
  2. Create a new sensor day 1’s value – ‘today’
  3. Create a new sensor that calculates the difference

I’m sure I don’t know how to do that any of that correctly.

There should be a way to do it in the UI. I don’t use the UI, I write it in YAML.

Start with looking at the documentation. Template - Home Assistant

You are going to want to use a time trigger to control when the updates happen.

check this

if you need something more advance with Energy Management:

Thank you guys. I wish I could focus on this, but it takes more time than I have to learn and get it right (even though I do enjoy learning it and doing it myself).

I’ve been trying with trigger template sensors and I’m more confused than ever.

Can someone please help with the yaml that creates a sensor at 11:45pm every day from the value of sensor.propane_tank_neevo_371_gallons

I already have the yaml to get the daily value of sensor.propane_tank_neevo_371_gallons every 14400 seconds (twice per day, in even thought it should not change, just case it fails the first time). But, instead of a scan interval, I assume the time should be hard coded, perhaps 2am and 2pm (should get the same value both times).

Thank you.

Okay, I just can’t.

template:
  - trigger:
    - platform: time
      at:
        - "23:00"
  - sensor:
      name: "Propane Tank Neevo 371 Gallons Yesterday"
      value_template: "sensor.propane_tank_neevo_371_gallons"
      state_class: measurement
      unit_of_measurement: "Gallons"

Can I pay someone here to do this for me?