core/homeassistant/components/lg_thinq/entity.py

96 lines
3.1 KiB
Python
Raw Normal View History

Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
"""Base class for ThinQ entities."""
from __future__ import annotations
from collections.abc import Coroutine
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
import logging
from typing import Any
from thinqconnect import ThinQAPIException
from thinqconnect.devices.const import Location
from thinqconnect.integration import PropertyState
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
from homeassistant.core import callback
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import COMPANY, DOMAIN
from .coordinator import DeviceDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
EMPTY_STATE = PropertyState()
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
class ThinQEntity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
"""The base implementation of all lg thinq entities."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: DeviceDataUpdateCoordinator,
entity_description: EntityDescription,
property_id: str,
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
) -> None:
"""Initialize an entity."""
super().__init__(coordinator)
self.entity_description = entity_description
self.property_id = property_id
self.location = self.coordinator.api.get_location_for_idx(self.property_id)
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
self._attr_device_info = dr.DeviceInfo(
identifiers={(DOMAIN, coordinator.unique_id)},
manufacturer=COMPANY,
model=coordinator.api.device.model_name,
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
name=coordinator.device_name,
)
self._attr_unique_id = f"{coordinator.unique_id}_{self.property_id}"
if self.location is not None and self.location not in (
Location.MAIN,
Location.OVEN,
coordinator.sub_id,
):
self._attr_translation_placeholders = {"location": self.location}
self._attr_translation_key = (
f"{entity_description.translation_key}_for_location"
)
@property
def data(self) -> PropertyState:
"""Return the state data of entity."""
return self.coordinator.data.get(self.property_id, EMPTY_STATE)
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
def _update_status(self) -> None:
"""Update status itself.
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
All inherited classes can update their own status in here.
"""
@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
self._update_status()
self.async_write_ha_state()
async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass."""
await super().async_added_to_hass()
self._handle_coordinator_update()
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
async def async_call_api(self, target: Coroutine[Any, Any, Any]) -> None:
"""Call the given api and handle exception."""
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
try:
await target
Add LG ThinQ Integration (#123860) * Add manifest.json * add switch entity * Add tests * fix function's name * adjust the changes after running scipt * Update homeassistant/components/lgthinq/__init__.py Accept the suggested change about format. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Accept suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/services.yaml * Update homeassistant/components/lgthinq/switch.py Accpet suggested change for log removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/strings.json Accept suggested change for service removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/manifest.json Accept suggested change for spaces removal Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Delete homeassistant/components/lgthinq/icons.json * Update __init__.py Remove unnecessary check code * Modification to pass ruff-format * Modification for mypy issues * Remove service registry and related code * Update strings.json Modification to pass the prettier issues * Update manifest.json Modification to pass the prettier issues * Update homeassistant/components/lgthinq/__init__.py Remove the unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary log. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Remove unnecessary code. Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/__init__.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for the review and related autocheck * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/config_flow.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Modifications for reviews and autocheck * Modifications for the reviews and autocheck * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/const.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Update homeassistant/components/lgthinq/device.py Co-authored-by: Franck Nijhof <frenck@frenck.nl> * Remove type definition after Final * Update const.py Do not use Final for DOMAIN * Refactoring for reviews - remove thinq.py - remove type definition - remove entry name in config flow - put config flow steps into a single step * Update tests - remove region * Refactoring for reviews - move property.py into PyPI library - replace error_code handling with try/catch - remove http response handling - remove generic - remove unnecessary class or map instance - refactor adding entities logic * Refactoring - remove unused code - change import path * Update tests * Refactoring for reviews 1. Use coordinator extended class instead of LGDevice 2. Rename entity_helper.py to entity.py 3. Move entity description to each entity file 4. Remove dynamic device creation code * Refactoring for reviews * Update requirements * Fix for reviews * Modify tests for reviews * Update for reviews * Remove property info and description class * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/lgthinq/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lgthinq/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update for reviews * Fix ruff issues * Fix ruff check * Fix for reviews * Fix ruff check * Fix for reviews * Fix prettier failure and hassfest failure --------- Co-authored-by: Jangwon Lee <jangwon.lee@lge.com> Co-authored-by: yunseon.park <yunseon.park@lge.com> Co-authored-by: nahyun.lee <nahyun.lee@lge.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-30 13:12:49 +00:00
except ThinQAPIException as exc:
raise ServiceValidationError(
exc.message,
translation_domain=DOMAIN,
translation_key=exc.code,
) from exc
finally:
await self.coordinator.async_request_refresh()