Add a module to retrieve electricity use from Linky


Just now this is the case (component and web UI KO) but yesterday I succeed to access the data thru the website and the HA component still fill the logs with the login error.

I will retry with the last modifications you have pushed in the PR.


They seem to have broken their own API for now…

I will try again latter and see if they update their website.


Example now. website is OK but not the component.


PirionFR seems to have found a workaround in the PR linked in my previous post. Using pyLinky 0.2.1 should be the answer.


I tried to change the pylink version in the custom component without any change on the issue.
I’m not sure the HA have taking it into account.


It’s work for me by updating to 0.2.1 :slight_smile:


I have to double check.
Just to be sure, you just changed in the custom component pylink the version in the line

REQUIREMENTS = ['pylinky==0.2.0']


Yes, I have made a custom component with the latest code from the PR of grea09 and changed line 19 with :
REQUIREMENTS = ['pylinky==0.2.1']

Hope it will work for you! :slight_smile:


It seems I have an error with fake-user agent module used by pylinky. I’ve this error:

2019-02-20 23:29:28 WARNING (SyncWorker_10) [fake_useragent] Error occurred during loading data. Trying to use cache server
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/", line 67, in get
  File "/usr/local/lib/python3.6/urllib/", line 223, in urlopen
    return, data, timeout)
  File "/usr/local/lib/python3.6/urllib/", line 526, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.6/urllib/", line 544, in _open
    '_open', req)
  File "/usr/local/lib/python3.6/urllib/", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/local/lib/python3.6/urllib/", line 1321, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.6/http/", line 1331, in getresponse
  File "/usr/local/lib/python3.6/http/", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.6/http/", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.6/", line 586, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/", line 166, in load
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/", line 122, in get_browser_versions
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/", line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

Any one with experience or skills to help find the root cause ?


Sorry can’t help you :frowning:


That error probably means the servers are down again. I can querry them here.

Try with python3 -m pylinky -u [email protected] -p secret_password


I am working on doing a much better version of the component. I want to make it integrate with the new Utility metter. I also got 5 students of mine on the UI to add cards with more graphs option and allowing for use with generic cards.

I however need to modify the history of the sensor. I found how to do it but I want to do it properly and convince the core team to allow for the modification of the recorder component. I did so here. If you want to help try to vote for the request.


thx for the great job!

It would be very nice to integrate into the utility meter. As for the history it would be perfect to insert the data on the right date (so yesterday’s for data received today in Linky).

Keep up the good work :slight_smile:


linky component doesn’t work, is there any update coming soon ?


I tried to bump pylinky to 0.3.1, I add to modify the code to configure the platform. Anyway it did not work. I try to use Pylinky directly and it works so the issue is not in enedis site but on the component. I did not try the built-in Linky component (which was bumped in 0.3.0 in dev).


still not working with the today update 0.89

linky: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/", line 348, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/util/", line 224, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/sensor/", line 87, in update
    _LOGGER.debug(json.dumps(self._client.get_data(), indent=2))
  File "/usr/local/lib/python3.7/site-packages/pylinky/", line 202, in get_data
    formatted_data[t] = self.format_data(self._data[t])
  File "/usr/local/lib/python3.7/site-packages/pylinky/", line 142, in format_data
    start_date = datetime.datetime.strptime(data.get("periode").get("dateDebut"), "%d/%m/%Y").date()
AttributeError: 'NoneType' object has no attribute 'get'



I’ve find a solution in order to not have the errors with component “Linky Sensor” (embedded in Home-Assistant since v0.79): add optionnal (but undocumented) attribute “timeout”.

  - platform: linky
    username: !secret enedis_username
    password: !secret enedis_password
    timeout: 60




It’s working now, although I’v sometimes error like :

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=“;”>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/”, line 220, in async_update_ha_state
await self.async_device_update()
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/”, line 348, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.7/concurrent/futures/”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/util/”, line 224, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/sensor/”, line 81, in update
File “/usr/local/lib/python3.7/site-packages/pylinky/”, line 193, in fetch_data
self._data[t] = self.get_data_per_period(t)
File “/usr/local/lib/python3.7/site-packages/pylinky/”, 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/”, line 98, in _get_data
raw_res =,
AttributeError: ‘NoneType’ object has no attribute ‘post’


Well here is my linky entity, there is nothing in attributes and the doc in components page is very poor…


I’m in the same situation as you, with the same mistakes you’re quoting above :wink:. If there was someone who could give us a little help please