mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Make Meater cook state an enum (#146958)
This commit is contained in:
parent
ad64139b8e
commit
cb21bb6542
@ -25,6 +25,18 @@ from . import MeaterCoordinator
|
||||
from .const import DOMAIN
|
||||
from .coordinator import MeaterConfigEntry
|
||||
|
||||
COOK_STATES = {
|
||||
"Not Started": "not_started",
|
||||
"Configured": "configured",
|
||||
"Started": "started",
|
||||
"Ready For Resting": "ready_for_resting",
|
||||
"Resting": "resting",
|
||||
"Slightly Underdone": "slightly_underdone",
|
||||
"Finished": "finished",
|
||||
"Slightly Overdone": "slightly_overdone",
|
||||
"OVERCOOK!": "overcooked",
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MeaterSensorEntityDescription(SensorEntityDescription):
|
||||
@ -80,13 +92,13 @@ SENSOR_TYPES = (
|
||||
available=lambda probe: probe is not None and probe.cook is not None,
|
||||
value=lambda probe: probe.cook.name if probe.cook else None,
|
||||
),
|
||||
# One of Not Started, Configured, Started, Ready For Resting, Resting,
|
||||
# Slightly Underdone, Finished, Slightly Overdone, OVERCOOK!. Not translated.
|
||||
MeaterSensorEntityDescription(
|
||||
key="cook_state",
|
||||
translation_key="cook_state",
|
||||
available=lambda probe: probe is not None and probe.cook is not None,
|
||||
value=lambda probe: probe.cook.state if probe.cook else None,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=list(COOK_STATES.values()),
|
||||
value=lambda probe: COOK_STATES.get(probe.cook.state) if probe.cook else None,
|
||||
),
|
||||
# Target temperature
|
||||
MeaterSensorEntityDescription(
|
||||
|
@ -40,7 +40,18 @@
|
||||
"name": "Cooking"
|
||||
},
|
||||
"cook_state": {
|
||||
"name": "Cook state"
|
||||
"name": "Cook state",
|
||||
"state": {
|
||||
"not_started": "Not started",
|
||||
"configured": "Configured",
|
||||
"started": "Started",
|
||||
"ready_for_resting": "Ready for resting",
|
||||
"resting": "Resting",
|
||||
"slightly_underdone": "Slightly underdone",
|
||||
"finished": "Finished",
|
||||
"slightly_overdone": "Slightly overdone",
|
||||
"overcooked": "Overcooked"
|
||||
}
|
||||
},
|
||||
"cook_target_temp": {
|
||||
"name": "Target temperature"
|
||||
|
@ -161,7 +161,19 @@
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'not_started',
|
||||
'configured',
|
||||
'started',
|
||||
'ready_for_resting',
|
||||
'resting',
|
||||
'slightly_underdone',
|
||||
'finished',
|
||||
'slightly_overdone',
|
||||
'overcooked',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
@ -179,7 +191,7 @@
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'meater',
|
||||
@ -194,13 +206,25 @@
|
||||
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_cook_state-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'enum',
|
||||
'options': list([
|
||||
'not_started',
|
||||
'configured',
|
||||
'started',
|
||||
'ready_for_resting',
|
||||
'resting',
|
||||
'slightly_underdone',
|
||||
'finished',
|
||||
'slightly_overdone',
|
||||
'overcooked',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_cook_state',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'Started',
|
||||
'state': 'started',
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_cook_target_temp-entry]
|
||||
|
Loading…
x
Reference in New Issue
Block a user