aijayadams / hass-blueair

BlueAir sensor integration for HomeAssistant
34 stars 15 forks source link

Adding support for "Classic" Models #11

Closed rgeorgi closed 2 years ago

rgeorgi commented 2 years ago

Just adding this PR after I got my BlueAir Classic 605 working (fan control only).

1) Adding initial poll so attributes aren't empty 2) Disable sensors for classic models that don't contain them 3) Spelling fix in "authorization" failure

(This addresses issue #8 )

MaxDucy commented 2 years ago

I have tested your PR and only the fan speed control showed up, but entities still show as unavailable.

Here's the log

2022-02-04 21:35:33 ERROR (MainThread) [custom_components.blueair] Error fetching blueair-Living Room data: list index out of range

2022-02-04 21:35:33 ERROR (MainThread) [custom_components.blueair] Error fetching blueair-Master Bedroom data: list index out of range

2022-02-04 21:35:34 ERROR (MainThread) [homeassistant.components.fan] Error adding entities for domain fan with platform blueair Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 773, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in state if (is_on := self.is_on) is None: File "/config/custom_components/blueair/fan.py", line 53, in is_on return self._device.is_on File "/config/custom_components/blueair/device.py", line 120, in is_on if self._attribute["fan_speed"] == "0": KeyError: 'fan_speed'

2022-02-04 21:35:34 ERROR (MainThread) [homeassistant.components.fan] Error while setting up blueair platform for fan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform await asyncio.gather(*pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 773, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in state if (is_on := self.is_on) is None: File "/config/custom_components/blueair/fan.py", line 53, in is_on return self._device.is_on File "/config/custom_components/blueair/device.py", line 120, in is_on if self._attribute["fan_speed"] == "0": KeyError: 'fan_speed'

2022-02-04 21:36:36 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in state if (is_on := self.is_on) is None: File "/config/custom_components/blueair/fan.py", line 53, in is_on return self._device.is_on File "/config/custom_components/blueair/device.py", line 120, in is_on if self._attribute["fan_speed"] == "0": KeyError: 'fan_speed'

2022-02-04 21:36:36 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in state if (is_on := self.is_on) is None: File "/config/custom_components/blueair/fan.py", line 53, in is_on return self._device.is_on File "/config/custom_components/blueair/device.py", line 120, in is_on if self._attribute["fan_speed"] == "0": KeyError: 'fan_speed'

GoranGozo commented 2 years ago

@rgeorgi Thank you for taking time to find a solution for the Classic models! Works like a charm on my Classic 405.

On my 405 if I set the fan speed to medium (67%) and then view the entity attributes under "Developer Tools" it shows "speed: high percentage: 67". Minor bug. The expected behaviour is for the speed to be "medium".

This is just a note/info for future work. I don't know the source of this discrepancy. If it's this pull request or something else.