python-swidget 1.4.8__tar.gz → 1.4.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-swidget
3
- Version: 1.4.8
3
+ Version: 1.4.9
4
4
  Summary: Python API for Swidget smart devices
5
5
  Home-page: https://github.com/swidget/python-swidget
6
6
  License: GPL-3.0-or-later
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-swidget"
3
- version = "1.4.8"
3
+ version = "1.4.9"
4
4
  description = "Python API for Swidget smart devices"
5
5
  license = "GPL-3.0-or-later"
6
6
  authors = ["Swidget"]
@@ -361,10 +361,30 @@ class SwidgetDevice:
361
361
  self.model = summary["model"]
362
362
  self.mac_address = summary["mac"]
363
363
  self.version = summary["version"]
364
- self.assemblies = {
364
+ new_assemblies = {
365
365
  "host": SwidgetAssembly(summary["host"]),
366
366
  "insert": SwidgetAssembly(summary["insert"]),
367
367
  }
368
+ # Carry already-populated function state forward. Rebuilding
369
+ # assemblies wholesale resets every component's ``functions`` to
370
+ # ``None`` placeholders until the next ``state`` message lands —
371
+ # subscribers that read state in between (e.g. an HA coordinator
372
+ # firing on the summary callback) would briefly see "unknown"
373
+ # and flicker the UI.
374
+ for assembly_key, new_assembly in new_assemblies.items():
375
+ old_assembly = self.assemblies.get(assembly_key)
376
+ if old_assembly is None:
377
+ continue
378
+ for component_id, new_component in new_assembly.components.items():
379
+ old_component = old_assembly.components.get(component_id)
380
+ if old_component is None:
381
+ continue
382
+ for fn_name in new_component.functions:
383
+ if fn_name in old_component.functions:
384
+ new_component.functions[fn_name] = old_component.functions[
385
+ fn_name
386
+ ]
387
+ self.assemblies = new_assemblies
368
388
  self.device_type = DeviceType(self.assemblies["host"].type)
369
389
  self.insert_type = InsertType(self.assemblies["insert"].type)
370
390
  self.id = self.assemblies["host"].id
File without changes