nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
211 stars 34 forks source link

binary_sensor.basic_schedule - TypeError: list indices must be integers or slices, not str #96

Closed tmjo closed 3 years ago

tmjo commented 3 years ago

I've been getting this every now and then, believe it is only on restart of HA. I can take a look at it later, just pasting the error message while I remember it :) After some time, the sensor is updated correctly, so it is not a major problem.

Logger: homeassistant.helpers.entity
Source: custom_components/easee/entity.py:232
First occurred: 8:51:22 (1 occurrences)
Last logged: 8:51:22

Update for binary_sensor.easee_1_basic_schedule fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/easee/entity.py", line 249, in async_update
    self._state = self.get_value_from_key(self._state_key)
  File "/config/custom_components/easee/entity.py", line 232, in get_value_from_key
    value = self.charger_data.schedule[second]
TypeError: list indices must be integers or slices, not str
olalid commented 3 years ago

It is a race condition. If the schedules are not polled once before the signalr data starts coming in, there is no basedict created and python assumes array instead which can not be indexed with anything else than integer numbers. What version are you using, I thought I fixed this...?

tmjo commented 3 years ago

I forgot to do any further investigation on this. Right now I'm on latest 0.9.26 but can't remember if I updated during the last week. Perhaps it will be fixed in your PR #99 then, or do you believe it was fixed on the official release already?

olalid commented 3 years ago

I think this should be fixed in the current latest release actually... But if you see it still, then it is not fixed... :)

tmjo commented 3 years ago

Let's hope it's done, didn't see it for a week or so and also did a restart now without error coming. Closing issue.