Add support for translating custom attribute state (#83386)
* Add support for translating custom attribute state * Address review comment * Rename attribute to state_attributes, allow naming attributes
This commit is contained in:
parent
fc94569a0d
commit
255f35b979
5 changed files with 83 additions and 6 deletions
|
@ -104,6 +104,7 @@ class DemoClimate(ClimateEntity):
|
||||||
"""Representation of a demo climate device."""
|
"""Representation of a demo climate device."""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_translation_key = "ubercool"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -157,9 +158,9 @@ class DemoClimate(ClimateEntity):
|
||||||
self._hvac_mode = hvac_mode
|
self._hvac_mode = hvac_mode
|
||||||
self._aux = aux
|
self._aux = aux
|
||||||
self._current_swing_mode = swing_mode
|
self._current_swing_mode = swing_mode
|
||||||
self._fan_modes = ["On Low", "On High", "Auto Low", "Auto High", "Off"]
|
self._fan_modes = ["on_low", "on_high", "auto_low", "auto_high", "off"]
|
||||||
self._hvac_modes = hvac_modes
|
self._hvac_modes = hvac_modes
|
||||||
self._swing_modes = ["Auto", "1", "2", "3", "Off"]
|
self._swing_modes = ["auto", "1", "2", "3", "off"]
|
||||||
self._target_temperature_high = target_temp_high
|
self._target_temperature_high = target_temp_high
|
||||||
self._target_temperature_low = target_temp_low
|
self._target_temperature_low = target_temp_low
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,29 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"climate": {
|
||||||
|
"ubercool": {
|
||||||
|
"state_attributes": {
|
||||||
|
"fan_mode": {
|
||||||
|
"state": {
|
||||||
|
"auto_high": "Auto High",
|
||||||
|
"auto_low": "Auto Low",
|
||||||
|
"on_high": "On High",
|
||||||
|
"on_low": "On Low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"swing_mode": {
|
||||||
|
"state": {
|
||||||
|
"1": "1",
|
||||||
|
"2": "2",
|
||||||
|
"3": "3",
|
||||||
|
"auto": "Auto",
|
||||||
|
"off": "Off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"select": {
|
"select": {
|
||||||
"speed": {
|
"speed": {
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -81,6 +104,15 @@
|
||||||
"sleep": "Sleep"
|
"sleep": "Sleep"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vacuum": {
|
||||||
|
"model_s": {
|
||||||
|
"state_attributes": {
|
||||||
|
"cleaned_area": {
|
||||||
|
"name": "Cleaned Area"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,28 @@
|
||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"climate": {
|
||||||
|
"ubercool": {
|
||||||
|
"state_attributes": {
|
||||||
|
"fan_mode": {
|
||||||
|
"state": {
|
||||||
|
"auto_high": "Auto High",
|
||||||
|
"auto_low": "Auto Low",
|
||||||
|
"on_high": "On High",
|
||||||
|
"on_low": "On Low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"swing_mode": {
|
||||||
|
"state": {
|
||||||
|
"1": "1",
|
||||||
|
"2": "2",
|
||||||
|
"3": "3",
|
||||||
|
"auto": "Auto",
|
||||||
|
"off": "Off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"select": {
|
"select": {
|
||||||
"speed": {
|
"speed": {
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -18,6 +41,15 @@
|
||||||
"sleep": "Sleep"
|
"sleep": "Sleep"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vacuum": {
|
||||||
|
"model_s": {
|
||||||
|
"state_attributes": {
|
||||||
|
"cleaned_area": {
|
||||||
|
"name": "Cleaned Area"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"issues": {
|
"issues": {
|
||||||
|
@ -36,7 +68,8 @@
|
||||||
"fix_flow": {
|
"fix_flow": {
|
||||||
"abort": {
|
"abort": {
|
||||||
"not_tea_time": "Can not re-heat the tea at this time"
|
"not_tea_time": "Can not re-heat the tea at this time"
|
||||||
}
|
},
|
||||||
|
"step": {}
|
||||||
},
|
},
|
||||||
"title": "The tea is cold"
|
"title": "The tea is cold"
|
||||||
},
|
},
|
||||||
|
@ -62,6 +95,9 @@
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
|
"init": {
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
"options_1": {
|
"options_1": {
|
||||||
"data": {
|
"data": {
|
||||||
"bool": "Optional boolean",
|
"bool": "Optional boolean",
|
||||||
|
|
|
@ -105,6 +105,7 @@ class DemoVacuum(VacuumEntity):
|
||||||
"""Representation of a demo vacuum."""
|
"""Representation of a demo vacuum."""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_translation_key = "model_s"
|
||||||
|
|
||||||
def __init__(self, name: str, supported_features: VacuumEntityFeature) -> None:
|
def __init__(self, name: str, supported_features: VacuumEntityFeature) -> None:
|
||||||
"""Initialize the vacuum."""
|
"""Initialize the vacuum."""
|
||||||
|
@ -247,6 +248,7 @@ class StateDemoVacuum(StateVacuumEntity):
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_supported_features = SUPPORT_STATE_SERVICES
|
_attr_supported_features = SUPPORT_STATE_SERVICES
|
||||||
|
_attr_translation_key = "model_s"
|
||||||
|
|
||||||
def __init__(self, name: str) -> None:
|
def __init__(self, name: str) -> None:
|
||||||
"""Initialize the vacuum."""
|
"""Initialize the vacuum."""
|
||||||
|
|
|
@ -269,9 +269,15 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema:
|
||||||
},
|
},
|
||||||
vol.Optional("entity"): {
|
vol.Optional("entity"): {
|
||||||
str: {
|
str: {
|
||||||
str: vol.Schema(
|
str: {
|
||||||
{vol.Optional("state"): {str: cv.string_with_no_html}}
|
vol.Optional("state_attributes"): {
|
||||||
)
|
str: {
|
||||||
|
vol.Optional("name"): cv.string_with_no_html,
|
||||||
|
vol.Optional("state"): {str: cv.string_with_no_html},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
vol.Optional("state"): {str: cv.string_with_no_html},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue