Prevent KeyError when Matter device sends invalid value for StartUpOnOff (#124280)

pull/124635/head
Marcel van der Veldt 2024-08-25 15:06:16 +02:00 committed by GitHub
parent f06c21c8cc
commit 51b520db0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -229,12 +229,12 @@ DISCOVERY_SCHEMAS = [
entity_category=EntityCategory.CONFIG,
translation_key="startup_on_off",
options=["On", "Off", "Toggle", "Previous"],
measurement_to_ha=lambda x: {
measurement_to_ha=lambda x: { # pylint: disable=unnecessary-lambda
0: "Off",
1: "On",
2: "Toggle",
None: "Previous",
}[x],
}.get(x),
ha_to_native_value=lambda x: {
"Off": 0,
"On": 1,