Home

Awesome

MyElectricalData Statistics Importer for Home Assistant

This Python script retrieves statistics from MyElectricalData's cache database and imports them into Home Assistant via the WebSocket API.

Long Term Statistics will be created in Home Assistant and usable in the Energy Dashboard.

Pre-requisites

Installation

  1. Clone this repository or download the source code
  2. The folder containing the source code should be preferrably located in Home Assistant's folder config
  3. If you don't intend to execute the script from Home Assistant environment, install the required packages by running the following command:
pip install -r requirements.txt

Configuration

Rename the script_config.example.yaml file to script_config.yaml and edit it to suit your needs. All the following keys are mandatory:

Usage

python statistics_importer.py [-h] [-d] [-f]

The script accepts the following options:

Automation with Home Assistant

The script can be accessed as a service in Home Assistant with the Shell Command integration.

Example of configuration.yaml entry in Home Assistant, assuming the folder statistics_importer is located in the folder config:

shell_command:
    statistics_import: python statistics_importer/statistics_importer.py
    statistics_delete_all: python statistics_importer/statistics_importer.py -d

You can then create an automation calling the service shell_command.statistics_import periodically or when MyElectricalData cache is updated.

Warning

License

This script is released under the MIT License.