Add translatable states to washer job state in SmartThings (#139368)

* Add translatable states to washer job state in SmartThings

* fix

* Update homeassistant/components/smartthings/sensor.py
This commit is contained in:
Joost Lekkerkerker 2025-02-26 18:07:56 +01:00 committed by GitHub
parent 3eea932b24
commit 2694828451
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 91 additions and 7 deletions

View File

@ -43,6 +43,14 @@ THERMOSTAT_CAPABILITIES = {
}
JOB_STATE_MAP = {
"airWash": "air_wash",
"airwash": "air_wash",
"aIRinse": "ai_rinse",
"aISpin": "ai_spin",
"aIWash": "ai_wash",
"delayWash": "delay_wash",
"weightSensing": "weight_sensing",
"freezeProtection": "freeze_protection",
"preDrain": "pre_drain",
"preWash": "pre_wash",
"wrinklePrevent": "wrinkle_prevent",
@ -257,7 +265,7 @@ CAPABILITY_TO_SENSORS: dict[
key=Attribute.DISHWASHER_JOB_STATE,
translation_key="dishwasher_job_state",
options=[
"airwash",
"air_wash",
"cooling",
"drying",
"finish",
@ -868,6 +876,26 @@ CAPABILITY_TO_SENSORS: dict[
SmartThingsSensorEntityDescription(
key=Attribute.WASHER_JOB_STATE,
translation_key="washer_job_state",
options=[
"air_wash",
"ai_rinse",
"ai_spin",
"ai_wash",
"cooling",
"delay_wash",
"drying",
"finish",
"none",
"pre_wash",
"rinse",
"spin",
"wash",
"weight_sensing",
"wrinkle_prevent",
"freeze_protection",
],
device_class=SensorDeviceClass.ENUM,
value_fn=lambda value: JOB_STATE_MAP.get(value, value),
)
],
Attribute.COMPLETION_TIME: [

View File

@ -85,7 +85,7 @@
"dishwasher_job_state": {
"name": "Job state",
"state": {
"airwash": "Airwash",
"air_wash": "Air wash",
"cooling": "Cooling",
"drying": "Drying",
"finish": "Finish",
@ -345,7 +345,25 @@
}
},
"washer_job_state": {
"name": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::name%]"
"name": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::name%]",
"state": {
"air_wash": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::air_wash%]",
"ai_rise": "AI rise",
"ai_spin": "AI spin",
"ai_wash": "AI wash",
"cooling": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::cooling%]",
"delay_wash": "Delay wash",
"drying": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::drying%]",
"finish": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::finish%]",
"none": "None",
"pre_wash": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::pre_wash%]",
"rinse": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::rinse%]",
"spin": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::spin%]",
"wash": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::wash%]",
"weight_sensing": "Weight sensing",
"wrinkle_prevent": "[%key:component::smartthings::entity::sensor::dishwasher_job_state::state::wrinkle_prevent%]",
"freeze_protection": "Freeze protection"
}
}
}
}

View File

@ -2921,7 +2921,7 @@
'area_id': None,
'capabilities': dict({
'options': list([
'airwash',
'air_wash',
'cooling',
'drying',
'finish',
@ -2967,7 +2967,7 @@
'device_class': 'enum',
'friendly_name': 'Dishwasher Job state',
'options': list([
'airwash',
'air_wash',
'cooling',
'drying',
'finish',
@ -3765,7 +3765,26 @@
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'capabilities': dict({
'options': list([
'air_wash',
'ai_rinse',
'ai_spin',
'ai_wash',
'cooling',
'delay_wash',
'drying',
'finish',
'none',
'pre_wash',
'rinse',
'spin',
'wash',
'weight_sensing',
'wrinkle_prevent',
'freeze_protection',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
@ -3783,7 +3802,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'Job state',
'platform': 'smartthings',
@ -3797,7 +3816,26 @@
# name: test_all_entities[da_wm_wm_000001][sensor.washer_job_state-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'Washer Job state',
'options': list([
'air_wash',
'ai_rinse',
'ai_spin',
'ai_wash',
'cooling',
'delay_wash',
'drying',
'finish',
'none',
'pre_wash',
'rinse',
'spin',
'wash',
'weight_sensing',
'wrinkle_prevent',
'freeze_protection',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.washer_job_state',