gieljnssns / kostalpiko-sensor-homeassistant

A custom component to get the readings of a Kostal Piko inverter
MIT License
12 stars 18 forks source link

Error while setting up kostal platform for sensor - IndexError: list index out of range #11

Closed Spitfire4466 closed 4 years ago

Spitfire4466 commented 4 years ago

I'm getting the following error in the log after adding kostal platform in my config file Device seems to be a PIKO 10.1

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, 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/kostal/sensor.py", line 65, in setup_platform
    dev.append(PikoInverter(data, sensor, config[CONF_NAME]))
  File "/config/custom_components/kostal/sensor.py", line 82, in __init__
    self.update()
  File "/config/custom_components/kostal/sensor.py", line 106, in update
    self.piko.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/kostal/sensor.py", line 237, in update
    self.data = self.piko._get_raw_content()
  File "/usr/local/lib/python3.7/site-packages/kostalpyko/kostalpyko.py", line 198, in _get_raw_content
    status = response.xpath("/html/body/form/font/table[2]/tr[8]/td[3]")[0].text.strip()
IndexError: list index out of range

Config yaml

 - platform: kostal
    host: !secret kostal_host
    username: !secret kostal_user
    password: !secret kostal_password
    monitored_conditions:
      - current_power
      - total_energy
      - daily_energy
      - string1_voltage
      - string1_current
      - string2_voltage
      - string2_current
      - l1_voltage
      - l1_power
      - l2_voltage
      - l2_power
      - l3_voltage
      - l3_power
      - status

Screenshot of the PIKO webserver

Capture d'écran 2020-05-26 20 21 36
gieljnssns commented 4 years ago

Try this

- platform: kostal
   host: !secret kostal_host
   username: !secret kostal_user
   password: !secret kostal_password
   monitored_conditions:
     - current_power
     - total_energy
     - daily_energy
     - string1_voltage
     - string1_current
     - string2_voltage
     - string2_current
     - l1_voltage
     - l1_power
     - l2_voltage
     - l2_power
     - l3_voltage
     - l3_power

Leave the status out

Spitfire4466 commented 4 years ago

Thanks for your help! Sadly same error

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, 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/kostal/sensor.py", line 65, in setup_platform
    dev.append(PikoInverter(data, sensor, config[CONF_NAME]))
  File "/config/custom_components/kostal/sensor.py", line 82, in __init__
    self.update()
  File "/config/custom_components/kostal/sensor.py", line 106, in update
    self.piko.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/kostal/sensor.py", line 237, in update
    self.data = self.piko._get_raw_content()
  File "/usr/local/lib/python3.7/site-packages/kostalpyko/kostalpyko.py", line 198, in _get_raw_content
    status = response.xpath("/html/body/form/font/table[2]/tr[8]/td[3]")[0].text.strip()
IndexError: list index out of range

I have also tried only one monitored_condition ( current_power ), but got the same error :(

gieljnssns commented 4 years ago

Please try to reinstall trough HACS and choose V2.5

Spitfire4466 commented 4 years ago

Okay it's partially working now, no more errors but... I can see all the sensors but they all have unknown state which is strange. See attached screenshot.

It's a sunny day right now and I'm producing power. The Piko webserver is online and it's showing correct production values I just checked. I have tried host values like http://<ip>/index.fhtml and http://pvserver:<password>@<ip>/index.fhtml but no luck. Also restarted Home assistant several times and waited one hour with no effect. What am I missing?

Thank you for your help :)

Capture d'écran 2020-05-29 09 57 44

gieljnssns commented 4 years ago

And what is your host now? Have you tried this format? "http://192.168.xx.xx"

Spitfire4466 commented 4 years ago

Oh right silly me, I got confused with this host thing... Now it's working, Thank you!

gieljnssns commented 4 years ago

Can you also update to the last version?

Spitfire4466 commented 4 years ago

Yes it works on 2.6 So the problem was me putting the wrong host... Sorry I see that you have updated the Readme.md with more details for the host, nice