mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Add more f-series models to myuplink (#130283)
This commit is contained in:
parent
7fd9339ad8
commit
1da4579a09
@ -12,11 +12,12 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||||
|
from .const import F_SERIES
|
||||||
from .entity import MyUplinkEntity, MyUplinkSystemEntity
|
from .entity import MyUplinkEntity, MyUplinkSystemEntity
|
||||||
from .helpers import find_matching_platform
|
from .helpers import find_matching_platform, transform_model_series
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, BinarySensorEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, BinarySensorEntityDescription]] = {
|
||||||
"F730": {
|
F_SERIES: {
|
||||||
"43161": BinarySensorEntityDescription(
|
"43161": BinarySensorEntityDescription(
|
||||||
key="elect_add",
|
key="elect_add",
|
||||||
translation_key="elect_add",
|
translation_key="elect_add",
|
||||||
@ -50,6 +51,7 @@ def get_description(device_point: DevicePoint) -> BinarySensorEntityDescription
|
|||||||
2. Default to None
|
2. Default to None
|
||||||
"""
|
"""
|
||||||
prefix, _, _ = device_point.category.partition(" ")
|
prefix, _, _ = device_point.category.partition(" ")
|
||||||
|
prefix = transform_model_series(prefix)
|
||||||
return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id)
|
return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,3 +6,5 @@ API_ENDPOINT = "https://api.myuplink.com"
|
|||||||
OAUTH2_AUTHORIZE = "https://api.myuplink.com/oauth/authorize"
|
OAUTH2_AUTHORIZE = "https://api.myuplink.com/oauth/authorize"
|
||||||
OAUTH2_TOKEN = "https://api.myuplink.com/oauth/token"
|
OAUTH2_TOKEN = "https://api.myuplink.com/oauth/token"
|
||||||
OAUTH2_SCOPES = ["WRITESYSTEM", "READSYSTEM", "offline_access"]
|
OAUTH2_SCOPES = ["WRITESYSTEM", "READSYSTEM", "offline_access"]
|
||||||
|
|
||||||
|
F_SERIES = "f-series"
|
||||||
|
@ -6,6 +6,8 @@ from homeassistant.components.number import NumberEntityDescription
|
|||||||
from homeassistant.components.sensor import SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntityDescription
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
|
|
||||||
|
from .const import F_SERIES
|
||||||
|
|
||||||
|
|
||||||
def find_matching_platform(
|
def find_matching_platform(
|
||||||
device_point: DevicePoint,
|
device_point: DevicePoint,
|
||||||
@ -86,8 +88,9 @@ PARAMETER_ID_TO_EXCLUDE_F730 = (
|
|||||||
"47941",
|
"47941",
|
||||||
"47975",
|
"47975",
|
||||||
"48009",
|
"48009",
|
||||||
"48042",
|
|
||||||
"48072",
|
"48072",
|
||||||
|
"48442",
|
||||||
|
"49909",
|
||||||
"50113",
|
"50113",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,7 +113,7 @@ def skip_entity(model: str, device_point: DevicePoint) -> bool:
|
|||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
if "F730" in model:
|
if model.lower().startswith("f"):
|
||||||
# Entity names containing weekdays are used for advanced scheduling in the
|
# Entity names containing weekdays are used for advanced scheduling in the
|
||||||
# heat pump and should not be exposed in the integration
|
# heat pump and should not be exposed in the integration
|
||||||
if any(d in device_point.parameter_name.lower() for d in WEEKDAYS):
|
if any(d in device_point.parameter_name.lower() for d in WEEKDAYS):
|
||||||
@ -118,3 +121,10 @@ def skip_entity(model: str, device_point: DevicePoint) -> bool:
|
|||||||
if device_point.parameter_id in PARAMETER_ID_TO_EXCLUDE_F730:
|
if device_point.parameter_id in PARAMETER_ID_TO_EXCLUDE_F730:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def transform_model_series(prefix: str) -> str:
|
||||||
|
"""Remap all F-series models."""
|
||||||
|
if prefix.lower().startswith("f"):
|
||||||
|
return F_SERIES
|
||||||
|
return prefix
|
||||||
|
@ -10,8 +10,9 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||||
|
from .const import F_SERIES
|
||||||
from .entity import MyUplinkEntity
|
from .entity import MyUplinkEntity
|
||||||
from .helpers import find_matching_platform, skip_entity
|
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||||
|
|
||||||
DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, NumberEntityDescription] = {
|
DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, NumberEntityDescription] = {
|
||||||
"DM": NumberEntityDescription(
|
"DM": NumberEntityDescription(
|
||||||
@ -22,7 +23,7 @@ DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, NumberEntityDescription] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, NumberEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, NumberEntityDescription]] = {
|
||||||
"F730": {
|
F_SERIES: {
|
||||||
"40940": NumberEntityDescription(
|
"40940": NumberEntityDescription(
|
||||||
key="degree_minutes",
|
key="degree_minutes",
|
||||||
translation_key="degree_minutes",
|
translation_key="degree_minutes",
|
||||||
@ -48,6 +49,7 @@ def get_description(device_point: DevicePoint) -> NumberEntityDescription | None
|
|||||||
3. Default to None
|
3. Default to None
|
||||||
"""
|
"""
|
||||||
prefix, _, _ = device_point.category.partition(" ")
|
prefix, _, _ = device_point.category.partition(" ")
|
||||||
|
prefix = transform_model_series(prefix)
|
||||||
description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(
|
description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(
|
||||||
device_point.parameter_id
|
device_point.parameter_id
|
||||||
)
|
)
|
||||||
|
@ -25,8 +25,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||||
|
from .const import F_SERIES
|
||||||
from .entity import MyUplinkEntity
|
from .entity import MyUplinkEntity
|
||||||
from .helpers import find_matching_platform, skip_entity
|
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||||
|
|
||||||
DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
||||||
"°C": SensorEntityDescription(
|
"°C": SensorEntityDescription(
|
||||||
@ -139,7 +140,7 @@ DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
|||||||
MARKER_FOR_UNKNOWN_VALUE = -32768
|
MARKER_FOR_UNKNOWN_VALUE = -32768
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SensorEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SensorEntityDescription]] = {
|
||||||
"F730": {
|
F_SERIES: {
|
||||||
"43108": SensorEntityDescription(
|
"43108": SensorEntityDescription(
|
||||||
key="fan_mode",
|
key="fan_mode",
|
||||||
translation_key="fan_mode",
|
translation_key="fan_mode",
|
||||||
@ -200,6 +201,7 @@ def get_description(device_point: DevicePoint) -> SensorEntityDescription | None
|
|||||||
"""
|
"""
|
||||||
description = None
|
description = None
|
||||||
prefix, _, _ = device_point.category.partition(" ")
|
prefix, _, _ = device_point.category.partition(" ")
|
||||||
|
prefix = transform_model_series(prefix)
|
||||||
description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(
|
description = CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(
|
||||||
device_point.parameter_id
|
device_point.parameter_id
|
||||||
)
|
)
|
||||||
|
@ -12,11 +12,12 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||||
|
from .const import F_SERIES
|
||||||
from .entity import MyUplinkEntity
|
from .entity import MyUplinkEntity
|
||||||
from .helpers import find_matching_platform, skip_entity
|
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SwitchEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SwitchEntityDescription]] = {
|
||||||
"F730": {
|
F_SERIES: {
|
||||||
"50004": SwitchEntityDescription(
|
"50004": SwitchEntityDescription(
|
||||||
key="temporary_lux",
|
key="temporary_lux",
|
||||||
translation_key="temporary_lux",
|
translation_key="temporary_lux",
|
||||||
@ -47,6 +48,7 @@ def get_description(device_point: DevicePoint) -> SwitchEntityDescription | None
|
|||||||
2. Default to None
|
2. Default to None
|
||||||
"""
|
"""
|
||||||
prefix, _, _ = device_point.category.partition(" ")
|
prefix, _, _ = device_point.category.partition(" ")
|
||||||
|
prefix = transform_model_series(prefix)
|
||||||
return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id)
|
return CATEGORY_BASED_DESCRIPTIONS.get(prefix, {}).get(device_point.parameter_id)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user