kongo09 / philips-airpurifier-coap

💨 Philips AirPurifier custom component for Home Assistant. Supports local CoAP protocol.
172 stars 27 forks source link

Errors "Error adding entities for domain light with platform philips_airpurifier_coap" in 0.17.2 #103

Closed jaal2001 closed 8 months ago

jaal2001 commented 8 months ago

Hi, with the actual release v0.17.2 I'm receiving these errors:

2024-01-08 13:38:29.907 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2024-01-08 13:39:29.973 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2024-01-08 13:39:48.259 ERROR (MainThread) [homeassistant.components.light] Error adding entities for domain light with platform philips_airpurifier_coap
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1553, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 120, in is_on
    return status > 0
           ^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'
2024-01-08 13:39:48.270 ERROR (MainThread) [homeassistant.components.light] Error while setting up philips_airpurifier_coap platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1553, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 120, in is_on
    return status > 0
           ^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'
2024-01-08 13:39:48.432 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1418, in _async_registry_updated
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1553, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 120, in is_on
    return status > 0
           ^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'
2024-01-08 13:40:10.283 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.schlafzimmer_air_quality_index is changing, got multiple {'AQI', None}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (AQI). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-08 13:40:10.284 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.schlafzimmer_indoor_allergen_index is changing, got multiple {'IAI', None}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (IAI). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-08 13:40:10.284 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_air_quality_index is changing, got multiple {'AQI', None}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (AQI). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-08 13:40:10.284 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_indoor_allergen_index is changing, got multiple {'IAI', None}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (IAI). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-08 13:40:10.284 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_total_volatile_organic_compounds is changing, got multiple {'µg/m³', 'Level'}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (Level). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this

With the 16.somewhat release I didn't had these. Any idea what could cause these?

kongo09 commented 8 months ago

Oh, interesting. I tried to tidy up a bit and maybe I made a mistake somewhere.

What device do you have and what's the output of aioairctrl for you?

jaal2001 commented 8 months ago

I do have an AC2889 and an AC4550.

(name, ProductID and DeviceID are redacted)

{"name": "redacted", "type": "AC2889", "modelid": "AC2889/10", "swversion": "1.0.7", "range": "Comfort", "Runtime": 53893064, "rssi": -51, "otacheck": false, "wifilog": false, "free_memory": 53272, "WifiVersion": "AWS_Philips_AIR@73.1", "ProductId": "redacted", "DeviceId": "redacted", "StatusType": "status", "ConnectType": "Online", "om": "0", "pwr": "0", "cl": false, "aqil": 100, "uil": "1", "dt": 0, "dtrs": 0, "mode": "P", "pm25": 3, "iaql": 1, "aqit": 7, "aqit_ext": 0, "ddp": "0", "err": 0, "fltt1": "A3", "fltt2": "C7", "fltsts0": 120, "fltsts1": 3820, "fltsts2": 1420}

{"name": "redacted", "type": "AC4550", "modelid": "AC4550/10", "swversion": "1.0.3", "range": "O2", "Runtime": 52493884, "rssi": -33, "otacheck": false, "wifilog": false, "free_memory": 46856, "WifiVersion": "AWS_Philips_AIR@73.1", "ProductId": "redacted", "DeviceId": "redacted", "StatusType": "status", "ConnectType": "Online", "om": "a", "pwr": "0", "cl": false, "aqil": "1", "uil": "1", "mode": "AG", "pm25": 1, "iaql": 1, "aqit": 7, "aqit_ext": 0, "tvoc": 1, "ddp": "0", "rddp": "0", "err": 0, "fltt1": "A5", "fltt2": "C7", "fltsts0": 292, "fltsts1": 9048, "fltsts2": 3648}

kongo09 commented 8 months ago

Which one of these is creating the problem?

jaal2001 commented 8 months ago

According to the sensor.recorder messages both of them. Can't find any more hints in the logs which a redirecting to model names or ip adresses. Should I delete one and test again?

kongo09 commented 8 months ago

You can simply unplug one device and see what happens when you start HA

jaal2001 commented 8 months ago

The 4550 is the source of the error.

kongo09 commented 8 months ago

Ok, I'll take a look later. It feels like I made a parameter mistake as it is using a different approach to the AC2889

kongo09 commented 8 months ago

I've fixed this in the latest release. Please let me know if it works.

jaal2001 commented 8 months ago

The current release produces less errors, but still the same:

2024-01-09 07:31:55.646 ERROR (MainThread) [homeassistant.components.light] Error adding entities for domain light with platform philips_airpurifier_coap
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1001, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1082, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
                            ^^^^^^^^^^^^^^^
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 129, in brightness
    return round(255 * brightness / 100)
                 ~~~~~~~~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for /: 'str' and 'int'

2024-01-09 07:31:55.656 ERROR (MainThread) [homeassistant.components.light] Error while setting up philips_airpurifier_coap platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1001, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1082, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
                            ^^^^^^^^^^^^^^^
  File "/config/custom_components/philips_airpurifier_coap/light.py", line 129, in brightness
    return round(255 * brightness / 100)
                 ~~~~~~~~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for /: 'str' and 'int'
2024-01-09 07:32:30.773 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2024-01-09 07:33:30.833 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: philips_airpurifier_coap
2024-01-09 07:35:10.665 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_air_quality_index (None) cannot be converted to the unit of previously compiled statistics (AQI). Generation of long term statistics will be suppressed unless the unit changes back to AQI or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-09 07:35:10.666 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_indoor_allergen_index (None) cannot be converted to the unit of previously compiled statistics (IAI). Generation of long term statistics will be suppressed unless the unit changes back to IAI or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-09 07:35:10.666 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.buro_total_volatile_organic_compounds (µg/m³) cannot be converted to the unit of previously compiled statistics (Level). Generation of long term statistics will be suppressed unless the unit changes back to Level or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-09 07:35:10.666 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.schlafzimmer_air_quality_index (None) cannot be converted to the unit of previously compiled statistics (AQI). Generation of long term statistics will be suppressed unless the unit changes back to AQI or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2024-01-09 07:35:10.666 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.schlafzimmer_indoor_allergen_index (None) cannot be converted to the unit of previously compiled statistics (IAI). Generation of long term statistics will be suppressed unless the unit changes back to IAI or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
kongo09 commented 8 months ago

Ah, that looks similar to the other error. I'll take a look.

kongo09 commented 8 months ago

please try v0.17.4

jaal2001 commented 8 months ago

Errors are gone, interestingly this is coming up:

2024-01-09 11:07:39.159 WARNING (MainThread) [custom_components.philips_airpurifier_coap.config_flow] Timeout, host 192.168.XXX.YYY looks like a Philips AirPurifier but doesn't answer, aborting

Nevertheless manual triggering (on/off) of the device does work. I will give it a look over the next few hours.