A custom component for Home Assistant that will import Green Button Usage and Cost data, and then generate statistics which can be added to the Energy dashboard.
The Green Button data needs to be in the ESPI XML Schema Definition, contained in an Atom Syndication format.
This custom component has been developed to handle the Green Button data available from Hydro Ottawa and Enbridge Gas. It may or may not work with other sources of Green Button data.
- Copy the green_button folder under custom_components into your Home Assistant custom_components folder
- Restart Home Assistant
- In the HA UI go to "Configuration" -> "Integrations". Click "+" and search for "Green Button"
- Complete the installation with or without providing Green Button XML data
- If you skip the XML import during setup, you can import it later using the Add Entry button on the Green Button integration or via Developer Tools → Actions → 'Import Green Button ESPI XML'
By default, importing electricity usage and billing data will create a "Home Electricity" Green Button device, with entities named "sensor.home_electricity_cost" and "sensor.home_electricity_usage". Importing Natural Gas data will create by default a "Home Natural Gas" device, with "sensor.home_natural_gas_cost" and "sensor.home_natural_gas_usage" sensors.
Statistics will automatically be generated for these sensors and can be imported into the Energy dashboard. The "usage" sensors have a state_class of "total_increasing", and the "cost" sensors have a state_class of "total". It's the statistics that you'll want to examine for periodic usage rather than the raw data in the sensors themselves.
It may take a few minutes for all the associated statisitics to be generated. The related sensor may not be available to add into the Energy dashbord until the generation is completed.
Review the Green Button Component Description for detail on how the Green Button custom component functions.
Green Button XML blocks do not need to be imported in chronological order, and can have gaps between the dates for imported blocks of data. Any data that is imported that overlaps pre-existing data will be merged with that data. If there is overlapping data, the statistics generation will resolve them. The drawback to overlapping data will be a larger than necessary green_button_xml file in /config/.storage
When importing xml files, it's probably easiest to locate the file to be imported in Home Assistant's share folder, which appears under the config folder, and can be referenced in the file path using /share//<green_button_xml_file.xml>
The Green Button spec says that the default power-of-ten-multiplier for cost is "-5", but that providers may choose to use a different value. The Green Button component allows the default multipliers for cost for gas and for electricity to be overridden if your provider uses a non-standard cost power-of-ten-multiplier.
If the value is ever changed after Green Button data has been imported, the new value will apply to any new imported cost data. To force recalculation of previously-imported costs, run the Recalculate Green Button Cost Statistics action under Developer Tools -> Actions.
There are several actions (services) related to the Green Button custom component available under Developer Tools → Actions. As of this writing, they are:
- Log Green Button Meter Reading Intervals
- Log Stored Green Button XML Info
- Delete Green Button Statistics
- Import Green Button ESPI XML
- Clear Stored Green Button XML Data
- Recalculate Green Button Cost Statistics
None of the original tests or development support files such as .pre-commit-config.yaml have been updated or, for that matter, used when updating this component.
This project was originally generated from @oncleben31's Home Assistant Custom Component Cookiecutter template.
Code template was mainly taken from @Ludeeus's integration_blueprint template.
Forked from the Green Button project created by @vqvu.