mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 22:38:02 -04:00
Rework translations in devolo Home Control (#184320)
This commit is contained in:
@@ -104,6 +104,5 @@ class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntit
|
||||
if not self._multi_level_switch_property.set(kwargs[ATTR_TEMPERATURE]):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "temperature"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
|
||||
@@ -79,6 +79,5 @@ class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
|
||||
if not self._multi_level_switch_property.set(position):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "cover position"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
|
||||
@@ -88,8 +88,7 @@ class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
||||
if not self._multi_level_switch_property.set(value):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "brightness"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
|
||||
def _set_switch(self, state: bool) -> None:
|
||||
@@ -102,8 +101,7 @@ class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
||||
if not self._binary_switch_property.set(state):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "state"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
except SwitchingProtected as err:
|
||||
raise ServiceValidationError(
|
||||
|
||||
@@ -83,8 +83,7 @@ class DevoloSirenDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, SirenEntity):
|
||||
if not self._multi_level_switch_property.set(tone):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "siren's tone"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
|
||||
@override
|
||||
|
||||
@@ -65,11 +65,11 @@
|
||||
"maintenance": {
|
||||
"message": "devolo Home Control is currently in maintenance mode."
|
||||
},
|
||||
"set": {
|
||||
"message": "An error occurred while setting the {placeholder}."
|
||||
"set_failed": {
|
||||
"message": "The devolo Home Control central unit did not accept the command."
|
||||
},
|
||||
"switch_protected": {
|
||||
"message": "Switching is protected by configuration."
|
||||
"message": "Remote switching is disabled for this device. Please use the physical button."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,7 @@ class DevoloSwitch(DevoloDeviceEntity, SwitchEntity):
|
||||
if not self._binary_switch_property.set(state=state):
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="set",
|
||||
translation_placeholders={"placeholder": "state"},
|
||||
translation_key="set_failed",
|
||||
)
|
||||
except SwitchingProtected as err:
|
||||
raise ServiceValidationError(
|
||||
|
||||
@@ -79,9 +79,8 @@ async def test_climate(
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "temperature"}
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
|
||||
@@ -95,9 +95,8 @@ async def test_cover(
|
||||
{ATTR_ENTITY_ID: f"{COVER_DOMAIN}.test_test", ATTR_POSITION: 50},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "cover position"}
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
|
||||
@@ -95,9 +95,8 @@ async def test_light_without_binary_sensor(
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test_test", ATTR_BRIGHTNESS: 50},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "brightness"}
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
@@ -171,9 +170,8 @@ async def test_light_with_binary_sensor(
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test_test"},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "state"}
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
||||
@@ -114,9 +114,8 @@ async def test_siren_switching(
|
||||
{"entity_id": f"{SIREN_DOMAIN}.test_test"},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "siren's tone"}
|
||||
|
||||
|
||||
async def test_siren_change_default_tone(
|
||||
|
||||
@@ -84,9 +84,8 @@ async def test_switch(
|
||||
{ATTR_ENTITY_ID: f"{SWITCH_DOMAIN}.test_test"},
|
||||
blocking=True,
|
||||
)
|
||||
assert error.value.translation_key == "set"
|
||||
assert error.value.translation_key == "set_failed"
|
||||
assert error.value.translation_domain == DOMAIN
|
||||
assert error.value.translation_placeholders == {"placeholder": "state"}
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
||||
Reference in New Issue
Block a user