I put together a few sensors to grab prices for Michigan Gas Utilities. It will scrape the site once per day for updates. MI Gas uses Ccf but HA does not currently support that so the price is converted to USD/ft³ in the first example. The second example gives the Ccf price that you would see on your bill if you combine volumetric charges. There is also a daily customer charge scraped in the third example. The bill will also include tax which is not represented here but you can find on your bill. Hopefully someone finds this useful.
- platform: scrape
resource: https://www.michigangasutilities.com/payment-bill/mi-rates
name: "MI GAS Cost USD cubed feet"
device_class: 'monetary'
unit_of_measurement: 'USD/ft³'
select: 'td:nth-of-type(4)'
scan_interval: 86400
value_template: >
{{ ((value.split('$')[1]) | float) / 100 }}
- platform: scrape
resource: https://www.michigangasutilities.com/payment-bill/mi-rates
name: "MI Gas Cost CCF"
device_class: 'monetary'
unit_of_measurement: 'USD/Ccf'
select: 'td:nth-of-type(4)'
scan_interval: 86400
value_template: >
{{ ((value.split('$')[1]) | float) }}
- platform: scrape
resource: https://www.michigangasutilities.com/payment-bill/mi-rates
name: "MI Gas Daily customer charge"
device_class: 'monetary'
unit_of_measurement: 'USD/ft³'
select: 'td:nth-of-type(2)'
scan_interval: 86400
value_template: >
{{ ((value.split('$')[1]).split(' ')[0] | float) }}
Use Julian days to keep track of daily customer charge. Increment 1/24th per hour.
- sensor:
- name: daily customer charge increment
device_class: gas
unit_of_measurement: 'ft³'
state_class: 'total_increasing'
state: >-
{{ ((now().strftime('%j') | float) - 1) + (1/24 * now().strftime('%H') | float) }}