Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fulfill IQS rule entity-unavailable in ViCare integration #133535

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions homeassistant/components/vicare/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,22 @@
)
self.entity_description = description

@property
def available(self) -> bool:
"""Return True if entity is available."""
return self._attr_is_on is not None

def update(self) -> None:
"""Update state of sensor."""
try:
with suppress(PyViCareNotSupportedFeatureError):
self._attr_is_on = self.entity_description.value_getter(self._api)
except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 195 in homeassistant/components/vicare/binary_sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/binary_sensor.py#L195

Added line #L195 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 198 in homeassistant/components/vicare/binary_sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/binary_sensor.py#L198

Added line #L198 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 201 in homeassistant/components/vicare/binary_sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/binary_sensor.py#L201

Added line #L201 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 204 in homeassistant/components/vicare/binary_sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/binary_sensor.py#L204

Added line #L204 was not covered by tests
else:
self._attr_available = True

Check warning on line 206 in homeassistant/components/vicare/binary_sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/binary_sensor.py#L206

Added line #L206 was not covered by tests
6 changes: 6 additions & 0 deletions homeassistant/components/vicare/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,18 @@

except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 224 in homeassistant/components/vicare/climate.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/climate.py#L224

Added line #L224 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 227 in homeassistant/components/vicare/climate.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/climate.py#L227

Added line #L227 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 230 in homeassistant/components/vicare/climate.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/climate.py#L230

Added line #L230 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 233 in homeassistant/components/vicare/climate.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/climate.py#L233

Added line #L233 was not covered by tests
else:
self._attr_available = True

Check warning on line 235 in homeassistant/components/vicare/climate.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/climate.py#L235

Added line #L235 was not covered by tests

@property
def hvac_mode(self) -> HVACMode | None:
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/vicare/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,18 @@
)
except RequestConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 162 in homeassistant/components/vicare/fan.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/fan.py#L162

Added line #L162 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 165 in homeassistant/components/vicare/fan.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/fan.py#L165

Added line #L165 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 168 in homeassistant/components/vicare/fan.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/fan.py#L168

Added line #L168 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 171 in homeassistant/components/vicare/fan.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/fan.py#L171

Added line #L171 was not covered by tests
else:
self._attr_available = True

Check warning on line 173 in homeassistant/components/vicare/fan.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/fan.py#L173

Added line #L173 was not covered by tests

@property
def is_on(self) -> bool | None:
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/vicare/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,6 @@
)
self.entity_description = description

@property
def available(self) -> bool:
"""Return True if entity is available."""
return self._attr_native_value is not None

def set_native_value(self, value: float) -> None:
"""Set new value."""
if self.entity_description.value_setter:
Expand Down Expand Up @@ -438,12 +433,18 @@
self._attr_native_step = stepping_value
except RequestConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 436 in homeassistant/components/vicare/number.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/number.py#L436

Added line #L436 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 439 in homeassistant/components/vicare/number.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/number.py#L439

Added line #L439 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 442 in homeassistant/components/vicare/number.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/number.py#L442

Added line #L442 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 445 in homeassistant/components/vicare/number.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/number.py#L445

Added line #L445 was not covered by tests
else:
self._attr_available = True

Check warning on line 447 in homeassistant/components/vicare/number.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/number.py#L447

Added line #L447 was not covered by tests


def _get_value(
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/vicare/quality_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ rules:
docs-actions: done
brands: done
# Silver
integration-owner: done
reauthentication-flow: done
config-entry-unloading: done
entity-unavailable: done
reauthentication-flow: done
integration-owner: done
# Gold
devices: done
diagnostics: done
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/vicare/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,11 +1003,6 @@
)
self.entity_description = description

@property
def available(self) -> bool:
"""Return True if entity is available."""
return self._attr_native_value is not None

def update(self) -> None:
"""Update state of sensor."""
vicare_unit = None
Expand All @@ -1021,12 +1016,18 @@
vicare_unit = self.entity_description.unit_getter(self._api)
except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 1019 in homeassistant/components/vicare/sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/sensor.py#L1019

Added line #L1019 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 1022 in homeassistant/components/vicare/sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/sensor.py#L1022

Added line #L1022 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 1025 in homeassistant/components/vicare/sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/sensor.py#L1025

Added line #L1025 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 1028 in homeassistant/components/vicare/sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/sensor.py#L1028

Added line #L1028 was not covered by tests
else:
self._attr_available = True

if vicare_unit is not None:
if (
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/vicare/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@

except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
self._attr_available = False

Check warning on line 140 in homeassistant/components/vicare/water_heater.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/water_heater.py#L140

Added line #L140 was not covered by tests
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
self._attr_available = False

Check warning on line 143 in homeassistant/components/vicare/water_heater.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/water_heater.py#L143

Added line #L143 was not covered by tests
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
self._attr_available = False

Check warning on line 146 in homeassistant/components/vicare/water_heater.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/water_heater.py#L146

Added line #L146 was not covered by tests
except PyViCareInvalidDataError as invalid_data_exception:
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
self._attr_available = False

Check warning on line 149 in homeassistant/components/vicare/water_heater.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/water_heater.py#L149

Added line #L149 was not covered by tests
else:
self._attr_available = True

Check warning on line 151 in homeassistant/components/vicare/water_heater.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/vicare/water_heater.py#L151

Added line #L151 was not covered by tests

def set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperatures."""
Expand Down
22 changes: 11 additions & 11 deletions tests/components/vicare/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_circulation_pump-entry]
Expand Down Expand Up @@ -90,7 +90,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_circulation_pump_2-entry]
Expand Down Expand Up @@ -137,7 +137,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_dhw_charging-entry]
Expand Down Expand Up @@ -184,7 +184,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_dhw_circulation_pump-entry]
Expand Down Expand Up @@ -231,7 +231,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_dhw_pump-entry]
Expand Down Expand Up @@ -278,7 +278,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_frost_protection-entry]
Expand Down Expand Up @@ -324,7 +324,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_all_entities[binary_sensor.model0_frost_protection_2-entry]
Expand Down Expand Up @@ -370,7 +370,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_binary_sensors[burner]
Expand All @@ -384,7 +384,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_binary_sensors[circulation_pump]
Expand All @@ -398,7 +398,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
# name: test_binary_sensors[frost_protection]
Expand All @@ -411,6 +411,6 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
'state': 'unknown',
})
# ---
Loading