Add a module to retrieve electricity use from Linky

with the upgrade 0.90 it works again.

The module only shows the total consumption of yesterday. Any way to add more infos ??

EDIT : There is still some errors :

Impossible to decode response: Expecting value: line 1 column 1 (char 0) Response was: <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href=“https://espace-client-connexion.enedis.fr/auth/UI/Login?realm=particuliers&amp;goto=http%3A%2F%2Fespace-client-particuliers.enedis.fr%3A80%2Fgroup%2Fespace-particuliers%2Fsuivi-de-consommation%3Fp_p_cacheability%3DcacheLevelPage%26p_p_col_count%3D3%26p_p_col_id%3Dcolumn-1%26p_p_col_pos%3D1%26p_p_id%3Dlincspartdisplaycdc_WAR_lincspartcdcportlet%26p_p_lifecycle%3D2%26p_p_mode%3Dview%26p_p_resource_id%3DurlCdcHeure%26p_p_state%3Dnormal”>here</a>.</p> </body></html>

Update for sensor.linky fails
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 220, in async_update_ha_state
await self.async_device_update()
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 379, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/sensor/linky.py”, line 82, in update
self._client.fetch_data()
File “/usr/local/lib/python3.7/site-packages/pylinky/client.py”, line 193, in fetch_data
self._data[t] = self.get_data_per_period(t)
File “/usr/local/lib/python3.7/site-packages/pylinky/client.py”, line 184, in get_data_per_period
data = self._get_data(_MAP[_RESSOURCE][period_type], start, end)
File “/usr/local/lib/python3.7/site-packages/pylinky/client.py”, line 98, in _get_data
raw_res = self._session.post(DATA_URL,
AttributeError: ‘NoneType’ object has no attribute ‘post’

The one above with issues. Is it with the official components or the custom component in development by Grea09?
With the custom component it works on my hass.io

official component

but if you say all the custom component is working great, why don’t you make a pull request ?

There is one PR. It just took time to have it merged. But you can copy/paste the code in a custom component to be able to used it and check if your issues are solved.

1 Like

Hey @grea09. Any news about the PR? Are you still searching to improve it?

Not me personally but a group of students will try to improve it and hopefully finish it next month and until june.

OK nice to know.
In the mean time I’ve updated the custom component to the new custom component architecture, made some update to be consistent with pyLinky v0.3.3 and correct the computation of the differences with same month last year.

If you want to use it go to my repo

Example of configuration:

sensor:
  - platform: linky_custom
    username: !secret linky_username
    password: !secret linky_password
    # No HP/HC
    peak_hours:
      - ["00:00","24:00"]
    peak_hours_cost: 0.09864
    offpeak_hours_cost: 0.09864
1 Like

I try it , but i got an error
2019-05-06 10:34:33 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform linky_custom
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/linky_custom/sensor.py”, line 70, in setup_platform
[LinkySensor(name, linky_data, peak_hours, peak_hours_cost, offpeak_hours_cost)]
File “/config/custom_components/linky_custom/sensor.py”, line 91, in init
self.update()
File “/usr/local/lib/python3.7/site-packages/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/linky_custom/sensor.py”, line 157, in update
) / (self._attributes[“peak_hours”] + self._attributes[“offpeak_hours”])
ZeroDivisionError: float division by zero

Exact same error for me.
I did use the same configuration as @oncleben31 suggested.

Strange your errors.
Except any undetected bug, zero should happen only if your total consumption from yesterday is 0.
@Fabrice_Barthelemy and @sylvaindd can you share the consumption data of the 5/05 visible in your linky web interface ?
@grea09 any idea of the root cause?

The official component give 43kw for yesterday

Here is the JSON I get from enedis suivi-de-consommation endpoint : https://pastebin.com/n1eYsy52 (01/05 - 05/05).
I don’t know if this the same endpoint used by the component though.

Back to normal for me :+1:

OK Thanks. Perhaps we should add some protection in this computation.

Same error still happening for me, I will try to debug it somehow later this week.

Yes error is back certainly due to enedis …

Hi,

I used your last version of linky custom conpounds. I can see al new data in HA service. I would like to grab the associated cards. Where I can download it ? and how to install it correctly ?
Thanks

I don’t find the inputs I used in this thread.

So the idea is to put the file linky-card.js in your www folder.

Add this code at the beginning of your lovelace configuration:

resources:
  - type: js
    url: /community_plugin/lovelace-fold-entity-row/fold-entity-row.js
  - type: js
    url: /local/linky-card.js?v=4
  - type: js

Add this code in your love-lace configuration to activate the card:

entity: sensor.linky
type: 'custom:linky-card'

Thanks works great:)