mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix airgradient select entities (#120549)
This commit is contained in:
parent
34e266762e
commit
e8a3e3c8db
@ -79,62 +79,59 @@ LED_BAR_ENTITIES: tuple[AirGradientSelectEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
LEARNING_TIME_OFFSET_OPTIONS = {
|
LEARNING_TIME_OFFSET_OPTIONS = [
|
||||||
12: "12",
|
"12",
|
||||||
60: "60",
|
"60",
|
||||||
120: "120",
|
"120",
|
||||||
360: "360",
|
"360",
|
||||||
720: "720",
|
"720",
|
||||||
}
|
]
|
||||||
LEARNING_TIME_OFFSET_OPTIONS_INVERSE = {
|
|
||||||
v: k for k, v in LEARNING_TIME_OFFSET_OPTIONS.items()
|
ABC_DAYS = [
|
||||||
}
|
"8",
|
||||||
ABC_DAYS = {
|
"30",
|
||||||
8: "8",
|
"90",
|
||||||
30: "30",
|
"180",
|
||||||
90: "90",
|
"0",
|
||||||
180: "180",
|
]
|
||||||
0: "off",
|
|
||||||
}
|
|
||||||
ABC_DAYS_INVERSE = {v: k for k, v in ABC_DAYS.items()}
|
def _get_value(value: int, values: list[str]) -> str | None:
|
||||||
|
str_value = str(value)
|
||||||
|
return str_value if str_value in values else None
|
||||||
|
|
||||||
|
|
||||||
CONTROL_ENTITIES: tuple[AirGradientSelectEntityDescription, ...] = (
|
CONTROL_ENTITIES: tuple[AirGradientSelectEntityDescription, ...] = (
|
||||||
AirGradientSelectEntityDescription(
|
AirGradientSelectEntityDescription(
|
||||||
key="nox_index_learning_time_offset",
|
key="nox_index_learning_time_offset",
|
||||||
translation_key="nox_index_learning_time_offset",
|
translation_key="nox_index_learning_time_offset",
|
||||||
options=list(LEARNING_TIME_OFFSET_OPTIONS_INVERSE),
|
options=LEARNING_TIME_OFFSET_OPTIONS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda config: LEARNING_TIME_OFFSET_OPTIONS.get(
|
value_fn=lambda config: _get_value(
|
||||||
config.nox_learning_offset
|
config.nox_learning_offset, LEARNING_TIME_OFFSET_OPTIONS
|
||||||
),
|
|
||||||
set_value_fn=lambda client, value: client.set_nox_learning_offset(
|
|
||||||
LEARNING_TIME_OFFSET_OPTIONS_INVERSE.get(value, 12)
|
|
||||||
),
|
),
|
||||||
|
set_value_fn=lambda client, value: client.set_nox_learning_offset(int(value)),
|
||||||
),
|
),
|
||||||
AirGradientSelectEntityDescription(
|
AirGradientSelectEntityDescription(
|
||||||
key="voc_index_learning_time_offset",
|
key="voc_index_learning_time_offset",
|
||||||
translation_key="voc_index_learning_time_offset",
|
translation_key="voc_index_learning_time_offset",
|
||||||
options=list(LEARNING_TIME_OFFSET_OPTIONS_INVERSE),
|
options=LEARNING_TIME_OFFSET_OPTIONS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda config: LEARNING_TIME_OFFSET_OPTIONS.get(
|
value_fn=lambda config: _get_value(
|
||||||
config.nox_learning_offset
|
config.tvoc_learning_offset, LEARNING_TIME_OFFSET_OPTIONS
|
||||||
),
|
|
||||||
set_value_fn=lambda client, value: client.set_tvoc_learning_offset(
|
|
||||||
LEARNING_TIME_OFFSET_OPTIONS_INVERSE.get(value, 12)
|
|
||||||
),
|
),
|
||||||
|
set_value_fn=lambda client, value: client.set_tvoc_learning_offset(int(value)),
|
||||||
),
|
),
|
||||||
AirGradientSelectEntityDescription(
|
AirGradientSelectEntityDescription(
|
||||||
key="co2_automatic_baseline_calibration",
|
key="co2_automatic_baseline_calibration",
|
||||||
translation_key="co2_automatic_baseline_calibration",
|
translation_key="co2_automatic_baseline_calibration",
|
||||||
options=list(ABC_DAYS_INVERSE),
|
options=ABC_DAYS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda config: ABC_DAYS.get(
|
value_fn=lambda config: _get_value(
|
||||||
config.co2_automatic_baseline_calibration_days
|
config.co2_automatic_baseline_calibration_days, ABC_DAYS
|
||||||
),
|
),
|
||||||
set_value_fn=lambda client,
|
set_value_fn=lambda client,
|
||||||
value: client.set_co2_automatic_baseline_calibration(
|
value: client.set_co2_automatic_baseline_calibration(int(value)),
|
||||||
ABC_DAYS_INVERSE.get(value, 0)
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
'30',
|
'30',
|
||||||
'90',
|
'90',
|
||||||
'180',
|
'180',
|
||||||
'off',
|
'0',
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'config_entry_id': <ANY>,
|
'config_entry_id': <ANY>,
|
||||||
@ -49,7 +49,7 @@
|
|||||||
'30',
|
'30',
|
||||||
'90',
|
'90',
|
||||||
'180',
|
'180',
|
||||||
'off',
|
'0',
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
@ -415,7 +415,7 @@
|
|||||||
'30',
|
'30',
|
||||||
'90',
|
'90',
|
||||||
'180',
|
'180',
|
||||||
'off',
|
'0',
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'config_entry_id': <ANY>,
|
'config_entry_id': <ANY>,
|
||||||
@ -454,7 +454,7 @@
|
|||||||
'30',
|
'30',
|
||||||
'90',
|
'90',
|
||||||
'180',
|
'180',
|
||||||
'off',
|
'0',
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user