Add a module to retrieve electricity use from Linky


#62

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.


#63

They seem to have broken their own API for now…

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


#64

Example now. website is OK but not the component.


#65

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


#66

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.


#67

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


#68

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']

#69

Yes, I have made a custom component linky2.py 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:


#70

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 https://fake-useragent.herokuapp.com/browsers/0.1.11
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/utils.py", line 67, in get
    context=context,
  File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1321, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/local/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.6/socket.py", 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/utils.py", line 166, in load
    verify_ssl=verify_ssl,
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/utils.py", line 122, in get_browser_versions
    verify_ssl=verify_ssl,
  File "/config/deps/lib/python3.6/site-packages/fake_useragent/utils.py", 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 ?


#71

Sorry can’t help you :frowning:


#72

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


#73

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.


#74

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:


#75

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


#76

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).


#77

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/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 348, 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 87, in update
    _LOGGER.debug(json.dumps(self._client.get_data(), indent=2))
  File "/usr/local/lib/python3.7/site-packages/pylinky/client.py", line 202, in get_data
    formatted_data[t] = self.format_data(self._data[t])
  File "/usr/local/lib/python3.7/site-packages/pylinky/client.py", 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'

#78

Hi,

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

Regards,

Romain.


#79

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=“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 348, 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 81, 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’


#80

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


#81

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