Linky is a “smart electricity meter” from the French power grid operator Enedis. One nice thing about this device is that it automatically reports your electricty consumption. By polling the operator’s portal, one can fetch back its own data. And if the data are then stored in InfluxDB, one can keep a pretty look on its power consumption.
Fetching the data
There are quite many tools that allow data fetching from Linky devices. There is a specific one on GitHub that works using Python ; and that is nice enough to run well on OpenBSD.
Start by creating an account on the Enedis portal. This may take some time as a random password is generated by them and send to you via snail-mail. Once done, connect to the portal, change the default password and use the credentials in the linkyndle tool.
Create a database in your preferred InfluxDB instance.
> CREATE DATABASE linky > CREATE USER linker WITH PASSWORD 'secret' > GRANT ALL ON "linky" TO "linker" > ALTER RETENTION POLICY "autogen" ON "linky" DURATION 1827d DEFAULT
Retention duration is 5 years with possible 2 leap years.
My InfluxDB instance requires TLS and authentication. The linkyndle script can handle this. And that’s great.
OpenBSD can run that Python stuff by adding a specific (hear not in port) package.
# pkg_add git # git clone https://github.com/beufanet/linkyndle.git # pkg_add py3-pip py3-influxdb # pip3.7 install fake-useragent # cd linkyndle/ # cp .params.example .params # vi .params
Configure your crontab(1) to regularly run the script ; I do it once a day. Or do it by hand to grab your consumption history.
# python3 linkynflux.py -d 365 # python3 linkynflux.py -l logging in InfluxDB Server Host <server>... logged in InfluxDB Server Host <server> succesfully logging in Enedis URI https://espace-client-particuliers.enedis.fr/group/espace-particuliers... logged in successfully! No data available as startDate (12/02/2020) is not before endDate (12/02/2020) # python3 linkynflux.py -d 1
Browsing the data
The InfluxDB data structure is quite simple.
> SHOW TAG KEYS FROM "conso_elec"; name: conso_elec tagKey ------ fetch_date heures_creuses heures_normales heures_pleines > SHOW FIELD KEYS FROM "conso_elec"; name: conso_elec fieldKey fieldType -------- --------- max integer value float > SELECT * FROM "conso_elec" LIMIT 5 name: conso_elec time fetch_date heures_creuses heures_normales heures_pleines max value ---- ---------- -------------- --------------- -------------- --- ----- 2019-10-07T10:30:00Z 06/02/2020 0 0 1 12000 7 2019-10-07T11:00:00Z 06/02/2020 0 0 1 12000 7 2019-10-07T11:30:00Z 06/02/2020 0 0 1 12000 479 2019-10-07T12:00:00Z 06/02/2020 0 0 1 12000 412 2019-10-07T12:30:00Z 06/02/2020 1 0 1 12000 8
The power consumption dashboard
The linkyndle tool comes with a Grafana dashboard that can be imported in your Grafana instance. It’s a great start at looking to your data. But there are things that didn’t met my needs. So I build my own one.
My interests are to check for the effective consumption value and cost. And to be able to decide on wether to go for the standard plan or the Day/Night plan.
Selecting various time range and interval, I can either check the whole consumption over the year or look at a particular month. More can be done, like a single day but I barely don’t use this. I can see that there is a gain using the Day/Night pricing. Altough the associated annual plan cost may leverage that gain. I’ll see that after a whole monitoring year.
There are hidden variables that need to be modified to match the current cost of electricity.
The JSON code for this dashboard is avalaible on Grafana’s portal. Happy monitoring!