Skip to content

Commit d23321c

Browse files
authored
Add tuya snapshot tests for dlq category (home-assistant#148549)
1 parent eb20292 commit d23321c

File tree

6 files changed

+1162
-1
lines changed

6 files changed

+1162
-1
lines changed

tests/components/tuya/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040
Platform.SENSOR,
4141
Platform.SWITCH,
4242
],
43+
"dlq_earu_electric_eawcpt": [
44+
# https://github.com/home-assistant/core/issues/102769
45+
Platform.SENSOR,
46+
Platform.SWITCH,
47+
],
48+
"dlq_metering_3pn_wifi": [
49+
# https://github.com/home-assistant/core/issues/143499
50+
Platform.SENSOR,
51+
],
4352
"kg_smart_valve": [
4453
# https://github.com/home-assistant/core/issues/148347
4554
Platform.SWITCH,

tests/components/tuya/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def mock_device(hass: HomeAssistant, mock_device_code: str) -> CustomerDev
143143
hass, f"{mock_device_code}.json", DOMAIN
144144
)
145145
device = MagicMock(spec=CustomerDevice)
146-
device.id = details["id"]
146+
device.id = details.get("id", "mocked_device_id")
147147
device.name = details["name"]
148148
device.category = details["category"]
149149
device.product_id = details["product_id"]
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
{
2+
"endpoint": "https://openapi.tuyaeu.com",
3+
"auth_type": 0,
4+
"country_code": "48",
5+
"app_type": "tuyaSmart",
6+
"mqtt_connected": null,
7+
"disabled_by": null,
8+
"disabled_polling": false,
9+
"name": "\u4e00\u8def\u5e26\u8ba1\u91cf\u78c1\u4fdd\u6301\u901a\u65ad\u5668",
10+
"model": "",
11+
"category": "dlq",
12+
"product_id": "0tnvg2xaisqdadcf",
13+
"product_name": "\u4e00\u8def\u5e26\u8ba1\u91cf\u78c1\u4fdd\u6301\u901a\u65ad\u5668",
14+
"online": true,
15+
"sub": false,
16+
"time_zone": "+01:00",
17+
"active_time": "2023-11-25T21:50:37+00:00",
18+
"create_time": "2023-11-25T21:49:06+00:00",
19+
"update_time": "2023-11-28T16:32:28+00:00",
20+
"function": {
21+
"switch": {
22+
"type": "Boolean",
23+
"value": {}
24+
},
25+
"countdown_1": {
26+
"type": "Integer",
27+
"value": {
28+
"unit": "s",
29+
"min": 0,
30+
"max": 86400,
31+
"scale": 0,
32+
"step": 1
33+
}
34+
},
35+
"relay_status": {
36+
"type": "Enum",
37+
"value": {
38+
"range": ["power_off", "power_on", "last"]
39+
}
40+
},
41+
"light_mode": {
42+
"type": "Enum",
43+
"value": {
44+
"range": ["relay", "pos", "none", "on"]
45+
}
46+
},
47+
"child_lock": {
48+
"type": "Boolean",
49+
"value": {}
50+
},
51+
"cycle_time": {
52+
"type": "String",
53+
"value": {
54+
"maxlen": 255
55+
}
56+
},
57+
"alarm_set_1": {
58+
"type": "Raw",
59+
"value": {}
60+
},
61+
"alarm_set_2": {
62+
"type": "Raw",
63+
"value": {}
64+
}
65+
},
66+
"status_range": {
67+
"switch": {
68+
"type": "Boolean",
69+
"value": {}
70+
},
71+
"countdown_1": {
72+
"type": "Integer",
73+
"value": {
74+
"unit": "s",
75+
"min": 0,
76+
"max": 86400,
77+
"scale": 0,
78+
"step": 1
79+
}
80+
},
81+
"add_ele": {
82+
"type": "Integer",
83+
"value": {
84+
"min": 0,
85+
"max": 50000,
86+
"scale": 3,
87+
"step": 100
88+
}
89+
},
90+
"cur_current": {
91+
"type": "Integer",
92+
"value": {
93+
"unit": "mA",
94+
"min": 0,
95+
"max": 100000,
96+
"scale": 0,
97+
"step": 1
98+
}
99+
},
100+
"cur_power": {
101+
"type": "Integer",
102+
"value": {
103+
"unit": "W",
104+
"min": 0,
105+
"max": 99999,
106+
"scale": 1,
107+
"step": 1
108+
}
109+
},
110+
"cur_voltage": {
111+
"type": "Integer",
112+
"value": {
113+
"unit": "V",
114+
"min": 0,
115+
"max": 5000,
116+
"scale": 1,
117+
"step": 1
118+
}
119+
},
120+
"test_bit": {
121+
"type": "Integer",
122+
"value": {
123+
"min": 0,
124+
"max": 5,
125+
"scale": 0,
126+
"step": 1
127+
}
128+
},
129+
"voltage_coe": {
130+
"type": "Integer",
131+
"value": {
132+
"min": 0,
133+
"max": 1000000,
134+
"scale": 0,
135+
"step": 1
136+
}
137+
},
138+
"electric_coe": {
139+
"type": "Integer",
140+
"value": {
141+
"min": 0,
142+
"max": 1000000,
143+
"scale": 0,
144+
"step": 1
145+
}
146+
},
147+
"power_coe": {
148+
"type": "Integer",
149+
"value": {
150+
"min": 0,
151+
"max": 1000000,
152+
"scale": 0,
153+
"step": 1
154+
}
155+
},
156+
"electricity_coe": {
157+
"type": "Integer",
158+
"value": {
159+
"min": 0,
160+
"max": 1000000,
161+
"scale": 0,
162+
"step": 1
163+
}
164+
},
165+
"fault": {
166+
"type": "Bitmap",
167+
"value": {
168+
"label": [
169+
"ov_cr",
170+
"ov_vol",
171+
"ov_pwr",
172+
"ls_cr",
173+
"ls_vol",
174+
"ls_pow",
175+
"short_circuit_alarm",
176+
"overload_alarm",
177+
"leakagecurr_alarm",
178+
"self_test_alarm",
179+
"high_temp",
180+
"unbalance_alarm",
181+
"miss_phase_alarm"
182+
]
183+
}
184+
},
185+
"relay_status": {
186+
"type": "Enum",
187+
"value": {
188+
"range": ["power_off", "power_on", "last"]
189+
}
190+
},
191+
"light_mode": {
192+
"type": "Enum",
193+
"value": {
194+
"range": ["relay", "pos", "none", "on"]
195+
}
196+
},
197+
"child_lock": {
198+
"type": "Boolean",
199+
"value": {}
200+
},
201+
"cycle_time": {
202+
"type": "String",
203+
"value": {
204+
"maxlen": 255
205+
}
206+
},
207+
"temp_value": {
208+
"type": "Integer",
209+
"value": {
210+
"unit": "\u2103",
211+
"min": 0,
212+
"max": 999,
213+
"scale": 0,
214+
"step": 1
215+
}
216+
},
217+
"alarm_set_1": {
218+
"type": "Raw",
219+
"value": {}
220+
},
221+
"alarm_set_2": {
222+
"type": "Raw",
223+
"value": {}
224+
}
225+
},
226+
"status": {
227+
"switch": true,
228+
"countdown_1": 0,
229+
"add_ele": 100,
230+
"cur_current": 2198,
231+
"cur_power": 4953,
232+
"cur_voltage": 2314,
233+
"test_bit": 2,
234+
"voltage_coe": 0,
235+
"electric_coe": 0,
236+
"power_coe": 0,
237+
"electricity_coe": 0,
238+
"fault": 0,
239+
"relay_status": "last",
240+
"light_mode": "relay",
241+
"child_lock": false,
242+
"cycle_time": "",
243+
"temp_value": 0,
244+
"alarm_set_1": "",
245+
"alarm_set_2": "AQAAAAMAAAAEAAAA"
246+
}
247+
}

0 commit comments

Comments
 (0)