MindFreeze / ha-sankey-chart

A Home Assistant lovelace card to display a sankey chart. For example for power consumption
MIT License
348 stars 15 forks source link

feat(#158): Convert units to CO2 or $ #159

Closed madsciencetist closed 5 months ago

madsciencetist commented 6 months ago

A sankey chart used to display energy usage (gas and/or electric) can now convert the native energy units (kWh or cubic feet of gas) into their corresponding monetary cost or CO2 intensity.

Cost:

energy_date_selection: true
convert_units_to: monetary
monetary_unit: USD
gas_price: 0.022405
electricity_price: 0.30112

image Note that while HA's Energy Dashboard knows and tracks utility prices, the API does not make them available to us outside of over-summarizing statistics like total cost. Thus utility cost must be supplied to the sankey config, and only fixed rates are supported.

CO2 intensity:

energy_date_selection: true
convert_units_to: gCO2
unit_prefix: k

image

For carbon intensity, we are able to use (abuse) the HA API to actually get the carbon intensity of all electricity usage on an hourly basis. Gas is assumed to have a fixed (but configurable) carbon intensity of 66.6 gCO2 per cubic foot.

Closes #158

madsciencetist commented 6 months ago

This is my first time using lovelace, TS or JS, so feel free to correct what doesn't make sense.