core/homeassistant/components/anova/entity.py

33 lines
1.1 KiB
Python
Raw Normal View History

Add Anova integration (#86254) * init setup of Anova Sous Vide * bump anova-wifi to 0.2.4 * Removed yaml support * Bump to anova-wifi 0.2.5 * Added support for adding sous vide while offline * Added basic test for sensor * added better tests for sensors and init * expanded code coverage * Decreased timedelta to lowest functioning value. * Updating my username * migrate to async_forward_entry_setups * applying pr recommended changes * bump anova-wifi to 0.2.7 * Improvements to hopefully get this review ready * formatting changes * clean ups for pr review * remove unneeded unique id check. * bump ao anova_wifi 0.3.0 * rename device_id to device_unique_id * renamed to 'anova' * added unique_id to MockConfigEntry * removed leftover anova sous vides * added device id to strings * added error for incorrect device id * add has_entity_name * added attr name for tests * added authentication functionality * bump to 0.4.3 * split entity into its own class/object * pulling firmware version out of async_setup Co-authored-by: J. Nick Koston <nick@koston.org> * addressed pr changes * fixed pytest * added anova data model * removed unneeded time change * add logging in package * rework step_user * Update homeassistant/components/anova/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Removed lower from attr unique id Co-authored-by: J. Nick Koston <nick@koston.org> * Removed unneeded member variables in sensor Co-authored-by: J. Nick Koston <nick@koston.org> * removed repeated subclass attr Co-authored-by: J. Nick Koston <nick@koston.org> * simplify update_failed test * created descriptionentity * bump to 0.6.1 limit ws connect * add translation for sensor entities * version bump - support pro model * add anova to strict typing * fixed sensor not getting datas type * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Check for new devices in init * style changes * return false instead of config entry not ready * move serialize_device_list to utils * move repeating device check into api * moved unneeded code out of try except * fixed tests to get 100% cov * Update homeassistant/components/anova/strings.json Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-22 23:05:14 +00:00
"""Base entity for the Anova integration."""
Add Anova integration (#86254) * init setup of Anova Sous Vide * bump anova-wifi to 0.2.4 * Removed yaml support * Bump to anova-wifi 0.2.5 * Added support for adding sous vide while offline * Added basic test for sensor * added better tests for sensors and init * expanded code coverage * Decreased timedelta to lowest functioning value. * Updating my username * migrate to async_forward_entry_setups * applying pr recommended changes * bump anova-wifi to 0.2.7 * Improvements to hopefully get this review ready * formatting changes * clean ups for pr review * remove unneeded unique id check. * bump ao anova_wifi 0.3.0 * rename device_id to device_unique_id * renamed to 'anova' * added unique_id to MockConfigEntry * removed leftover anova sous vides * added device id to strings * added error for incorrect device id * add has_entity_name * added attr name for tests * added authentication functionality * bump to 0.4.3 * split entity into its own class/object * pulling firmware version out of async_setup Co-authored-by: J. Nick Koston <nick@koston.org> * addressed pr changes * fixed pytest * added anova data model * removed unneeded time change * add logging in package * rework step_user * Update homeassistant/components/anova/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Removed lower from attr unique id Co-authored-by: J. Nick Koston <nick@koston.org> * Removed unneeded member variables in sensor Co-authored-by: J. Nick Koston <nick@koston.org> * removed repeated subclass attr Co-authored-by: J. Nick Koston <nick@koston.org> * simplify update_failed test * created descriptionentity * bump to 0.6.1 limit ws connect * add translation for sensor entities * version bump - support pro model * add anova to strict typing * fixed sensor not getting datas type * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Check for new devices in init * style changes * return false instead of config entry not ready * move serialize_device_list to utils * move repeating device check into api * moved unneeded code out of try except * fixed tests to get 100% cov * Update homeassistant/components/anova/strings.json Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-22 23:05:14 +00:00
from __future__ import annotations
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .coordinator import AnovaCoordinator
class AnovaEntity(CoordinatorEntity[AnovaCoordinator], Entity):
2023-08-27 18:06:19 +00:00
"""Defines an Anova entity."""
_attr_has_entity_name = True
Add Anova integration (#86254) * init setup of Anova Sous Vide * bump anova-wifi to 0.2.4 * Removed yaml support * Bump to anova-wifi 0.2.5 * Added support for adding sous vide while offline * Added basic test for sensor * added better tests for sensors and init * expanded code coverage * Decreased timedelta to lowest functioning value. * Updating my username * migrate to async_forward_entry_setups * applying pr recommended changes * bump anova-wifi to 0.2.7 * Improvements to hopefully get this review ready * formatting changes * clean ups for pr review * remove unneeded unique id check. * bump ao anova_wifi 0.3.0 * rename device_id to device_unique_id * renamed to 'anova' * added unique_id to MockConfigEntry * removed leftover anova sous vides * added device id to strings * added error for incorrect device id * add has_entity_name * added attr name for tests * added authentication functionality * bump to 0.4.3 * split entity into its own class/object * pulling firmware version out of async_setup Co-authored-by: J. Nick Koston <nick@koston.org> * addressed pr changes * fixed pytest * added anova data model * removed unneeded time change * add logging in package * rework step_user * Update homeassistant/components/anova/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Removed lower from attr unique id Co-authored-by: J. Nick Koston <nick@koston.org> * Removed unneeded member variables in sensor Co-authored-by: J. Nick Koston <nick@koston.org> * removed repeated subclass attr Co-authored-by: J. Nick Koston <nick@koston.org> * simplify update_failed test * created descriptionentity * bump to 0.6.1 limit ws connect * add translation for sensor entities * version bump - support pro model * add anova to strict typing * fixed sensor not getting datas type * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Check for new devices in init * style changes * return false instead of config entry not ready * move serialize_device_list to utils * move repeating device check into api * moved unneeded code out of try except * fixed tests to get 100% cov * Update homeassistant/components/anova/strings.json Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-22 23:05:14 +00:00
def __init__(self, coordinator: AnovaCoordinator) -> None:
"""Initialize the Anova entity."""
super().__init__(coordinator)
self.device = coordinator.anova_device
self._attr_device_info = coordinator.device_info
2023-08-27 18:06:19 +00:00
class AnovaDescriptionEntity(AnovaEntity):
"""Defines an Anova entity that uses a description."""
Add Anova integration (#86254) * init setup of Anova Sous Vide * bump anova-wifi to 0.2.4 * Removed yaml support * Bump to anova-wifi 0.2.5 * Added support for adding sous vide while offline * Added basic test for sensor * added better tests for sensors and init * expanded code coverage * Decreased timedelta to lowest functioning value. * Updating my username * migrate to async_forward_entry_setups * applying pr recommended changes * bump anova-wifi to 0.2.7 * Improvements to hopefully get this review ready * formatting changes * clean ups for pr review * remove unneeded unique id check. * bump ao anova_wifi 0.3.0 * rename device_id to device_unique_id * renamed to 'anova' * added unique_id to MockConfigEntry * removed leftover anova sous vides * added device id to strings * added error for incorrect device id * add has_entity_name * added attr name for tests * added authentication functionality * bump to 0.4.3 * split entity into its own class/object * pulling firmware version out of async_setup Co-authored-by: J. Nick Koston <nick@koston.org> * addressed pr changes * fixed pytest * added anova data model * removed unneeded time change * add logging in package * rework step_user * Update homeassistant/components/anova/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Removed lower from attr unique id Co-authored-by: J. Nick Koston <nick@koston.org> * Removed unneeded member variables in sensor Co-authored-by: J. Nick Koston <nick@koston.org> * removed repeated subclass attr Co-authored-by: J. Nick Koston <nick@koston.org> * simplify update_failed test * created descriptionentity * bump to 0.6.1 limit ws connect * add translation for sensor entities * version bump - support pro model * add anova to strict typing * fixed sensor not getting datas type * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Check for new devices in init * style changes * return false instead of config entry not ready * move serialize_device_list to utils * move repeating device check into api * moved unneeded code out of try except * fixed tests to get 100% cov * Update homeassistant/components/anova/strings.json Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-22 23:05:14 +00:00
def __init__(
self, coordinator: AnovaCoordinator, description: EntityDescription
) -> None:
"""Initialize the entity and declare unique id based on description key."""
super().__init__(coordinator)
self.entity_description = description
self._attr_unique_id = f"{coordinator.device_unique_id}_{description.key}"