Skip to content

Commit 40da606

Browse files
authored
Add support for Tuya swtz category (cooking thermometer) (home-assistant#152022)
1 parent d613b69 commit 40da606

File tree

7 files changed

+335
-15
lines changed

7 files changed

+335
-15
lines changed

homeassistant/components/tuya/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class DPCode(StrEnum):
169169
CONTROL_BACK = "control_back"
170170
CONTROL_BACK_MODE = "control_back_mode"
171171
COOK_TEMPERATURE = "cook_temperature"
172+
COOK_TEMPERATURE_2 = "cook_temperature_2"
172173
COOK_TIME = "cook_time"
173174
COUNTDOWN = "countdown" # Countdown
174175
COUNTDOWN_1 = "countdown_1"
@@ -388,6 +389,7 @@ class DPCode(StrEnum):
388389
TEMP_CONTROLLER = "temp_controller"
389390
TEMP_CORRECTION = "temp_correction"
390391
TEMP_CURRENT = "temp_current" # Current temperature in °C
392+
TEMP_CURRENT_2 = "temp_current_2"
391393
TEMP_CURRENT_EXTERNAL = (
392394
"temp_current_external" # Current external temperature in Celsius
393395
)

homeassistant/components/tuya/number.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@
215215
entity_category=EntityCategory.CONFIG,
216216
),
217217
),
218+
# Cooking thermometer
219+
"swtz": (
220+
NumberEntityDescription(
221+
key=DPCode.COOK_TEMPERATURE,
222+
translation_key="cook_temperature",
223+
entity_category=EntityCategory.CONFIG,
224+
),
225+
NumberEntityDescription(
226+
key=DPCode.COOK_TEMPERATURE_2,
227+
translation_key="indexed_cook_temperature",
228+
translation_placeholders={"index": "2"},
229+
entity_category=EntityCategory.CONFIG,
230+
),
231+
),
218232
# Robot Vacuum
219233
# https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo
220234
"sd": (

homeassistant/components/tuya/sensor.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,23 @@ class TuyaSensorEntityDescription(SensorEntityDescription):
11181118
state_class=SensorStateClass.MEASUREMENT,
11191119
),
11201120
),
1121+
# Cooking thermometer
1122+
"swtz": (
1123+
TuyaSensorEntityDescription(
1124+
key=DPCode.TEMP_CURRENT,
1125+
translation_key="temperature",
1126+
device_class=SensorDeviceClass.TEMPERATURE,
1127+
state_class=SensorStateClass.MEASUREMENT,
1128+
),
1129+
TuyaSensorEntityDescription(
1130+
key=DPCode.TEMP_CURRENT_2,
1131+
translation_key="indexed_temperature",
1132+
translation_placeholders={"index": "2"},
1133+
device_class=SensorDeviceClass.TEMPERATURE,
1134+
state_class=SensorStateClass.MEASUREMENT,
1135+
),
1136+
*BATTERY_SENSORS,
1137+
),
11211138
# Smart Gardening system
11221139
# https://developer.tuya.com/en/docs/iot/categorysz?id=Kaiuz4e6h7up0
11231140
"sz": (

homeassistant/components/tuya/strings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
"temperature": {
140140
"name": "[%key:component::sensor::entity_component::temperature::name%]"
141141
},
142+
"indexed_temperature": {
143+
"name": "Temperature {index}"
144+
},
142145
"time": {
143146
"name": "Time"
144147
},
@@ -176,10 +179,13 @@
176179
"name": "Powder"
177180
},
178181
"cook_temperature": {
179-
"name": "Cook temperature"
182+
"name": "Cooking temperature"
183+
},
184+
"indexed_cook_temperature": {
185+
"name": "Cooking temperature {index}"
180186
},
181187
"cook_time": {
182-
"name": "Cook time"
188+
"name": "Cooking time"
183189
},
184190
"cloud_recipe": {
185191
"name": "Cloud recipe"

tests/components/tuya/snapshots/test_init.ambr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7181,7 +7181,7 @@
71817181
'labels': set({
71827182
}),
71837183
'manufacturer': 'Tuya',
7184-
'model': 'Cooking Thermometer (unsupported)',
7184+
'model': 'Cooking Thermometer',
71857185
'model_id': '3rzngbyy',
71867186
'name': 'Grillhőmérő',
71877187
'name_by_user': None,

tests/components/tuya/snapshots/test_number.ambr

Lines changed: 128 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,122 @@
465465
'state': '1.0',
466466
})
467467
# ---
468+
# name: test_platform_setup_and_discovery[number.grillhomero_cooking_temperature-entry]
469+
EntityRegistryEntrySnapshot({
470+
'aliases': set({
471+
}),
472+
'area_id': None,
473+
'capabilities': dict({
474+
'max': 300.0,
475+
'min': -30.0,
476+
'mode': <NumberMode.AUTO: 'auto'>,
477+
'step': 0.1,
478+
}),
479+
'config_entry_id': <ANY>,
480+
'config_subentry_id': <ANY>,
481+
'device_class': None,
482+
'device_id': <ANY>,
483+
'disabled_by': None,
484+
'domain': 'number',
485+
'entity_category': <EntityCategory.CONFIG: 'config'>,
486+
'entity_id': 'number.grillhomero_cooking_temperature',
487+
'has_entity_name': True,
488+
'hidden_by': None,
489+
'icon': None,
490+
'id': <ANY>,
491+
'labels': set({
492+
}),
493+
'name': None,
494+
'options': dict({
495+
}),
496+
'original_device_class': None,
497+
'original_icon': None,
498+
'original_name': 'Cooking temperature',
499+
'platform': 'tuya',
500+
'previous_unique_id': None,
501+
'suggested_object_id': None,
502+
'supported_features': 0,
503+
'translation_key': 'cook_temperature',
504+
'unique_id': 'tuya.yybgnzr3ztwscook_temperature',
505+
'unit_of_measurement': '℃',
506+
})
507+
# ---
508+
# name: test_platform_setup_and_discovery[number.grillhomero_cooking_temperature-state]
509+
StateSnapshot({
510+
'attributes': ReadOnlyDict({
511+
'friendly_name': 'Grillhőmérő Cooking temperature',
512+
'max': 300.0,
513+
'min': -30.0,
514+
'mode': <NumberMode.AUTO: 'auto'>,
515+
'step': 0.1,
516+
'unit_of_measurement': '℃',
517+
}),
518+
'context': <ANY>,
519+
'entity_id': 'number.grillhomero_cooking_temperature',
520+
'last_changed': <ANY>,
521+
'last_reported': <ANY>,
522+
'last_updated': <ANY>,
523+
'state': 'unavailable',
524+
})
525+
# ---
526+
# name: test_platform_setup_and_discovery[number.grillhomero_cooking_temperature_2-entry]
527+
EntityRegistryEntrySnapshot({
528+
'aliases': set({
529+
}),
530+
'area_id': None,
531+
'capabilities': dict({
532+
'max': 300.0,
533+
'min': -30.0,
534+
'mode': <NumberMode.AUTO: 'auto'>,
535+
'step': 0.1,
536+
}),
537+
'config_entry_id': <ANY>,
538+
'config_subentry_id': <ANY>,
539+
'device_class': None,
540+
'device_id': <ANY>,
541+
'disabled_by': None,
542+
'domain': 'number',
543+
'entity_category': <EntityCategory.CONFIG: 'config'>,
544+
'entity_id': 'number.grillhomero_cooking_temperature_2',
545+
'has_entity_name': True,
546+
'hidden_by': None,
547+
'icon': None,
548+
'id': <ANY>,
549+
'labels': set({
550+
}),
551+
'name': None,
552+
'options': dict({
553+
}),
554+
'original_device_class': None,
555+
'original_icon': None,
556+
'original_name': 'Cooking temperature 2',
557+
'platform': 'tuya',
558+
'previous_unique_id': None,
559+
'suggested_object_id': None,
560+
'supported_features': 0,
561+
'translation_key': 'indexed_cook_temperature',
562+
'unique_id': 'tuya.yybgnzr3ztwscook_temperature_2',
563+
'unit_of_measurement': '℃',
564+
})
565+
# ---
566+
# name: test_platform_setup_and_discovery[number.grillhomero_cooking_temperature_2-state]
567+
StateSnapshot({
568+
'attributes': ReadOnlyDict({
569+
'friendly_name': 'Grillhőmérő Cooking temperature 2',
570+
'max': 300.0,
571+
'min': -30.0,
572+
'mode': <NumberMode.AUTO: 'auto'>,
573+
'step': 0.1,
574+
'unit_of_measurement': '℃',
575+
}),
576+
'context': <ANY>,
577+
'entity_id': 'number.grillhomero_cooking_temperature_2',
578+
'last_changed': <ANY>,
579+
'last_reported': <ANY>,
580+
'last_updated': <ANY>,
581+
'state': 'unavailable',
582+
})
583+
# ---
468584
# name: test_platform_setup_and_discovery[number.hot_water_heat_pump_temperature-entry]
469585
EntityRegistryEntrySnapshot({
470586
'aliases': set({
@@ -2107,7 +2223,7 @@
21072223
'state': '-2.0',
21082224
})
21092225
# ---
2110-
# name: test_platform_setup_and_discovery[number.sous_vide_cook_temperature-entry]
2226+
# name: test_platform_setup_and_discovery[number.sous_vide_cooking_temperature-entry]
21112227
EntityRegistryEntrySnapshot({
21122228
'aliases': set({
21132229
}),
@@ -2125,7 +2241,7 @@
21252241
'disabled_by': None,
21262242
'domain': 'number',
21272243
'entity_category': <EntityCategory.CONFIG: 'config'>,
2128-
'entity_id': 'number.sous_vide_cook_temperature',
2244+
'entity_id': 'number.sous_vide_cooking_temperature',
21292245
'has_entity_name': True,
21302246
'hidden_by': None,
21312247
'icon': None,
@@ -2137,7 +2253,7 @@
21372253
}),
21382254
'original_device_class': None,
21392255
'original_icon': None,
2140-
'original_name': 'Cook temperature',
2256+
'original_name': 'Cooking temperature',
21412257
'platform': 'tuya',
21422258
'previous_unique_id': None,
21432259
'suggested_object_id': None,
@@ -2147,25 +2263,25 @@
21472263
'unit_of_measurement': '℃',
21482264
})
21492265
# ---
2150-
# name: test_platform_setup_and_discovery[number.sous_vide_cook_temperature-state]
2266+
# name: test_platform_setup_and_discovery[number.sous_vide_cooking_temperature-state]
21512267
StateSnapshot({
21522268
'attributes': ReadOnlyDict({
2153-
'friendly_name': 'Sous Vide Cook temperature',
2269+
'friendly_name': 'Sous Vide Cooking temperature',
21542270
'max': 92.5,
21552271
'min': 25.0,
21562272
'mode': <NumberMode.AUTO: 'auto'>,
21572273
'step': 0.1,
21582274
'unit_of_measurement': '℃',
21592275
}),
21602276
'context': <ANY>,
2161-
'entity_id': 'number.sous_vide_cook_temperature',
2277+
'entity_id': 'number.sous_vide_cooking_temperature',
21622278
'last_changed': <ANY>,
21632279
'last_reported': <ANY>,
21642280
'last_updated': <ANY>,
21652281
'state': 'unavailable',
21662282
})
21672283
# ---
2168-
# name: test_platform_setup_and_discovery[number.sous_vide_cook_time-entry]
2284+
# name: test_platform_setup_and_discovery[number.sous_vide_cooking_time-entry]
21692285
EntityRegistryEntrySnapshot({
21702286
'aliases': set({
21712287
}),
@@ -2183,7 +2299,7 @@
21832299
'disabled_by': None,
21842300
'domain': 'number',
21852301
'entity_category': <EntityCategory.CONFIG: 'config'>,
2186-
'entity_id': 'number.sous_vide_cook_time',
2302+
'entity_id': 'number.sous_vide_cooking_time',
21872303
'has_entity_name': True,
21882304
'hidden_by': None,
21892305
'icon': None,
@@ -2195,7 +2311,7 @@
21952311
}),
21962312
'original_device_class': None,
21972313
'original_icon': None,
2198-
'original_name': 'Cook time',
2314+
'original_name': 'Cooking time',
21992315
'platform': 'tuya',
22002316
'previous_unique_id': None,
22012317
'suggested_object_id': None,
@@ -2205,18 +2321,18 @@
22052321
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
22062322
})
22072323
# ---
2208-
# name: test_platform_setup_and_discovery[number.sous_vide_cook_time-state]
2324+
# name: test_platform_setup_and_discovery[number.sous_vide_cooking_time-state]
22092325
StateSnapshot({
22102326
'attributes': ReadOnlyDict({
2211-
'friendly_name': 'Sous Vide Cook time',
2327+
'friendly_name': 'Sous Vide Cooking time',
22122328
'max': 5999.0,
22132329
'min': 1.0,
22142330
'mode': <NumberMode.AUTO: 'auto'>,
22152331
'step': 1.0,
22162332
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
22172333
}),
22182334
'context': <ANY>,
2219-
'entity_id': 'number.sous_vide_cook_time',
2335+
'entity_id': 'number.sous_vide_cooking_time',
22202336
'last_changed': <ANY>,
22212337
'last_reported': <ANY>,
22222338
'last_updated': <ANY>,

0 commit comments

Comments
 (0)