Best french discord community about "Domotique & Diy" :
The tool is still under development. It is possible that various functions disappear or be modified
- Github Repository : https://github.com/m4dm4rtig4n/enedisgateway2mqtt
- Docker Hub Images : https://hub.docker.com/r/m4dm4rtig4n/enedisgateway2mqtt
- Hassio Addons : https://github.com/alexbelgium/hassio-addons/tree/master/enedisgateway2mqtt
- Saniho Card for Home Assistant : https://github.com/saniho/content-card-linky
EnedisGateway2MQTT use Enedis Gateway API to send data in your MQTT Broker.
- Go to Enedis Website
- Log or create account
- Link your Linky
- Go in page "Gérer l’accès à mes données" and enable all collect. (The boxes at the bottom right of the page.)
Sometimes it takes several days for Enedis to activate the collection.
Activation is only valid for 1 year.
- Go to Enedis Gateway and clic on "Faire la demande de consentement"
- Approuve your concentment
- At the end, your are redirect to Enedis Gateway and you can found your access_token and curl test command.
WARNING, The enedis website has some issues with chrome / chromium based browsers. The easiest way is to use Firefox in the consent process
In order to avoid saturation of Enedis Gateway services, the number of API calls is limited to 15 per day. Most of the information will be collected during the first launch. You will just need a few days to report all "detailed" consumption over 2 years (about 1 week)
Enedis Gateway limit to 50 call per day / per pdl.
If you reach this limit, you will be banned for 24 hours!
API call number by parameters :
Parameters | Call number |
---|---|
GET_CONSUMPTION | 3 |
GET_CONSUMPTION_DETAIL | 105 |
GET_PRODUCTION | 3 |
GET_PRODUCTION_DETAIL | 105 |
ADDRESSES | 1 |
CONTRACT | 1 |
See chapter persistance, to reduce API call number.
Filename : config.yaml
Container path : /data/config.yaml
The easiest is to map the "/data" in local because it is also this folder that contains the cache.
3 parameters is mandatory :
- MQTT Hostname
- At least one PDL
- PDL token
All other variables have default values
Exemple :
##########
# GLOBAL #
##########
debug: false
####################
## MQTT ##
####################
mqtt:
host: MOSQUITO_SERVER # MANDATORY
port: 1883
username: ""
password: ""
prefix: enedis_gateway
client_id: enedis_gateway
retain: true
qos: 0
####################
## Home assistant ##
####################
home_assistant:
discovery: false
discovery_prefix: homeassistant
card_myenedis: false
###############
## Influx DB ##
###############
#influxdb:
# host: MY_INFLUXDB_SERVER
# port: 8086
# token: MY_TOKEN
# org: MY_ORG
# bucket: MY_BUCKET
####################
## ENEDIS GATEWAY ##
####################
enedis_gateway:
"XXXXXXXXXXXXXX": # Replace XXXXXXXXXXXXXX by your PDL Number. MANDATORY
token: "YOUR_TOKEN" # MANDATORY
plan: BASE # BASE or HP/HC
consumption: true
consumption_detail: true
consumption_price_hc: 0
consumption_price_hp: 0
consumption_price_base: 0
production: false
production_detail: false
offpeak_hours: "" # USE ONLY IF YOU WANT OVERLOAD DEFAULT VALUE, Format : 22h36-06h00;11h30-14h30
addresses: true
# YYYYYYYYYYYYYY: # Replace YYYYYYYYYYYYYY by your other PDL Number
# token: YOUR_TOKEN
# plan: HP/HC
# consumption: true
# consumption_detail: true
# consumption_price_hc: 0.1781
# consumption_price_hp: 0.1337
# consumption_price_base: 0.1781
# production: false
# production_detail: false
# addresses: true
offpeak_hours : I automatically retrieve the information via the Enedis APIs, but it happens that some account does not upload it. This parameter will allow you to fill in your HP / HC ranges yourself in order to be able to compare your consumption according to the 2 subscriptions.
Since v0.3, Enedis Gateway use SQLite database to store all data and reduce API call number.
Don't forget to mount /data to keep database persistance !!
If you wan wipe cache, just delete enedisgateway.db and restat container.
WARNING, if you wipe all data you generate lot of API Call (don't forget [Enedis Gateway limit](#Enedis Gateway limit))
It doesn't forget that it takes several days to recover consumption/production in detail mode.
Even if you are on a basic plan (and not HP / HC), it is interesting to enter the prices of each plan. The tool will do calculation for you and tell you which plan is the most advantageous for you based on your consumption.
Sometimes there are holes in the Enedis consumption records. So I set up a blacklist system for certain dates.
If date does not return information after 7 try (7 x CYCLE), I blacklist this date and will no longer generate an API call
Gateway is work with influxDB version 1.X & 2.X
influxdb:
host: influxdb
port: 8086
token: USERNAME:PASSWORD
org: "-"
bucket: "DATABASE/RETENTION"
influxdb:
host: influxdb
port: 8086
token: MY_TOKEN
org: MY_ORG
bucket: MY_BUCKET
When you are exported all data in your influxDB, you can use this grafana dashboard.
Actually it's work only in InfluxQL (v1 language), Flux mode (v2 language) it's in progress... But you can use InfluxQL in V2.
These are EXAMPLES, and do not necessarily represent your settings!
Please read parameter table and adapt to your configuration.
docker run -it --restart=unless-stopped -v $(pwd):/data m4dm4rtig4n/enedisgateway2mqtt:latest
docker-compose.yml
version: "3.9"
services:
enedisgateway2mqtt:
image: m4dm4rtig4n/enedisgateway2mqtt:latest
restart: unless-stopped
volumes:
-./:/data
Requirement:
- docker
- docker-compose
- make
Display help information:
make
Start containers:
make up
Stop containers:
make down
Start application:
make start
Connect to container:
make start
- Add DJU18
- Add Postgres/MariaDB Connector
- Add max power
UPGRADE Procedure :
- 0.7.6 -> 0.7.7 : Wipe cache (rm enedisgateway.db)
Change Log :
- Fix Null values don’t mean no values
- Fix Timezone bug
- Fix HP/HC no cost
- Fix HP/HC wrong price
- Switch Enedis API Call in UTC Datetime (reduce error)
- Fix offpeak hours in HA Sensor
- Fix SQLite closed connection
- Fix debug
- Fix OFFPEAK_HOUR bug
BREAKING CHANGE - All configuration is now in config.yml
Not update to 0.7.0 if you don't have adapt your configuration
- Skip version
- Add timeout to API Call
- Fix bug
- HassOS Addons available : https://github.com/alexbelgium/hassio-addons/tree/master/enedisGateway2MQTT (special thx to alexbelgium)
- Reduce API Call
- Add more log
- Fix bug
- Fix log on MQTT connection failed :
NameError: name 'client' is not defined
- HA Sensor (kW => Wh)
- HA Sensor add uniq_id
- HA Sensor add device (thx to Smeagolworms4)
- Fix offpeak bug
- Add dev environment (thx to Smeagolworms4)
- Fix bug
- Add influxdb connecter & exporter
- Grafana dashboard exemple
- Create HA sensor for Linky Card with auto-discovery
- Add param to choose current plan
- Add HC/HP
- Rework database structure (all cached data are reset)
- Add new params to reset all cache.
- Cache addresses & contracts data.
- Switch locale to fr_FR.UTF8 (french date format)
- Switch ha_discovery state in kW by default (W before)
- Add Database structure check + reset if broken
- Optimise caching
- Change MQTT structure per days
- I remove the "years" parameter and automatically set the max value (36 month)
- Switch image docker to python-slim to reduce image size (900mo => 150mo)
- Fixes various bugs
- Fix HA Discovery error.
- Fix error when API call limit is reached.
- Rework ha discovery to reduce items
- Fix ha_autodiscovery always enable
- Get Production
- Add SQLite database to store data and reduce number of API Call.
- Helm chart
- Home Assistant auto-discovery
- Add Retain & QoS (MQTT)
- Add Timestamp in log
- First Release