### Install enedisgateway2mqtt Helm Chart Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/chart/README.md Use this command to install the chart with a release name and a custom values file. ```console helm upgrade --install enedisgateway2mqtt Chart/ -f values.yaml ``` -------------------------------- ### Initialize Python Virtual Environment with Poetry Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/20.-Dev.-Environment Run this command to initialize the Python virtual environment managed by Poetry. Ensure Poetry is installed. ```bash make install ``` -------------------------------- ### Install enedisgateway2mqtt with Custom Values Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/chart/README.md Install the chart using the `--set` argument to override specific values, such as the timezone. Alternatively, provide a YAML file specifying the values. ```console helm install enedisgateway2mqtt \ --set env.TZ="America/New York" \ m4dm4rtig4n/enedisgateway2mqtt ``` ```console helm upgrade --install enedisgateway2mqtt m4dm4rtig4n/enedisgateway2mqtt -f values.yaml ``` -------------------------------- ### Run Application Locally (Classic Mode) Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/20.-Dev.-Environment Start the service in classic local mode using the make command or by directly executing the main Python script. ```bash make run ``` ```bash poetry run src/main.py ``` -------------------------------- ### Configuration YAML Example Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log Update your config.yaml file to use the new template provided with version 0.8.0. ```yaml config.yaml ``` -------------------------------- ### Configure Local Environment Variables Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/20.-Dev.-Environment Copy the example environment file to `.env` and set necessary variables for local execution. These variables control application paths and debug mode. ```bash APPLICATION_PATH=src/ APPLICATION_PATH_DATA=data/cache/ APPLICATION_PATH_LOG=data/log DEBUG=true ``` -------------------------------- ### Get Subscription Comparison with GET /price Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Provides a comparative analysis of subscriptions (BASE, HC/HP) based on the actual consumption history of a usage point. Use the PUT method to recalculate and update the cache. ```bash # Consulter le comparatif tarifaire curl -s http://localhost:5000/price/12345678901234 | python3 -m json.tool ``` ```bash # Recalculer le comparatif (met à jour le cache) curl -s -X PUT http://localhost:5000/price/12345678901234 | python3 -m json.tool ``` -------------------------------- ### Run MyElectricalData Docker Container Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt This command starts a Docker container for MyElectricalData, mapping the local directory to /data for persistence and exposing the API on port 5000. It also includes a check to verify the service is running. ```bash # Démarrage simple docker run -it --restart=unless-stopped \ -v $(pwd):/data \ -p 5000:5000 \ -e TZ="Europe/Paris" \ m4dm4rtig4n/myelectricaldata:latest # Vérification que le service répond curl http://localhost:5000/ping # Réponse : "ok" ``` -------------------------------- ### Force Full Data Import with GET /import Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Immediately triggers the import of all available data for a usage point from the gateway. Supports targeted imports for specific data types like consumption or production. ```bash # Import complet (toutes les données) curl -s "http://localhost:5000/import/12345678901234" ``` ```bash # Import ciblé : uniquement la consommation journalière curl -s "http://localhost:5000/import/12345678901234/consumption" ``` ```bash # Import ciblé : uniquement la consommation horaire curl -s "http://localhost:5000/import/12345678901234/consumption_detail" ``` ```bash # Autres cibles disponibles : # account_status | contract | addresses | production | production_detail # consumption_max_power | stat | mqtt | home_assistant | influxdb ``` -------------------------------- ### Run Application in Debug Mode with Third-Party Components Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/20.-Dev.-Environment Start the service in debug mode, which includes third-party components like InfluxDB and MQTT. This requires a Docker socket and setting the DEBUG variable to true in the `.env` file. ```bash make debug ``` ```bash poetry run src/main.py ``` -------------------------------- ### Get RTE Ecowatt Data with GET /ecowatt Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves Ecowatt (electrical sobriety signals) data from the local cache. Use the PUT method to force a refresh. ```bash # Lecture des données Ecowatt curl -s http://localhost:5000/ecowatt | python3 -m json.tool ``` ```bash # Forcer le rafraîchissement curl -s -X PUT http://localhost:5000/ecowatt ``` -------------------------------- ### Get EDF Tempo Data with GET /tempo Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves EDF Tempo (Blue/White/Red days) data from the local cache. Use the PUT method to force a cache refresh. ```bash # Lecture des données Tempo curl -s http://localhost:5000/tempo | python3 -m json.tool ``` ```bash # Forcer le rafraîchissement du cache Tempo depuis la passerelle curl -s -X PUT http://localhost:5000/tempo ``` -------------------------------- ### Retrieve Daily Data with GET /daily Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Fetches daily consumption or production data from the local cache for a given usage point ID and date range. Ensure the measurement direction is correctly specified as 'consumption' or 'production'. ```bash # Consommation journalière du 1er au 30 janvier 2024 curl -s "http://localhost:5000/daily/12345678901234/consumption/2024-01-01/2024-01-30" \ | python3 -m json.tool # Réponse : # { # "unit": "w", # "data": { # "2024-01-01": 12540, # "2024-01-02": 9870, # "2024-01-03": 11200, # ... # } # } ``` ```bash # Production journalière solaire curl -s "http://localhost:5000/daily/12345678901234/production/2024-06-01/2024-06-30" \ | python3 -m json.tool ``` -------------------------------- ### Check Service Status with GET /ping Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Use this endpoint to verify if the service is operational. It's commonly used for Docker/Kubernetes health checks. ```bash curl -s http://localhost:5000/ping # Réponse : "ok" ``` ```bash curl -s http://localhost:5000/import_status # Réponse : true (importation en cours) ou false (idle) ``` ```bash curl -s http://localhost:5000/gateway_status | python3 -m json.tool # Réponse : # { # "status": true, # "information": null, # "nb_client": 142, # "waiting_estimation": "2min", # "version": "1.2.3" # } ``` -------------------------------- ### Manual Unit Test Execution with Pytest Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/tests/TESTING.md Execute unit tests locally using pytest. Ensure pytest, pytest-cov, and pytest-mock are installed. This command also generates an XML coverage report. ```commandline pip install pytest pytest-cov pytest-mock requests-mock python -m pytest --cov=src/ --cov-report=xml ``` -------------------------------- ### Automated Unit Test Execution in GitHub Actions Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/tests/TESTING.md A GitHub Actions workflow to automate the execution of unit tests. It includes steps for setting up Python, installing dependencies, linting with Ruff, running tests with pytest, and optionally uploading coverage reports to Codecov. ```yaml name: Run Pytests on: # Run workflow automatically whenever the workflow, app or tests are updated push: paths: - .github/workflows/pytest.yaml # Assuming this file is stored in .github/workflows/pytest.yaml - src/** - tests/** jobs: pytest: name: Run pytests runs-on: ubuntu-latest steps: - name: generate FR locale run: sudo locale-gen fr_FR.UTF-8 - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.12' cache: 'pip' - name: Lint with Ruff # Running an optional linter step run: | pip install ruff ruff --output-format=github src/ continue-on-error: true - name: Install application dependencies run: | python -m pip install --upgrade pip pip install -r src/requirements.txt - name: Test with pytest run: | pip install pytest pytest-cov pytest-mock requests-mock python -m pytest --cov=src/ --cov-report=xml - name: Upload coverage reports to Codecov # Optional: Run codecov. Requires: secrets.CODECOV_TOKEN uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} continue-on-error: true ``` -------------------------------- ### Clear Local Cache with GET /reset Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Deletes all local cache data for a usage point, forcing a re-download on the next cycle. Use 'delete' to remove the PDL completely or 'reset_gateway' to clear the remote cache on the gateway. ```bash # Effacer tout le cache local du PDL curl -s "http://localhost:5000/reset/12345678901234" ``` ```bash # Supprimer complètement le PDL de la base curl -s "http://localhost:5000/delete/12345678901234" ``` ```bash # Effacer le cache distant sur la passerelle myelectricaldata.fr curl -s "http://localhost:5000/reset_gateway/12345678901234" ``` -------------------------------- ### Retrieve Hourly Data with GET /detail Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves detailed hourly or half-hourly consumption or production data for a specified usage point ID and date range. This requires hourly collection to be enabled on Enedis. ```bash # Consommation détaillée (horaire) sur une semaine curl -s "http://localhost:5000/detail/12345678901234/consumption/2024-01-15/2024-01-22" \ | python3 -m json.tool # Réponse : # { # "unit": "w", # "data": { # "2024-01-15 00:00:00": 320, # "2024-01-15 00:30:00": 290, # "2024-01-15 01:00:00": 275, # ... # } # } ``` -------------------------------- ### Show Loading Overlay and Reset Data Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Shows a loading overlay with a specified message, then makes an AJAX GET request to reset data. Hides the overlay and reloads the page upon completion. ```javascript $("#delete\_data").click(function () { $("#bottom\_menu").removeClass("active") $.LoadingOverlay("show", loading); $.ajax({ type: 'GET', url: '/reset/' + usage\_point\_id }) .done(function (data) { // data = JSON.parse(JSON.stringify(data)) $.LoadingOverlay("hide"); location.reload(); }) }); ``` -------------------------------- ### Reset Specific Date Data with GET /usage_point_id/{usage_point_id}/{target}/reset/{date} Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Deletes specific data types for a given date from the local cache. Supports blacklisting/whitelisting dates and forcing imports for specific dates. ```bash # Supprimer la consommation journalière du 15 janvier 2024 curl -s "http://localhost:5000/usage_point_id/12345678901234/consumption/reset/2024-01-15" ``` ```bash # Blacklister une date (elle ne sera plus importée) curl -s "http://localhost:5000/usage_point_id/12345678901234/consumption_detail/blacklist/2024-01-15" ``` ```bash # Retirer une date de la blacklist curl -s "http://localhost:5000/usage_point_id/12345678901234/consumption_detail/whitelist/2024-01-15" ``` ```bash # Forcer l'import d'une date spécifique curl -s "http://localhost:5000/usage_point_id/12345678901234/consumption/import/2024-01-15" ``` -------------------------------- ### Configure Off-Peak Hours for Delivery Point Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Manually define off-peak hours for a delivery point, especially useful if Enedis does not provide this information or for analyzing consumption patterns across different plans. This format is used for each day of the week, starting with Monday (index 0). ```yaml offpeak_hours_0: 3H40-8h10;12H40-16H10 offpeak_hours_1: 3H40-8h10;12H40-16H10 offpeak_hours_2: 0H00-23h59 offpeak_hours_3: 3H40-8h10;12H40-16H10 offpeak_hours_4: 3H40-8h10;12H40-16H10 offpeak_hours_5: 0H00-23h59 offpeak_hours_6: 0H00-23h59 ``` -------------------------------- ### Open Configuration Dialog for New Account Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Attaches a click handler to the 'add_account' element. When clicked, it removes the 'active' class from 'bottom_menu', sets the dialog's URL to '/new_account/', and opens the configuration dialog. ```javascript $("#add\_account").click(function (e) { $("#bottom\_menu").removeClass("active") $("#configuration").data('url', "/new\_account/").dialog('open'); e.preventDefault(); }); ``` -------------------------------- ### Initialize and Manage Help Dialog Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Initializes a jQuery UI dialog for displaying help content. The dialog is resizable, modal, and its content is dynamically set based on the 'alt' attribute of the clicked help icon. ```javascript var $dialog = $('
').dialog({ title: "Aide", autoOpen: false, resizable: false, modal: true, maxWidth: $(window).width(), minWidth: $(window).width()/2, }); $(".help").click(function () { $dialog.dialog('open'); $dialog.html($(this).attr("alt")); }); ``` -------------------------------- ### Initialize DataTables with Configuration Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Initializes two DataTables instances, 'dataTableConsommation' and 'dataTableProduction', using the defined 'datatable_config'. ```javascript $"#dataTableConsommation".DataTable(datatable\_config); $('#dataTableProduction').DataTable(datatable\_config); ``` -------------------------------- ### Configure MyElectricalData Settings Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt This YAML configuration file defines global settings, export targets (Home Assistant, InfluxDB, MQTT), and individual electricity delivery points (PDL) with their specific parameters. ```yaml # /data/config.yaml port: 5000 debug: false log2file: false cycle: 14400 # Intervalle d'importation en secondes (minimum 3600) wipe_cache: false wipe_influxdb: false # Cache externe (optionnel, SQLite local par défaut) # storage_uri: postgresql://myelectricaldata:myelectricaldata@postgres:5432/myelectricaldata # --- Export Home Assistant via MQTT Auto-Discovery --- home_assistant: enable: true discovery_prefix: homeassistant # --- Export vers l'onglet Energy de Home Assistant (WebSocket) --- home_assistant_ws: enable: true ssl: true token: MON_TOKEN_HA_LONGUE_DUREE url: myhomeassistant.domain.fr max_date: "2022-01-01" # --- Export InfluxDB v2 --- influxdb: enable: true scheme: http hostname: influxdb port: 8086 token: MY_INFLUX_TOKEN org: myorg bucket: myelectricaldata method: synchronous # synchronous | asynchronous | batching # --- Export MQTT --- mqtt: enable: true hostname: mosquitto port: 1883 username: null password: null prefix: myelectricaldata client_id: myelectricaldata retain: true qos: 0 # --- Données Tempo EDF --- tempo: enable: true # --- SSL pour la passerelle distante --- ssl: gateway: true certfile: "" keyfile: "" # --- Points de livraison --- myelectricaldata: "12345678901234": enable: true token: MON_TOKEN_PDL name: "Maison principale" addresses: true cache: true consumption: true consumption_detail: true consumption_price_base: '0.2516' consumption_price_hc: '0.2068' consumption_price_hp: '0.2700' consumption_max_date: "2021-01-01" consumption_detail_max_date: "2021-01-01" offpeak_hours_0: "22H00-6H00" # Lundi offpeak_hours_1: "22H00-6H00" # Mardi offpeak_hours_2: "22H00-6H00" # Mercredi offpeak_hours_3: "22H00-6H00" # Jeudi offpeak_hours_4: "22H00-6H00" # Vendredi offpeak_hours_5: "22H00-6H00;12H00-14H00" # Samedi offpeak_hours_6: "22H00-6H00;12H00-14H00" # Dimanche plan: HC/HP # BASE | HC/HP | TEMPO production: false production_detail: false production_price: '0.0' refresh_addresse: false refresh_contract: false ``` -------------------------------- ### Home Assistant MQTT Auto-Discovery Configuration Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Configure Home Assistant integration via MQTT auto-discovery. Ensure the discovery_prefix matches HA's configuration. ```yaml # Dans config.yaml home_assistant: enable: true discovery_prefix: homeassistant # Doit correspondre au préfixe configuré dans HA mqtt: enable: true hostname: mosquitto port: 1883 username: null password: null prefix: myelectricaldata client_id: myelectricaldata retain: true qos: 0 ``` -------------------------------- ### Configure Home Assistant MQTT Discovery Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Enable or disable MQTT exports for Home Assistant's auto-discovery feature. The default discovery prefix is 'homeassistant'. ```yaml home_assistant: enable: "true" discovery_prefix: "homeassistant" ``` -------------------------------- ### Deploy MyElectricalData with Docker Compose Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt This Docker Compose configuration sets up MyElectricalData along with its dependencies, Mosquitto for MQTT and InfluxDB for time-series data storage, ensuring all services are linked and configured for deployment. ```yaml version: "3.9" services: myelectricaldata: image: m4dm4rtig4n/myelectricaldata:latest restart: unless-stopped volumes: - ./:/data environment: TZ: Europe/Paris ports: - '5000:5000' depends_on: - mosquitto - influxdb mosquitto: image: eclipse-mosquitto:latest restart: unless-stopped ports: - '1883:1883' influxdb: image: influxdb:2.7 restart: unless-stopped ports: - '8086:8086' environment: DOCKER_INFLUXDB_INIT_MODE: setup DOCKER_INFLUXDB_INIT_USERNAME: admin DOCKER_INFLUXDB_INIT_PASSWORD: password DOCKER_INFLUXDB_INIT_ORG: myorg DOCKER_INFLUXDB_INIT_BUCKET: myelectricaldata DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: MY_INFLUX_TOKEN ``` -------------------------------- ### Configure MQTT Export Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Enable or disable MQTT exports. Configure connection details, authentication, prefix, client ID, retain, and QoS. ```yaml mqtt: enable: "false" hostname: "localhost" port: 1883 username: "null" password: "null" prefix: "myelectricaldata" client_id: "myelectricaldata" retain: "true" qos: 0 ``` -------------------------------- ### Datatable Configuration Object Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Configuration object for initializing DataTables, including column definitions, ordering, and language settings. Column definitions specify class names and widths. ```javascript let datatable\_config = { columnDefs: [ { targets: -1, className: 'dt-body-center dt-head-center', // orderDataType: "dom-select", // render: function (data, type, row, meta) { // if (type === 'sort') { // switch (data) { // case 'Blaclist': // return 0; // case 'Uncommon': // return 1; // case 'Rare': // return 2; // case 'Lengendary': // return 3; // } // } // } }, { targets: -2, className: 'dt-body-center dt-head-center', }, { targets: -3, className: 'dt-head-center', }, { targets: -4, className: 'dt-body-center dt-head-center', } ], columns: [ {"width": "30%"}, {"width": "30%"}, {"width": "30%"}, {"width": "10px"}, {"width": "50px"}, {"width": "50px"}, {"width": "50px"}, ], order: [[0, 'desc']], language: french } ``` -------------------------------- ### Subscription Comparison Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Provides a comparative analysis of subscription plans (BASE, HC/HP) based on the actual consumption history of a usage point. Can also trigger a recalculation. ```APIDOC ## GET /price/{usage_point_id} — Subscription Comparison Returns a comparative analysis of subscription plans (BASE, HC/HP) based on the actual consumption history of the usage point. Can also trigger a recalculation. ### Method GET, PUT ### Endpoint /price/{usage_point_id} ### Parameters #### Path Parameters - **usage_point_id** (string) - Required - The unique identifier for the usage point. ### Description - **GET**: Retrieves the subscription comparison data. - **PUT**: Recalculates and updates the subscription comparison data (updates the cache). ### Request Example ```bash # View tariff comparison curl -s http://localhost:5000/price/12345678901234 | python3 -m json.tool # Recalculate comparison curl -s -X PUT http://localhost:5000/price/12345678901234 | python3 -m json.tool ``` ``` -------------------------------- ### Home Assistant WebSocket Configuration Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log Configure Home Assistant integration using WebSocket for data transfer. Ensure SSL is enabled if required and obtain the token from your Home Assistant profile. ```yaml home_assistant_ws: enable: true ssl: true token: HOME_ASSISTANT_TOKEN_GENERATE_IN_PROFILE_TABS_(BOTTOM) url: myhomeassistant.domain.fr ``` -------------------------------- ### Open Configuration Dialog for Specific Usage Point Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Attaches a click handler to the 'config_data' element. When clicked, it removes the 'active' class from 'bottom_menu', sets the dialog's URL, and opens the configuration dialog. ```javascript $("#config\_data").click(function (e) { $("#bottom\_menu").removeClass("active") $("#configuration").data('url', "/configuration/{{usage\_point\_id}}").dialog('open'); e.preventDefault(); }); ``` -------------------------------- ### Home Assistant WebSocket Configuration Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Configure Home Assistant integration via WebSocket for the Energy tab. Requires SSL/WSS if HA uses HTTPS and a long-lived access token. ```yaml # Dans config.yaml home_assistant_ws: enable: true ssl: true # WSS si HA en HTTPS token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... # Jeton longue durée depuis Profile HA url: myhomeassistant.domain.fr max_date: "2022-01-01" # Date de début d'import vers l'onglet Energy purge: false ``` -------------------------------- ### Force Full Data Import Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Immediately triggers the import of all available data for a usage point from the gateway. Supports targeted imports for specific data types. ```APIDOC ## GET /import/{usage_point_id} — Force Full Data Import Immediately triggers the import of all available data for a usage point from the gateway. Supports targeted imports for specific data types. ### Method GET ### Endpoint /import/{usage_point_id} ### Parameters #### Path Parameters - **usage_point_id** (string) - Required - The unique identifier for the usage point. ### Description This endpoint initiates data import. It can be used for a full import or targeted imports by specifying the data type. #### Targeted Imports - `/import/{usage_point_id}/consumption` - Import only daily consumption data. - `/import/{usage_point_id}/consumption_detail` - Import only hourly consumption data. #### Other Available Targets `account_status`, `contract`, `addresses`, `production`, `production_detail`, `consumption_max_power`, `stat`, `mqtt`, `home_assistant`, `influxdb` ### Request Example ```bash # Full import (all data) curl -s "http://localhost:5000/import/12345678901234" # Targeted import: only daily consumption curl -s "http://localhost:5000/import/12345678901234/consumption" # Targeted import: only hourly consumption curl -s "http://localhost:5000/import/12345678901234/consumption_detail" ``` ``` -------------------------------- ### Make Configuration Dialog Draggable Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Enables dragging functionality for the 'configuration' element, constrained within the browser window. ```javascript $"#configuration".draggable({ containment: 'window' }); ``` -------------------------------- ### Swagger API Documentation Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/05.-API Access the interactive API documentation through Swagger to understand and test the available endpoints for retrieving your data. ```APIDOC ## Swagger API Documentation ### Description Access the interactive API documentation through Swagger to understand and test the available endpoints for retrieving your data. ### Endpoint /docs ### Example URL http://enedis.mondomaine.fr/docs ``` -------------------------------- ### Configure Home Assistant Energy Tab Export Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Enable or disable exports to Home Assistant's Energy tab via WebSocket. Configure SSL, token, URL, and data export date limits. ```yaml home_assistant_ws: enable: "true" ssl: "true" token: "YOUR_HA_TOKEN" url: "YOUR_HA_URL" max_date: "YYYY-MM-DD" ``` -------------------------------- ### Home Assistant MQTT Sensor Renaming - Potential Duplicates Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log If duplicate sensors with a '_2' suffix appear after renaming, remove all entities again and restart the client. ```text sensor.myelectricaldata_XXXXXXXXXXXXXX ``` ```text sensor.myelectricaldata_consumption_XXXXXXXXXXXXXX ``` ```text sensor.myelectricaldata_history_XXXXXXXXXXXXXX ``` ```text myelectricaldata_consumption_history_XXXXXXXXXXXXXX ``` ```text sensor.myelectricaldata_consumption_last5day_XXXXXXXXXXXXXX ``` ```text sensor.myelectricaldata_production_XXXXXXXXXXXXXX ``` ```text myelectricaldata_production_history_XXXXXXXXXXXXXX ``` ```text sensor.myelectricaldata_production_last5day_XXXXXXXXXXXXXX ``` -------------------------------- ### Home Assistant Sensor Naming Convention Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log Follow this naming convention for main sensors in Home Assistant to ensure proper tracking of consumption data. ```text myelectricaldata:NUMERODEPDL_PLAN_consumption_ ``` ```text myelectricaldata:01234567891456_bluehc_consumption ``` ```text myelectricaldata:01234567891456_hp_consumption ``` ```text myelectricaldata:01234567891456_hc_consumption ``` ```text myelectricaldata:01234567891456_base_consumption ``` -------------------------------- ### Home Assistant Cost Sensor Naming Convention Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log Use this naming convention for sensors tracking total costs in Home Assistant. ```text myelectricaldata:NUMERODEPDL_PLAN_consumption_cost_ ``` ```text myelectricaldata:01234567891456_bluehc_consumption_cost ``` ```text myelectricaldata:01234567891456_hp_consumption_cost ``` ```text myelectricaldata:01234567891456_hc_consumption_cost ``` ```text myelectricaldata:01234567891456_base_consumption_cost ``` -------------------------------- ### Configure InfluxDB v2.X Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Configuration for InfluxDB version 2.X, including connection details and export method. Use a specific token, organization, and bucket. ```yaml influxdb: enable: 'true' hostname: influxdb port: 8086 token: MY_TOKEN org: MY_ORG bucket: MY_BUCKET method: batching ``` -------------------------------- ### InfluxDB v2.x / VictoriaMetrics Configuration Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Configure InfluxDB v2.x or VictoriaMetrics with scheme, hostname, port, token, org, bucket, and batching options. Set vm_mode to true for VictoriaMetrics. ```yaml influxdb: enable: true scheme: http hostname: influxdb port: 8086 # 8428 pour VictoriaMetrics token: MY_TOKEN org: MY_ORG bucket: myelectricaldata method: batching vm_mode: false # true pour VictoriaMetrics batching_options: batch_size: 1000 flush_interval: 1000 jitter_interval: 0 retry_interval: 5000 max_retry_time: 180000 max_retries: 5 max_retry_delay: 125000 exponential_base: 2 ``` -------------------------------- ### Initialize and Configure jQuery UI Dialog for Configuration Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Initializes a jQuery UI dialog for configuration settings. It is set to be non-resizable, modal, and centered. It also defines custom buttons for 'Cancel' and 'Save'. ```javascript $("#configuration").dialog({ autoOpen: false, autoResize:false, draggable: false, resizable: false, width: 700, position: {my: "center center", at: "center center", of: window}, modal: true, maxHeight: $(window).height(), open: function (event, ui) { $("body").css({overflow: 'hidden'}) }, beforeClose: function (event, ui) { $("body").css({overflow: 'inherit'}) }, buttons: { cancel: { text: 'Annuler', class: 'btn-blue', click: function () { $(this).dialog("close"); } }, formSubmit: { text: 'Sauvegarder', class: 'btn-blue', click: function (event) { sendForm() } }, } }); ``` -------------------------------- ### Daily Consumption/Production Data Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves daily data from the local cache for a given usage point ID and date range. Supports 'consumption' or 'production' measurement directions. ```APIDOC ## GET /daily/{usage_point_id}/{measurement_direction}/{begin}/{end} — Daily Consumption/Production Data Retrieves daily data from the local cache for a given usage point ID, over a date range. `measurement_direction` accepts `consumption` or `production`. ### Method GET ### Endpoint /daily/{usage_point_id}/{measurement_direction}/{begin}/{end} ### Parameters #### Path Parameters - **usage_point_id** (string) - Required - The unique identifier for the usage point. - **measurement_direction** (string) - Required - The type of measurement, either 'consumption' or 'production'. - **begin** (string) - Required - The start date in YYYY-MM-DD format. - **end** (string) - Required - The end date in YYYY-MM-DD format. ### Response #### Success Response (200) - **unit** (string) - The unit of measurement (e.g., 'w'). - **data** (object) - An object containing date-value pairs for the requested period. - **YYYY-MM-DD** (number) - The measured value for the specific date. ### Request Example ```bash # Daily consumption from January 1st to January 30th, 2024 curl -s "http://localhost:5000/daily/12345678901234/consumption/2024-01-01/2024-01-30" | python3 -m json.tool ``` ### Response Example ```json { "unit": "w", "data": { "2024-01-01": 12540, "2024-01-02": 9870, "2024-01-03": 11200 } } ``` ``` -------------------------------- ### Configure InfluxDB v1.8 Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/03.-Configuration Configuration for InfluxDB version 1.8, including connection details and export method. Use 'USERNAME:PASSWORD' for the token and 'DATABASE/RETENTION' for the bucket. ```yaml influxdb: enable: 'true' hostname: influxdb port: 8086 token: USERNAME:PASSWORD org: "-" bucket: "DATABASE/RETENTION" method: asynchronous ``` -------------------------------- ### Home Assistant MQTT Sensor Renaming Procedure Source: https://github.com/myelectricaldata/myelectricaldata_import/wiki/90.-Change-Log Follow these steps to rename MQTT sensors in Home Assistant to avoid duplicates after version updates. This involves stopping the client, cleaning MQTT queues, and removing old entities. ```text home_assistant/sensor/myelectricaldata_... ``` -------------------------------- ### Display Confirmation Dialog for Redirection Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Attaches a click handler to elements with the class 'alert_redirect'. When clicked, it displays a confirmation dialog using $.confirm before redirecting the user to a specified URL. ```javascript $(".alert\_redirect").click(function (e) { var url = $(this).attr("about") $.confirm({ columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', containerFluid: true, // this will add 'container-fluid' instead of 'container' boxWidth: '600px', useBootstrap: false, title: 'Confirmation', content: 'Vous allez être rediriger vers ' + url, buttons: { confirm: { text: 'OK!', btnClass: 'btn-blue', action: function () { location.href = url; } }, cancel: { text: 'Non merci', btnClass: 'btn-blue', } } }); }); ``` -------------------------------- ### AJAX Form Submission Function Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Handles the submission of the configuration form. It validates the form, shows a loading overlay, sends form data via AJAX POST, and reloads the page on success. ```javascript function sendForm() { console.log($('#configuration').data('url')) if ($('#formConfiguration').valid()) { $.LoadingOverlay("show", loading); var formData = { {{configurationInput}} }; $.ajax({ type: "POST", url: $('#configuration').data('url'), data: formData, dataType: "json", encode: true, }).done(function (data) { window.location.reload(); }); } } ``` -------------------------------- ### Hourly Consumption/Production Data Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves hourly or half-hourly data from the local cache for a given usage point ID and date range. Requires hourly collection to be enabled. ```APIDOC ## GET /detail/{usage_point_id}/{measurement_direction}/{begin}/{end} — Hourly Consumption/Production Data Retrieves half-hourly or hourly consumption or production data over a date range. Requires hourly collection to be enabled on Enedis. ### Method GET ### Endpoint /detail/{usage_point_id}/{measurement_direction}/{begin}/{end} ### Parameters #### Path Parameters - **usage_point_id** (string) - Required - The unique identifier for the usage point. - **measurement_direction** (string) - Required - The type of measurement, either 'consumption' or 'production'. - **begin** (string) - Required - The start date in YYYY-MM-DD format. - **end** (string) - Required - The end date in YYYY-MM-DD format. ### Response #### Success Response (200) - **unit** (string) - The unit of measurement (e.g., 'w'). - **data** (object) - An object containing timestamp-value pairs for the requested period. - **YYYY-MM-DD HH:MM:SS** (number) - The measured value for the specific timestamp. ### Request Example ```bash # Detailed (hourly) consumption over a week curl -s "http://localhost:5000/detail/12345678901234/consumption/2024-01-15/2024-01-22" | python3 -m json.tool ``` ### Response Example ```json { "unit": "w", "data": { "2024-01-15 00:00:00": 320, "2024-01-15 00:30:00": 290, "2024-01-15 01:00:00": 275 } } ``` ``` -------------------------------- ### Redirect on Usage Point Selection Change Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html When the selected value of the 'select_usage_point_id' dropdown changes, this code shows a loading overlay and redirects the user to a new URL based on the selected value. ```javascript $"#select\_usage\_point\_id".change(function () { $.LoadingOverlay("show", loading); location.href = "/usage\_point\_id/" + $("#select\_usage\_point\_id").val(); }); ``` -------------------------------- ### Copy Text to Clipboard Function Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html A utility function to copy provided text to the system clipboard. It creates a temporary textarea element, sets its value, selects it, executes the copy command, and then removes the element. ```javascript function copyToClipboard(text) { var dummy = document.createElement("textarea"); document.body.appendChild(dummy); dummy.value = text; dummy.select(); document.execCommand("copy"); document.body.removeChild(dummy); } ``` -------------------------------- ### Custom Off-Peak Hours Configuration Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Manually configure custom off-peak (HC/HP) hours for energy plans that differ from standard Enedis returns. Format is HHHmm-HHHmm or multiple ranges separated by ';'. ```yaml myelectricaldata: "12345678901234": plan: HC/HP # Format : HHHmm-HHHmm ou plages multiples séparées par ; offpeak_hours_0: "22H00-6H00" # Lundi offpeak_hours_1: "22H00-6H00" # Mardi offpeak_hours_2: "0H00-23H59" # Mercredi (tout en HC) offpeak_hours_3: "3H40-8H10;12H40-16H10" # Jeudi (deux plages) offpeak_hours_4: "22H00-6H00" # Vendredi offpeak_hours_5: "22H00-6H00;12H00-14H00" # Samedi offpeak_hours_6: "22H00-6H00;12H00-14H00" # Dimanche ``` -------------------------------- ### InfluxDB v1.8 Configuration Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Configure InfluxDB v1.8 connection details including hostname, port, username, password, and bucket. ```yaml influxdb: enable: true hostname: influxdb port: 8086 token: "USERNAME:PASSWORD" org: "-" bucket: "myelectricaldata/autogen" method: asynchronous ``` -------------------------------- ### Import Status Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves the current status of data importation. ```APIDOC ## GET /import_status — Import Status Returns the current status of data importation. ### Method GET ### Endpoint /import_status ### Response #### Success Response (200) - **status** (boolean) - true if importation is in progress, false if idle. ### Request Example ```bash curl -s http://localhost:5000/import_status ``` ### Response Example ```json true ``` ``` -------------------------------- ### Gateway Status Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves the status information from the gateway. ```APIDOC ## GET /gateway_status — Gateway Status Retrieves status information from the gateway. ### Method GET ### Endpoint /gateway_status ### Response #### Success Response (200) - **status** (boolean) - Indicates the gateway status. - **information** (string | null) - Additional information, can be null. - **nb_client** (integer) - Number of connected clients. - **waiting_estimation** (string) - Estimated waiting time. - **version** (string) - The version of the gateway software. ### Request Example ```bash curl -s http://localhost:5000/gateway_status | python3 -m json.tool ``` ### Response Example ```json { "status": true, "information": null, "nb_client": 142, "waiting_estimation": "2min", "version": "1.2.3" } ``` ``` -------------------------------- ### Reset Local Cache for a Usage Point Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Deletes all local cache data for a usage point. Data will be re-downloaded on the next cycle. Also provides options to delete the usage point entirely or reset the gateway cache. ```APIDOC ## GET /reset/{usage_point_id} — Reset Local Cache for a Usage Point Deletes all local cache data for a usage point. Data will be re-downloaded on the next cycle. Also provides options to delete the usage point entirely or reset the gateway cache. ### Method GET ### Endpoint /reset/{usage_point_id} ### Parameters #### Path Parameters - **usage_point_id** (string) - Required - The unique identifier for the usage point. ### Description This endpoint resets the local cache for a specified usage point. Additional related operations are available: - `/delete/{usage_point_id}`: Completely removes the usage point from the database. - `/reset_gateway/{usage_point_id}`: Clears the remote cache on the myelectricaldata.fr gateway. ### Request Example ```bash # Clear all local cache for the usage point curl -s "http://localhost:5000/reset/12345678901234" # Completely delete the usage point from the database curl -s "http://localhost:5000/delete/12345678901234" # Clear the remote cache on the gateway curl -s "http://localhost:5000/reset_gateway/12345678901234" ``` ``` -------------------------------- ### Service Status Check Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Checks the operational status of the service. Useful for Docker/Kubernetes health checks. ```APIDOC ## GET /ping — Service Status Check Returns "ok" if the service is operational. Useful for Docker/Kubernetes healthchecks. ### Method GET ### Endpoint /ping ### Response #### Success Response (200) - **status** (string) - Indicates the service is operational ('ok'). ### Request Example ```bash curl -s http://localhost:5000/ping ``` ### Response Example ``` "ok" ``` ``` -------------------------------- ### EDF Tempo Data Source: https://context7.com/myelectricaldata/myelectricaldata_import/llms.txt Retrieves EDF Tempo data (Blue/White/Red days) from the local cache. Can also be used to force a cache refresh. ```APIDOC ## GET /tempo — EDF Tempo Data Retrieves EDF Tempo data (Blue/White/Red days) from the local cache. ### Method GET, PUT ### Endpoint /tempo ### Description - **GET**: Reads Tempo data from the local cache. - **PUT**: Forces a cache refresh of Tempo data from the gateway. ### Request Example ```bash # Read Tempo data curl -s http://localhost:5000/tempo | python3 -m json.tool # Force cache refresh curl -s -X PUT http://localhost:5000/tempo ``` ``` -------------------------------- ### Datatable Language Configuration (French) Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/src/templates/index.html Defines language settings for DataTables in French, including text for processing, search, pagination, and sorting information. ```javascript let french = { processing: "Traitement en cours...", search: "Rechercher :", lengthMenu: "Afficher _MENU_ éléments", info: "Affichage de l 'élement _START_ à _END_ sur _TOTAL_ éléments", infoEmpty: "Affichage de l 'élement 0 à 0 sur 0 éléments", infoFiltered: "(filtré de _MAX_ éléments au total)", infoPostFix: "", loadingRecords: "Chargement en cours...", zeroRecords: "Aucun élément à afficher", emptyTable: "Aucune donnée disponible dans le tableau", paginate: { first: "Premier", previous: "Précédent", next: "Suivant", last: "Dernier" }, aria: { sortAscending: ": activer pour trier la colonne par ordre croissant", sortDescending: ": activer pour trier la colonne par ordre décroissant" } } ``` -------------------------------- ### Uninstall enedisgateway2mqtt Helm Chart Source: https://github.com/myelectricaldata/myelectricaldata_import/blob/main/chart/README.md This command removes the enedisgateway2mqtt deployment, including all associated Kubernetes components and persistent volumes. ```console helm uninstall enedisgateway2mqtt ```