rainepretorius / olarm-ha-integration

Integration for Olarm devices created by a BSC(Computer Science and Mathematics) student.
https://raine.pretoriusse.net
BSD 2-Clause "Simplified" License
30 stars 13 forks source link

Indexing error in v2.0.4 #38

Closed AlduCor closed 1 year ago

AlduCor commented 1 year ago

Hi!

I'm adding the integration to a new HASSOS server. I'm getting the following errors:

2023-04-11 18:01:56.278 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up olarm_sensors platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/olarm_sensors/binary_sensor.py", line 34, in async_setup_entry
    await coordinator.async_get_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 148, in async_get_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:01:56.287 ERROR (MainThread) [homeassistant.components.button] Error while setting up olarm_sensors platform for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/olarm_sensors/button.py", line 30, in async_setup_entry
    await coordinator.async_get_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 148, in async_get_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:00.930 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:03.187 WARNING (SyncWorker_4) [homeassistant.helpers.service] Unable to parse services.yaml for the olarm_sensors integration
2023-04-11 18:02:06.008 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:11.779 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:17.156 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:22.506 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:27.504 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:32.832 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:37.569 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
2023-04-11 18:02:45.917 ERROR (MainThread) [custom_components.olarm_sensors.coordinator] Unexpected error fetching Olarm Coordinator (c93ca785-14b2-45a4-b3d1-e4ddf3a33702) data: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 250, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 144, in _async_update_data
    return await self.update_data()
  File "/config/custom_components/olarm_sensors/coordinator.py", line 117, in update_data
    int(devices_json["deviceState"]["areasStamp"][i - 1] / 1000)
IndexError: list index out of range
AlduCor commented 1 year ago

I tested it with all versions, same issue. From the JSON, the areasLimit "4" in my case, does not equal the number of areasStamp (1 in my case). I checked on Olarm, it is possible to change the number of areas to 1 (thus changing areasLimit to 1, fixing the problem). But I would suggest adding a check, or not relying on areasLimit, but rather length of areasStamp in the for loop in coordinator.py?

rainepretorius commented 1 year ago

It has been fixed in 2.0.5