Make Matter select entity values translatable (#126608)
* Make Matter select entity values lowercase * Make Matter select entity values lowercase
This commit is contained in:
parent
9e703b8224
commit
d3889cab9e
3 changed files with 20 additions and 14 deletions
|
@ -228,18 +228,18 @@ DISCOVERY_SCHEMAS = [
|
|||
key="MatterStartUpOnOff",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
translation_key="startup_on_off",
|
||||
options=["On", "Off", "Toggle", "Previous"],
|
||||
options=["on", "off", "toggle", "previous"],
|
||||
measurement_to_ha={
|
||||
0: "Off",
|
||||
1: "On",
|
||||
2: "Toggle",
|
||||
None: "Previous",
|
||||
0: "off",
|
||||
1: "on",
|
||||
2: "toggle",
|
||||
None: "previous",
|
||||
}.get,
|
||||
ha_to_native_value={
|
||||
"Off": 0,
|
||||
"On": 1,
|
||||
"Toggle": 2,
|
||||
"Previous": None,
|
||||
"off": 0,
|
||||
"on": 1,
|
||||
"toggle": 2,
|
||||
"previous": None,
|
||||
}.get,
|
||||
),
|
||||
entity_class=MatterSelectEntity,
|
||||
|
|
|
@ -136,7 +136,13 @@
|
|||
"name": "Mode"
|
||||
},
|
||||
"startup_on_off": {
|
||||
"name": "Power-on behavior on Startup"
|
||||
"name": "Power-on behavior on startup",
|
||||
"state": {
|
||||
"on": "[%key:common::state::on%]",
|
||||
"off": "[%key:common::state::off%]",
|
||||
"toggle": "[%key:common::action::toggle%]",
|
||||
"previous": "Previous"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
|
|
|
@ -87,16 +87,16 @@ async def test_attribute_select_entities(
|
|||
entity_id = "select.mock_dimmable_light_power_on_behavior_on_startup"
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
assert state.state == "Previous"
|
||||
assert state.attributes["options"] == ["On", "Off", "Toggle", "Previous"]
|
||||
assert state.state == "previous"
|
||||
assert state.attributes["options"] == ["on", "off", "toggle", "previous"]
|
||||
assert (
|
||||
state.attributes["friendly_name"]
|
||||
== "Mock Dimmable Light Power-on behavior on Startup"
|
||||
== "Mock Dimmable Light Power-on behavior on startup"
|
||||
)
|
||||
set_node_attribute(light_node, 1, 6, 16387, 1)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == "On"
|
||||
assert state.state == "on"
|
||||
# test that an invalid value (e.g. 255) leads to an unknown state
|
||||
set_node_attribute(light_node, 1, 6, 16387, 255)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
|
Loading…
Add table
Reference in a new issue