From 91013ece60e6b20235fa7f4306a7d8793751383e Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Sun, 19 Jul 2026 04:33:23 +0000 Subject: [PATCH] fix: translate machine_state sensor values; bump to 0.4.1 machine_state was rendering the raw lowercase OCF values (idle/active/ pause) untranslated in the UI. Add device_class=enum, options, and a translation_key matching the existing pattern used by ice_making_status and connection_mode, in both the shared operational.py capability and oven.py's separate machine_state sensor. Bump patch version for this fix plus the ice_type 'off' translation and iot_class correction earlier on this branch. --- custom_components/localthings/manifest.json | 2 +- .../localthings/registry/capabilities/operational.py | 4 +++- .../localthings/registry/capabilities/oven.py | 4 +++- custom_components/localthings/strings.json | 7 +++++++ custom_components/localthings/translations/en.json | 7 +++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/custom_components/localthings/manifest.json b/custom_components/localthings/manifest.json index 799740b..e1c770b 100644 --- a/custom_components/localthings/manifest.json +++ b/custom_components/localthings/manifest.json @@ -12,5 +12,5 @@ "pyOpenSSL>=23.0", "smartthings-local>=0.1.0" ], - "version": "0.4.0" + "version": "0.4.1" } diff --git a/custom_components/localthings/registry/capabilities/operational.py b/custom_components/localthings/registry/capabilities/operational.py index 8056a9f..bc9efb2 100644 --- a/custom_components/localthings/registry/capabilities/operational.py +++ b/custom_components/localthings/registry/capabilities/operational.py @@ -75,7 +75,9 @@ OPERATIONAL_STATE = Capability( poll_tier='hot', entities=( SensorDesc(key='machine_state', field='x.com.samsung.da.state', - name='Machine state', value_fn=_to_ocf), + name='Machine state', device_class='enum', + options=('idle', 'active', 'pause'), + translation_key='machine_state', value_fn=_to_ocf), # cycle_active is a bool derived from machine_state; used by the # adapter to gate oven writes (cycle_active_field='cycle_active'). # Harmless for non-oven appliances — just an extra bool in state. diff --git a/custom_components/localthings/registry/capabilities/oven.py b/custom_components/localthings/registry/capabilities/oven.py index 2780335..764d66c 100644 --- a/custom_components/localthings/registry/capabilities/oven.py +++ b/custom_components/localthings/registry/capabilities/oven.py @@ -223,7 +223,9 @@ OVEN_OPERATIONAL_STATE = Capability( poll_tier='hot', entities=( SensorDesc(key='machine_state', field='x.com.samsung.da.state', - name='Machine state', icon='mdi:stove', value_fn=_to_ocf), + name='Machine state', icon='mdi:stove', + device_class='enum', options=('idle', 'active', 'pause'), + translation_key='machine_state', value_fn=_to_ocf), BinarySensorDesc(key='cycle_active', field='x.com.samsung.da.state', name='Cycle active', device_class='running', value_fn=lambda v: _SAMSUNG_STATE_TO_OCF.get(v) == 'active'), diff --git a/custom_components/localthings/strings.json b/custom_components/localthings/strings.json index 5fe72c9..c6220ef 100644 --- a/custom_components/localthings/strings.json +++ b/custom_components/localthings/strings.json @@ -115,6 +115,13 @@ "observe": "Push (observe)", "poll": "Polling" } + }, + "machine_state": { + "state": { + "idle": "Idle", + "active": "Active", + "pause": "Paused" + } } } }, diff --git a/custom_components/localthings/translations/en.json b/custom_components/localthings/translations/en.json index 5fe72c9..c6220ef 100644 --- a/custom_components/localthings/translations/en.json +++ b/custom_components/localthings/translations/en.json @@ -115,6 +115,13 @@ "observe": "Push (observe)", "poll": "Polling" } + }, + "machine_state": { + "state": { + "idle": "Idle", + "active": "Active", + "pause": "Paused" + } } } },