PiotrMachowski / Home-Assistant-custom-components-Tauron-AMIplus

This sensor uses unofficial API to get energy usage and generation data from https://elicznik.tauron-dystrybucja.pl.
MIT License
138 stars 34 forks source link

Error loading integration #17

Closed darth-aragoth closed 3 years ago

darth-aragoth commented 3 years ago

After updating HA to latest version, integration doea not work. Error log:

Logger: homeassistant.components.sensor
Source: custom_components/tauron_amiplus/sensor.py:86
Integration: Sensor (documentation, issues)
First occurred: 17:32:27 (1 occurrences)
Last logged: 17:32:27

Error while setting up tauron_amiplus platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/tauron_amiplus/sensor.py", line 61, in setup_platform
    dev.append(TauronAmiplusSensor(name, username, password, meter_id, generation, variable))
  File "/config/custom_components/tauron_amiplus/sensor.py", line 131, in __init__
    configuration = calculate_configuration(username, password, meter_id)
  File "/config/custom_components/tauron_amiplus/sensor.py", line 86, in calculate_configuration
    json_data = response.json()
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
PiotrMachowski commented 3 years ago

Have you tried if you can log in to eLicznik website?

darth-aragoth commented 3 years ago

Hmm that's interesting...

Przekroczono maksymalną ilość logowań na dobę.

I can log in after entering captcha code. It seems that they implemented some login-count limit... Sounds bad, is it possible to log in and refresh data in the same session? Or increase data refresh interval?

PiotrMachowski commented 3 years ago

My guess is that during HA update you have restarted your HA several times, which have caused exceeding a max number of logins. Everything should start to work after you have provider captcha.

Currently data is refreshed each hour. If you have this integration set up in yaml you can use following config to change said interval to 4 hours (documentation):

sensor:
  - platform: tauron_amiplus
    name: Tauron AMIPlus
    username: !secret tauron_amiplus.username
    password: !secret tauron_amiplus.password
    energy_meter_id: !secret tauron_amiplus.energy_meter_id
    check_generation: true
    monitored_variables:
      - zone
      - consumption_daily
      - consumption_monthly
      - consumption_yearly
      - generation_daily
      - generation_monthly
      - generation_yearly
    scan_interval: 14400

If you have this integration using GUI then you have to disable polling and create an automation that will call homeassistant.update_entity service on all entities of this integration (documentation)