Add state attribute translations to Switchbot (#90861)

pull/95350/head
Patrick ZAJDA 2023-06-27 11:52:20 +02:00 committed by GitHub
parent 22f29e8c84
commit 58f8f9c82a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 0 deletions

View File

@ -51,6 +51,7 @@ class SwitchBotCurtainEntity(SwitchbotEntity, CoverEntity, RestoreEntity):
| CoverEntityFeature.STOP
| CoverEntityFeature.SET_POSITION
)
_attr_translation_key = "cover"
def __init__(self, coordinator: SwitchbotDataUpdateCoordinator) -> None:
"""Initialize the Switchbot."""
@ -120,6 +121,7 @@ class SwitchBotBlindTiltEntity(SwitchbotEntity, CoverEntity, RestoreEntity):
| CoverEntityFeature.STOP_TILT
| CoverEntityFeature.SET_TILT_POSITION
)
_attr_translation_key = "cover"
CLOSED_UP_THRESHOLD = 80
CLOSED_DOWN_THRESHOLD = 20

View File

@ -40,6 +40,7 @@ class SwitchBotHumidifier(SwitchbotSwitchedEntity, HumidifierEntity):
_attr_available_modes = [MODE_NORMAL, MODE_AUTO]
_device: switchbot.SwitchbotHumidifier
_attr_min_humidity = 1
_attr_translation_key = "humidifier"
@property
def is_on(self) -> bool | None:

View File

@ -26,6 +26,7 @@ async def async_setup_entry(
class SwitchBotLock(SwitchbotEntity, LockEntity):
"""Representation of a Switchbot lock."""
_attr_translation_key = "lock"
_device: switchbot.SwitchbotLock
def __init__(self, coordinator: SwitchbotDataUpdateCoordinator) -> None:

View File

@ -108,6 +108,60 @@
"power": {
"name": "[%key:component::sensor::entity_component::power::name%]"
}
},
"cover": {
"cover": {
"state_attributes": {
"last_run_success": {
"state": {
"true": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"false": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
}
}
}
},
"humidifier": {
"humidifier": {
"state_attributes": {
"last_run_success": {
"state": {
"true": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"false": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
}
}
}
},
"lock": {
"lock": {
"state_attributes": {
"last_run_success": {
"state": {
"true": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"false": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
}
}
}
},
"switch": {
"bot": {
"state_attributes": {
"last_run_success": {
"state": {
"true": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"false": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
},
"switch_mode": {
"state": {
"true": "Pull/Retract",
"false": "Momentary"
}
}
}
}
}
}
}

View File

@ -34,6 +34,7 @@ class SwitchBotSwitch(SwitchbotSwitchedEntity, SwitchEntity, RestoreEntity):
"""Representation of a Switchbot switch."""
_attr_device_class = SwitchDeviceClass.SWITCH
_attr_translation_key = "bot"
_device: switchbot.Switchbot
def __init__(self, coordinator: SwitchbotDataUpdateCoordinator) -> None: