core/homeassistant/components/lg_thinq/switch.py

108 lines
3.3 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
"""Support for switch entities."""
from __future__ import annotations
import logging
from typing import Any
from thinqconnect import DeviceType
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 thinqconnect.devices.const import Property as ThinQProperty
from thinqconnect.integration import ActiveMode
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.components.switch import (
SwitchDeviceClass,
SwitchEntity,
SwitchEntityDescription,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import ThinqConfigEntry
from .entity import ThinQEntity
DEVICE_TYPE_SWITCH_MAP: dict[DeviceType, tuple[SwitchEntityDescription, ...]] = {
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
DeviceType.AIR_PURIFIER_FAN: (
SwitchEntityDescription(
key=ThinQProperty.AIR_FAN_OPERATION_MODE, translation_key="operation_power"
),
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
),
DeviceType.AIR_PURIFIER: (
SwitchEntityDescription(
key=ThinQProperty.AIR_PURIFIER_OPERATION_MODE,
translation_key="operation_power",
),
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
),
DeviceType.DEHUMIDIFIER: (
SwitchEntityDescription(
key=ThinQProperty.DEHUMIDIFIER_OPERATION_MODE,
translation_key="operation_power",
),
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
),
DeviceType.HUMIDIFIER: (
SwitchEntityDescription(
key=ThinQProperty.HUMIDIFIER_OPERATION_MODE,
translation_key="operation_power",
),
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
),
DeviceType.SYSTEM_BOILER: (
SwitchEntityDescription(
key=ThinQProperty.BOILER_OPERATION_MODE, translation_key="operation_power"
),
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
),
}
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(
hass: HomeAssistant,
entry: ThinqConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up an entry for switch platform."""
entities: list[ThinQSwitchEntity] = []
for coordinator in entry.runtime_data.values():
if (
descriptions := DEVICE_TYPE_SWITCH_MAP.get(
coordinator.api.device.device_type
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
)
) is not None:
for description in descriptions:
entities.extend(
ThinQSwitchEntity(coordinator, description, property_id)
for property_id in coordinator.api.get_active_idx(
description.key, ActiveMode.READ_WRITE
)
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
)
if entities:
async_add_entities(entities)
class ThinQSwitchEntity(ThinQEntity, SwitchEntity):
"""Represent a thinq switch platform."""
_attr_device_class = SwitchDeviceClass.SWITCH
def _update_status(self) -> None:
"""Update status itself."""
super()._update_status()
_LOGGER.debug(
"[%s:%s] update status: %s",
self.coordinator.device_name,
self.property_id,
self.data.is_on,
)
self._attr_is_on = self.data.is_on
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_turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch."""
_LOGGER.debug("[%s] async_turn_on", self.name)
await self.async_call_api(self.coordinator.api.async_turn_on(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
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the switch."""
_LOGGER.debug("[%s] async_turn_off", self.name)
await self.async_call_api(self.coordinator.api.async_turn_off(self.property_id))