mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Sensibo select platform translations (#82743)
This commit is contained in:
parent
ee21bc5d7f
commit
a5225a3606
@ -308,11 +308,13 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
if "fanLevel" not in self.device_data.active_features:
|
if "fanLevel" not in self.device_data.active_features:
|
||||||
raise HomeAssistantError("Current mode doesn't support setting Fanlevel")
|
raise HomeAssistantError("Current mode doesn't support setting Fanlevel")
|
||||||
|
|
||||||
|
transformation = self.device_data.fan_modes_translated
|
||||||
await self.async_send_api_call(
|
await self.async_send_api_call(
|
||||||
key=AC_STATE_TO_DATA["fanLevel"],
|
key=AC_STATE_TO_DATA["fanLevel"],
|
||||||
value=fan_mode,
|
value=fan_mode,
|
||||||
name="fanLevel",
|
name="fanLevel",
|
||||||
assumed_state=False,
|
assumed_state=False,
|
||||||
|
transformation=transformation,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
@ -347,11 +349,13 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
if "swing" not in self.device_data.active_features:
|
if "swing" not in self.device_data.active_features:
|
||||||
raise HomeAssistantError("Current mode doesn't support setting Swing")
|
raise HomeAssistantError("Current mode doesn't support setting Swing")
|
||||||
|
|
||||||
|
transformation = self.device_data.swing_modes_translated
|
||||||
await self.async_send_api_call(
|
await self.async_send_api_call(
|
||||||
key=AC_STATE_TO_DATA["swing"],
|
key=AC_STATE_TO_DATA["swing"],
|
||||||
value=swing_mode,
|
value=swing_mode,
|
||||||
name="swing",
|
name="swing",
|
||||||
assumed_state=False,
|
assumed_state=False,
|
||||||
|
transformation=transformation,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_turn_on(self) -> None:
|
async def async_turn_on(self) -> None:
|
||||||
@ -502,8 +506,11 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
value: Any,
|
value: Any,
|
||||||
name: str,
|
name: str,
|
||||||
assumed_state: bool = False,
|
assumed_state: bool = False,
|
||||||
|
transformation: dict | None = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Make service call to api."""
|
"""Make service call to api."""
|
||||||
|
if transformation:
|
||||||
|
value = transformation[value]
|
||||||
result = await self._client.async_set_ac_state_property(
|
result = await self._client.async_set_ac_state_property(
|
||||||
self._device_id,
|
self._device_id,
|
||||||
name,
|
name,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "sensibo",
|
"domain": "sensibo",
|
||||||
"name": "Sensibo",
|
"name": "Sensibo",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/sensibo",
|
"documentation": "https://www.home-assistant.io/integrations/sensibo",
|
||||||
"requirements": ["pysensibo==1.0.22"],
|
"requirements": ["pysensibo==1.0.25"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"codeowners": ["@andrey-git", "@gjohansson-ST"],
|
"codeowners": ["@andrey-git", "@gjohansson-ST"],
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
|
@ -27,6 +27,7 @@ class SensiboSelectDescriptionMixin:
|
|||||||
data_key: str
|
data_key: str
|
||||||
value_fn: Callable[[SensiboDevice], str | None]
|
value_fn: Callable[[SensiboDevice], str | None]
|
||||||
options_fn: Callable[[SensiboDevice], list[str] | None]
|
options_fn: Callable[[SensiboDevice], list[str] | None]
|
||||||
|
transformation: Callable[[SensiboDevice], dict | None]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -44,6 +45,8 @@ DEVICE_SELECT_TYPES = (
|
|||||||
icon="mdi:air-conditioner",
|
icon="mdi:air-conditioner",
|
||||||
value_fn=lambda data: data.horizontal_swing_mode,
|
value_fn=lambda data: data.horizontal_swing_mode,
|
||||||
options_fn=lambda data: data.horizontal_swing_modes,
|
options_fn=lambda data: data.horizontal_swing_modes,
|
||||||
|
translation_key="horizontalswing",
|
||||||
|
transformation=lambda data: data.horizontal_swing_modes_translated,
|
||||||
),
|
),
|
||||||
SensiboSelectEntityDescription(
|
SensiboSelectEntityDescription(
|
||||||
key="light",
|
key="light",
|
||||||
@ -52,6 +55,8 @@ DEVICE_SELECT_TYPES = (
|
|||||||
icon="mdi:flashlight",
|
icon="mdi:flashlight",
|
||||||
value_fn=lambda data: data.light_mode,
|
value_fn=lambda data: data.light_mode,
|
||||||
options_fn=lambda data: data.light_modes,
|
options_fn=lambda data: data.light_modes,
|
||||||
|
translation_key="light",
|
||||||
|
transformation=lambda data: data.light_modes_translated,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -116,6 +121,10 @@ class SensiboSelect(SensiboDeviceBaseEntity, SelectEntity):
|
|||||||
@async_handle_api_call
|
@async_handle_api_call
|
||||||
async def async_send_api_call(self, key: str, value: Any) -> bool:
|
async def async_send_api_call(self, key: str, value: Any) -> bool:
|
||||||
"""Make service call to api."""
|
"""Make service call to api."""
|
||||||
|
transformation = self.entity_description.transformation(self.device_data)
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
assert transformation is not None
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"name": self.entity_description.key,
|
"name": self.entity_description.key,
|
||||||
"value": value,
|
"value": value,
|
||||||
@ -125,7 +134,7 @@ class SensiboSelect(SensiboDeviceBaseEntity, SelectEntity):
|
|||||||
result = await self._client.async_set_ac_state_property(
|
result = await self._client.async_set_ac_state_property(
|
||||||
self._device_id,
|
self._device_id,
|
||||||
data["name"],
|
data["name"],
|
||||||
data["value"],
|
transformation[data["value"]],
|
||||||
data["ac_states"],
|
data["ac_states"],
|
||||||
data["assumed_state"],
|
data["assumed_state"],
|
||||||
)
|
)
|
||||||
|
@ -45,6 +45,28 @@
|
|||||||
"humidity": "Humidity"
|
"humidity": "Humidity"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"select": {
|
||||||
|
"horizontalswing": {
|
||||||
|
"state": {
|
||||||
|
"stopped": "Stopped",
|
||||||
|
"fixedleft": "Fixed left",
|
||||||
|
"fixedcenterleft": "Fixed center left",
|
||||||
|
"fixedcenter": "Fixed center",
|
||||||
|
"fixedcenterright": "Fixed center right",
|
||||||
|
"fixedright": "Fixed right",
|
||||||
|
"fixedleftright": "Fixed left right",
|
||||||
|
"rangecenter": "Range center",
|
||||||
|
"rangefull": "Range full"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"light": {
|
||||||
|
"state": {
|
||||||
|
"on": "On",
|
||||||
|
"dim": "Dim",
|
||||||
|
"off": "Off"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"select": {
|
||||||
|
"horizontalswing": {
|
||||||
|
"state": {
|
||||||
|
"fixedcenter": "Fixed center",
|
||||||
|
"fixedcenterleft": "Fixed center left",
|
||||||
|
"fixedcenterright": "Fixed center right",
|
||||||
|
"fixedleft": "Fixed left",
|
||||||
|
"fixedleftright": "Fixed left right",
|
||||||
|
"fixedright": "Fixed right",
|
||||||
|
"rangecenter": "Range center",
|
||||||
|
"rangefull": "Range full",
|
||||||
|
"stopped": "Stopped"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"light": {
|
||||||
|
"state": {
|
||||||
|
"dim": "Dim",
|
||||||
|
"off": "Off",
|
||||||
|
"on": "On"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"sensitivity": {
|
"sensitivity": {
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -1898,7 +1898,7 @@ pysaj==0.0.16
|
|||||||
pysdcp==1
|
pysdcp==1
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.0.22
|
pysensibo==1.0.25
|
||||||
|
|
||||||
# homeassistant.components.serial
|
# homeassistant.components.serial
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
|
@ -1351,7 +1351,7 @@ pyruckus==0.16
|
|||||||
pysabnzbd==1.1.1
|
pysabnzbd==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.0.22
|
pysensibo==1.0.25
|
||||||
|
|
||||||
# homeassistant.components.serial
|
# homeassistant.components.serial
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
|
@ -99,8 +99,8 @@ async def test_climate(
|
|||||||
"fan_modes": ["quiet", "low", "medium"],
|
"fan_modes": ["quiet", "low", "medium"],
|
||||||
"swing_modes": [
|
"swing_modes": [
|
||||||
"stopped",
|
"stopped",
|
||||||
"fixedTop",
|
"fixedtop",
|
||||||
"fixedMiddleTop",
|
"fixedmiddletop",
|
||||||
],
|
],
|
||||||
"current_temperature": 21.2,
|
"current_temperature": 21.2,
|
||||||
"temperature": 25,
|
"temperature": 25,
|
||||||
@ -203,13 +203,13 @@ async def test_climate_swing(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_SWING_MODE,
|
SERVICE_SET_SWING_MODE,
|
||||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_SWING_MODE: "fixedTop"},
|
{ATTR_ENTITY_ID: state1.entity_id, ATTR_SWING_MODE: "fixedtop"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state2 = hass.states.get("climate.hallway")
|
state2 = hass.states.get("climate.hallway")
|
||||||
assert state2.attributes["swing_mode"] == "fixedTop"
|
assert state2.attributes["swing_mode"] == "fixedtop"
|
||||||
|
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
get_data.parsed["ABC999111"],
|
get_data.parsed["ABC999111"],
|
||||||
@ -240,13 +240,13 @@ async def test_climate_swing(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_SWING_MODE,
|
SERVICE_SET_SWING_MODE,
|
||||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_SWING_MODE: "fixedTop"},
|
{ATTR_ENTITY_ID: state1.entity_id, ATTR_SWING_MODE: "fixedtop"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state3 = hass.states.get("climate.hallway")
|
state3 = hass.states.get("climate.hallway")
|
||||||
assert state3.attributes["swing_mode"] == "fixedTop"
|
assert state3.attributes["swing_mode"] == "fixedtop"
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_temperatures(
|
async def test_climate_temperatures(
|
||||||
|
@ -34,7 +34,7 @@ async def test_select(
|
|||||||
assert state1.state == "stopped"
|
assert state1.state == "stopped"
|
||||||
|
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
get_data.parsed["ABC999111"], "horizontal_swing_mode", "fixedLeft"
|
get_data.parsed["ABC999111"], "horizontal_swing_mode", "fixedleft"
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
@ -48,7 +48,7 @@ async def test_select(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state1 = hass.states.get("select.hallway_horizontal_swing")
|
state1 = hass.states.get("select.hallway_horizontal_swing")
|
||||||
assert state1.state == "fixedLeft"
|
assert state1.state == "fixedleft"
|
||||||
|
|
||||||
|
|
||||||
async def test_select_set_option(
|
async def test_select_set_option(
|
||||||
@ -95,7 +95,7 @@ async def test_select_set_option(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SELECT_DOMAIN,
|
SELECT_DOMAIN,
|
||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedLeft"},
|
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedleft"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -136,7 +136,7 @@ async def test_select_set_option(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SELECT_DOMAIN,
|
SELECT_DOMAIN,
|
||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedLeft"},
|
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedleft"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -154,10 +154,10 @@ async def test_select_set_option(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SELECT_DOMAIN,
|
SELECT_DOMAIN,
|
||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedLeft"},
|
{ATTR_ENTITY_ID: state1.entity_id, ATTR_OPTION: "fixedleft"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state2 = hass.states.get("select.hallway_horizontal_swing")
|
state2 = hass.states.get("select.hallway_horizontal_swing")
|
||||||
assert state2.state == "fixedLeft"
|
assert state2.state == "fixedleft"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user