pyimouapi 1.4.3__tar.gz → 1.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/PKG-INFO +1 -1
  2. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/__init__.py +1 -1
  3. pyimouapi-1.4.5/pyimouapi/bulb_light.py +201 -0
  4. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/const.py +1 -1
  5. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/device.py +52 -11
  6. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/dormant_retry.py +1 -1
  7. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/ha_device.py +389 -96
  8. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/openapi.py +61 -11
  9. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/PKG-INFO +1 -1
  10. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/SOURCES.txt +3 -0
  11. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyproject.toml +1 -1
  12. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/setup.py +1 -1
  13. pyimouapi-1.4.5/tests/test_bulb_light.py +252 -0
  14. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_device_stream.py +1 -1
  15. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_event_identifier_map.py +10 -1
  16. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_get_devices.py +18 -0
  17. pyimouapi-1.4.5/tests/test_live_stream_source.py +206 -0
  18. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_openapi_http.py +65 -3
  19. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_siren.py +2 -2
  20. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_switch_status_aggregation.py +5 -4
  21. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/LICENSE +0 -0
  22. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/README.md +0 -0
  23. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/alarm_mode.py +0 -0
  24. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/collection_point.py +0 -0
  25. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/exceptions.py +0 -0
  26. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/pic_decode.py +0 -0
  27. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/push.py +0 -0
  28. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/py.typed +0 -0
  29. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/select_option.py +0 -0
  30. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/sensor.py +0 -0
  31. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi/siren.py +0 -0
  32. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/dependency_links.txt +0 -0
  33. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/not-zip-safe +0 -0
  34. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/requires.txt +0 -0
  35. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/pyimouapi.egg-info/top_level.txt +0 -0
  36. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/setup.cfg +0 -0
  37. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_accessory_device_id.py +0 -0
  38. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_alarm_control_panel.py +0 -0
  39. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_alarm_mode.py +0 -0
  40. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_alarm_pir_switch.py +0 -0
  41. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_auth_failure_propagates.py +0 -0
  42. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_bind_device.py +0 -0
  43. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_channel_id_and_api_guards.py +0 -0
  44. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_collect_property_entities.py +0 -0
  45. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_collection_point.py +0 -0
  46. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_connection_pool.py +0 -0
  47. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_device_image.py +0 -0
  48. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_device_summaries.py +0 -0
  49. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_dormant_write_retry.py +0 -0
  50. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_entity_tables_golden.py +0 -0
  51. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_feature_switches.py +0 -0
  52. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_lookup_property.py +0 -0
  53. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_message_callback.py +0 -0
  54. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_motion_detect_excepts.py +0 -0
  55. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_packaging.py +0 -0
  56. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_pic_decode.py +0 -0
  57. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_product_id_guard.py +0 -0
  58. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_push.py +0 -0
  59. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_select_option.py +0 -0
  60. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_sensor_normalize.py +0 -0
  61. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_services_entities_concurrency.py +0 -0
  62. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_set_text_value.py +0 -0
  63. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_shared_status_reads.py +0 -0
  64. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_status_read_concurrency.py +0 -0
  65. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_update_from_detail.py +0 -0
  66. {pyimouapi-1.4.3 → pyimouapi-1.4.5}/tests/test_write_optimistic_state.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyimouapi
3
- Version: 1.4.3
3
+ Version: 1.4.5
4
4
  Summary: A package for imou open api
5
5
  Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
6
  Author: Imou-OpenPlatform
@@ -1,4 +1,4 @@
1
- __version__ = "1.4.3"
1
+ __version__ = "1.4.5"
2
2
 
3
3
  from .device import ImouChannel, ImouDevice, ImouDeviceManager
4
4
  from .exceptions import (
@@ -0,0 +1,201 @@
1
+ """Color bulb state for one Home Assistant light.
2
+
3
+ White and color are color modes. Named scenes are effects. The relay is the
4
+ light itself, not a separate switch.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ REF_SWITCH = "11900"
12
+ REF_MODE = "131800"
13
+ REF_BRIGHTNESS = "131900"
14
+ REF_COLOR_TEMP = "132000"
15
+ REF_HUE = "132100"
16
+ REF_SATURATION = "132200"
17
+ REF_VALUE = "132300"
18
+ REF_SCENE = "132400"
19
+
20
+ MODE_WHITE = 0
21
+ MODE_COLOR = 1
22
+ MODE_SCENE = 2
23
+
24
+ MIN_KELVIN = 2700
25
+ MAX_KELVIN = 6500
26
+
27
+ BULB_PROPERTY_REFS = (
28
+ REF_SWITCH,
29
+ REF_MODE,
30
+ REF_BRIGHTNESS,
31
+ REF_COLOR_TEMP,
32
+ REF_HUE,
33
+ REF_SATURATION,
34
+ REF_VALUE,
35
+ REF_SCENE,
36
+ )
37
+
38
+ # Effect name shown on the light, and the scene enum the bulb stores.
39
+ BULB_SCENES: tuple[tuple[str, int], ...] = (
40
+ ("Daylight", 0),
41
+ ("Night light", 1),
42
+ ("Movie", 2),
43
+ ("Relax", 3),
44
+ ("Romantic", 4),
45
+ ("Party", 5),
46
+ ("Christmas", 6),
47
+ ("Halloween", 7),
48
+ ("Wake up", 8),
49
+ )
50
+
51
+ _SCENE_BY_NAME = dict(BULB_SCENES)
52
+ _NAME_BY_SCENE = {value: name for name, value in BULB_SCENES}
53
+
54
+
55
+ def empty_bulb_state() -> dict[str, int | bool]:
56
+ """Defaults match the thing model until the first property read."""
57
+ return {
58
+ "on": False,
59
+ "mode": MODE_WHITE,
60
+ "brightness": 50,
61
+ "color_temp": 3500,
62
+ "hue": 0,
63
+ "saturation": 0,
64
+ "value": 100,
65
+ "scene": 0,
66
+ }
67
+
68
+
69
+ def scene_effect_names() -> list[str]:
70
+ """Effect list for the light card, in thing-model order."""
71
+ return [name for name, _value in BULB_SCENES]
72
+
73
+
74
+ def scene_effect_name(scene: int) -> str | None:
75
+ """Return the effect name for a scene enum, if we know it."""
76
+ return _NAME_BY_SCENE.get(scene)
77
+
78
+
79
+ def percent_to_brightness(percent: int) -> int:
80
+ """Map a 1-100 bulb level onto Home Assistant brightness 1-255."""
81
+ clamped = max(1, min(100, percent))
82
+ return max(1, min(255, round(clamped * 255 / 100)))
83
+
84
+
85
+ def brightness_to_percent(brightness: int) -> int:
86
+ """Map Home Assistant brightness 0-255 onto a 1-100 bulb level."""
87
+ clamped = max(0, min(255, brightness))
88
+ return max(1, min(100, round(clamped * 100 / 255)))
89
+
90
+
91
+ def _as_int(raw: Any) -> int | None:
92
+ if isinstance(raw, bool):
93
+ return int(raw)
94
+ if isinstance(raw, int):
95
+ return raw
96
+ if isinstance(raw, float):
97
+ return int(raw)
98
+ if isinstance(raw, str):
99
+ text = raw.strip()
100
+ if text.lstrip("-").isdigit():
101
+ return int(text)
102
+ return None
103
+
104
+
105
+ def apply_bulb_properties(state: dict[str, Any], values: dict[str, Any]) -> None:
106
+ """Fold a ref→value map into bulb state. Unknown or empty values are skipped."""
107
+ if REF_SWITCH in values:
108
+ raw = values[REF_SWITCH]
109
+ if isinstance(raw, bool):
110
+ state["on"] = raw
111
+ else:
112
+ parsed = _as_int(raw)
113
+ if parsed is not None:
114
+ state["on"] = parsed == 1
115
+ for key, ref in (
116
+ ("mode", REF_MODE),
117
+ ("brightness", REF_BRIGHTNESS),
118
+ ("color_temp", REF_COLOR_TEMP),
119
+ ("hue", REF_HUE),
120
+ ("saturation", REF_SATURATION),
121
+ ("value", REF_VALUE),
122
+ ("scene", REF_SCENE),
123
+ ):
124
+ if ref not in values:
125
+ continue
126
+ parsed = _as_int(values[ref])
127
+ if parsed is None:
128
+ continue
129
+ state[key] = _clamp_read(key, parsed)
130
+
131
+
132
+ def properties_for_turn_off() -> dict[str, int]:
133
+ """Turn the bulb off."""
134
+ return {REF_SWITCH: 0}
135
+
136
+
137
+ def properties_for_turn_on(
138
+ state: dict[str, Any],
139
+ *,
140
+ brightness: int | None = None,
141
+ color_temp_kelvin: int | None = None,
142
+ hs_color: tuple[float, float] | None = None,
143
+ effect: str | None = None,
144
+ ) -> dict[str, int]:
145
+ """Build one property write for light.turn_on.
146
+
147
+ White mode is brightness plus color temperature. Color mode is hue,
148
+ saturation, and its own brightness. A write only includes the values the
149
+ caller passed, so moving color temperature does not copy the color
150
+ brightness, and moving the color does not copy the white brightness.
151
+ """
152
+ payload: dict[str, int] = {REF_SWITCH: 1}
153
+ if effect is not None:
154
+ scene = _SCENE_BY_NAME.get(effect)
155
+ if scene is None:
156
+ raise ValueError(f"unknown bulb effect: {effect}")
157
+ payload[REF_MODE] = MODE_SCENE
158
+ payload[REF_SCENE] = scene
159
+ return payload
160
+ if hs_color is not None:
161
+ hue, saturation = hs_color
162
+ payload[REF_MODE] = MODE_COLOR
163
+ payload[REF_HUE] = max(0, min(360, round(hue)))
164
+ payload[REF_SATURATION] = max(0, min(100, round(saturation)))
165
+ if brightness is not None:
166
+ payload[REF_VALUE] = max(1, min(100, brightness_to_percent(brightness)))
167
+ return payload
168
+ if color_temp_kelvin is not None:
169
+ payload[REF_MODE] = MODE_WHITE
170
+ payload[REF_COLOR_TEMP] = max(
171
+ MIN_KELVIN, min(MAX_KELVIN, int(color_temp_kelvin))
172
+ )
173
+ if brightness is not None:
174
+ payload[REF_BRIGHTNESS] = max(
175
+ 1, min(100, brightness_to_percent(brightness))
176
+ )
177
+ return payload
178
+ if brightness is not None:
179
+ level = brightness_to_percent(brightness)
180
+ if int(state["mode"]) == MODE_COLOR:
181
+ payload[REF_VALUE] = level
182
+ else:
183
+ # A scene (or any non-white mode) does not use the white slider.
184
+ # Brightness alone moves the bulb back to white so the lamp matches.
185
+ if int(state["mode"]) != MODE_WHITE:
186
+ payload[REF_MODE] = MODE_WHITE
187
+ payload[REF_BRIGHTNESS] = level
188
+ return payload
189
+
190
+
191
+ def _clamp_read(key: str, value: int) -> int:
192
+ """Keep a device reading inside the thing-model range."""
193
+ if key == "brightness":
194
+ return max(1, min(100, value))
195
+ if key == "color_temp":
196
+ return max(MIN_KELVIN, min(MAX_KELVIN, value))
197
+ if key == "hue":
198
+ return max(0, min(360, value))
199
+ if key in ("saturation", "value"):
200
+ return max(0, min(100, value))
201
+ return value
@@ -563,7 +563,7 @@ SENSOR_TYPE_REF: dict[str, list[dict[str, Any]]] = {
563
563
  "ref": "14600",
564
564
  "default": "e2",
565
565
  "ref_type": "properties",
566
- "expression": "('e1' if data['14603']==0 else 'e2') if data['14603'] != 1 else int(data['14602'] / data['14601'] * 100)",
566
+ "expression": "('e1' if data['14603']==0 else 'e2') if data['14603'] != 1 else ('e2' if not data['14601'] else int(data['14602'] / data['14601'] * 100))",
567
567
  }
568
568
  ],
569
569
  "battery": [
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import logging
5
5
  from dataclasses import dataclass
6
+ from time import monotonic
6
7
  from typing import Any
7
8
 
8
9
  from .const import (
@@ -77,6 +78,16 @@ from .openapi import ImouOpenApiClient
77
78
 
78
79
  _LOGGER = logging.getLogger(__name__)
79
80
 
81
+ # A failed product-model fetch is retried after this, instead of on every push.
82
+ _EVENT_MAP_RETRY_SECONDS = 60
83
+
84
+
85
+ def _text_or_default(value: Any, default: str = "unknown") -> str:
86
+ """Return a string field, treating JSON null and blanks as the default."""
87
+ if isinstance(value, str) and value:
88
+ return value
89
+ return default
90
+
80
91
 
81
92
  def _parse_event_ref_map(data: dict[str, Any] | None) -> dict[str, str]:
82
93
  """Build {event.ref: event.identifier} from a getProductModel payload."""
@@ -184,6 +195,7 @@ class ImouDevice:
184
195
  self._is_multi = False
185
196
  self._is_ipc = False
186
197
  self._access_type = "PaaS"
198
+ self._source = ""
187
199
 
188
200
  @property
189
201
  def device_id(self) -> str:
@@ -247,6 +259,14 @@ class ImouDevice:
247
259
  def access_type(self) -> str:
248
260
  return self._access_type
249
261
 
262
+ @property
263
+ def source(self) -> str:
264
+ """Device detail ``source``, such as ``bind`` or ``share``."""
265
+ return self._source
266
+
267
+ def set_source(self, source: str) -> None:
268
+ self._source = source
269
+
250
270
  def set_product_id(self, product_id: str) -> None:
251
271
  self._product_id = product_id
252
272
 
@@ -282,6 +302,7 @@ class ImouDeviceManager:
282
302
  def __init__(self, imou_api_client: ImouOpenApiClient):
283
303
  self._imou_api_client = imou_api_client
284
304
  self._event_maps: dict[str, dict[str, str]] = {}
305
+ self._event_map_failed_at: dict[str, float] = {}
285
306
  self._event_map_locks: dict[str, asyncio.Lock] = {}
286
307
  self._event_map_locks_guard = asyncio.Lock()
287
308
 
@@ -311,15 +332,23 @@ class ImouDeviceManager:
311
332
  async with lock:
312
333
  if product_id in self._event_maps:
313
334
  return
335
+ failed_at = self._event_map_failed_at.get(product_id)
336
+ if (
337
+ failed_at is not None
338
+ and monotonic() - failed_at < _EVENT_MAP_RETRY_SECONDS
339
+ ):
340
+ return
314
341
  try:
315
342
  data = await self.async_get_product_model(product_id)
316
343
  except Exception:
344
+ self._event_map_failed_at[product_id] = monotonic()
317
345
  _LOGGER.warning(
318
346
  "getProductModel failed for product_id=%s",
319
347
  product_id,
320
348
  exc_info=True,
321
349
  )
322
350
  return
351
+ self._event_map_failed_at.pop(product_id, None)
323
352
  self._event_maps[product_id] = _parse_event_ref_map(data)
324
353
 
325
354
  def cached_event_map(self, product_id: str) -> dict[str, str]:
@@ -364,8 +393,8 @@ class ImouDeviceManager:
364
393
  data = await self._imou_api_client.async_request_api(
365
394
  API_ENDPOINT_LIST_DEVICE_DETAILS, params
366
395
  )
367
- device_list = data.get(PARAM_DEVICE_LIST) or []
368
- if not device_list:
396
+ device_list = data.get(PARAM_DEVICE_LIST) if isinstance(data, dict) else None
397
+ if not isinstance(device_list, list) or not device_list:
369
398
  return []
370
399
  devices = []
371
400
  iot_devices = []
@@ -379,7 +408,9 @@ class ImouDeviceManager:
379
408
  device_id, device_name, device_status, brand, device_model
380
409
  )
381
410
  if PARAM_DEVICE_ABILITY in device:
382
- imou_device.set_device_ability(device[PARAM_DEVICE_ABILITY])
411
+ imou_device.set_device_ability(
412
+ _text_or_default(device[PARAM_DEVICE_ABILITY])
413
+ )
383
414
  if PARAM_DEVICE_VERSION in device:
384
415
  imou_device.set_device_version(device[PARAM_DEVICE_VERSION])
385
416
  if PARAM_PARENT_PRODUCT_ID in device:
@@ -392,8 +423,14 @@ class ImouDeviceManager:
392
423
  imou_device.set_is_multi(device[PARAM_MULTI_FLAG])
393
424
  if PARAM_ACCESS_TYPE in device:
394
425
  imou_device.set_access_type(device[PARAM_ACCESS_TYPE])
426
+ raw_source = device.get("source")
427
+ imou_device.set_source(
428
+ raw_source.strip() if isinstance(raw_source, str) else ""
429
+ )
395
430
  if PARAM_CHANNEL_LIST in device:
396
- channel_list = device[PARAM_CHANNEL_LIST]
431
+ channel_list = device[PARAM_CHANNEL_LIST] or []
432
+ if not isinstance(channel_list, list):
433
+ channel_list = []
397
434
  channels = []
398
435
  for channel in channel_list:
399
436
  channel_id = (
@@ -403,7 +440,9 @@ class ImouDeviceManager:
403
440
  )
404
441
  channel_name = channel[PARAM_CHANNEL_NAME]
405
442
  channel_status = channel[PARAM_CHANNEL_STATUS]
406
- channel_ability = channel.get(PARAM_CHANNEL_ABILITY, "unknown")
443
+ channel_ability = _text_or_default(
444
+ channel.get(PARAM_CHANNEL_ABILITY)
445
+ )
407
446
  channel = ImouChannel(
408
447
  channel_id, channel_name, channel_status, channel_ability
409
448
  )
@@ -469,8 +508,8 @@ class ImouDeviceManager:
469
508
  data = await self._imou_api_client.async_request_api(
470
509
  API_ENDPOINT_LIST_DEVICE_DETAILS, params
471
510
  )
472
- device_list = data.get(PARAM_DEVICE_LIST) or []
473
- if not device_list:
511
+ device_list = data.get(PARAM_DEVICE_LIST) if isinstance(data, dict) else None
512
+ if not isinstance(device_list, list) or not device_list:
474
513
  return []
475
514
  summaries: list[ImouDeviceSummary] = []
476
515
  for device in device_list:
@@ -673,7 +712,9 @@ class ImouDeviceManager:
673
712
  PARAM_DEVICE_LIST: [
674
713
  {
675
714
  PARAM_DEVICE_ID: device_id,
676
- PARAM_CHANNEL_ID: channel_id,
715
+ PARAM_CHANNEL_ID: int(channel_id)
716
+ if channel_id is not None
717
+ else channel_id,
677
718
  PARAM_PRODUCT_ID: product_id,
678
719
  PARAM_PROPERTIES: properties,
679
720
  }
@@ -815,13 +856,13 @@ class ImouDeviceManager:
815
856
  imou_device.product_id,
816
857
  )
817
858
  imou_device.set_device_ability_refs(
818
- device_detail.get(PARAM_ABILITY_REFS, "unknown")
859
+ _text_or_default(device_detail.get(PARAM_ABILITY_REFS))
819
860
  )
820
861
  channels_detail = device_detail.get(PARAM_CHANNELS)
821
862
  if channels_detail and imou_device.channels:
822
863
  channel_detail_map = {
823
- str(channel_detail.get(PARAM_CHANNEL_ID)): channel_detail.get(
824
- PARAM_ABILITY_REFS, "unknown"
864
+ str(channel_detail.get(PARAM_CHANNEL_ID)): _text_or_default(
865
+ channel_detail.get(PARAM_ABILITY_REFS)
825
866
  )
826
867
  for channel_detail in channels_detail
827
868
  if channel_detail.get(PARAM_CHANNEL_ID) is not None
@@ -20,7 +20,7 @@ _LOGGER = logging.getLogger(__name__)
20
20
  DEVICE_STATUS_SLEEP = "sleep"
21
21
 
22
22
  # Seconds to wait before retrying a control write on a sleeping device.
23
- DORMANT_WRITE_RETRY_WAIT_SECONDS = 10
23
+ DORMANT_WRITE_RETRY_WAIT_SECONDS = 5
24
24
 
25
25
  # Platform codes seen when a dormant device cannot accept a write yet.
26
26
  DORMANT_WRITE_RETRY_ERROR_CODES = frozenset(