python-mobius 0.10.0__py3-none-any.whl → 0.10.1__py3-none-any.whl

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.
mobius/__init__.py CHANGED
@@ -87,7 +87,7 @@ from .mob import (
87
87
  MAX_PUMP_PRIMITIVE_SIZE,
88
88
  )
89
89
 
90
- __version__ = "0.10.0"
90
+ __version__ = "0.10.1"
91
91
 
92
92
  __all__ = [
93
93
  "__version__",
mobius/device.py CHANGED
@@ -169,26 +169,18 @@ def _schedule_checksum_attr(which: int) -> C2Attribute:
169
169
  return C2Attribute.Schedule1Checksum if which == 1 else C2Attribute.Schedule2Checksum
170
170
 
171
171
 
172
- def _configuration_requests(
172
+ def _configuration_checksum_requests(
173
173
  configuration: tuple, cache: Optional[ConfigurationCache], supported_attribute_ids: set,
174
- ) -> tuple[list, set]:
175
- """
176
- Poll requests for each (data attribute, checksum attribute) of
177
- `configuration`: the checksum alone when `cache` holds the data, else
178
- the data (plus the checksum, to store with it). Returns (requests,
179
- data attributes requested).
180
- """
181
- requests, data_read = [], set()
182
- for data_attr, checksum_attr in configuration:
183
- checksum_usable = cache is not None and checksum_attr in supported_attribute_ids
184
- if checksum_usable and data_attr in cache.entries:
185
- requests.append((checksum_attr, 0, 1))
186
- continue
187
- requests.append((data_attr, 0, ALL_ELEMENTS))
188
- data_read.add(data_attr)
189
- if checksum_usable:
190
- requests.append((checksum_attr, 0, 1))
191
- return requests, data_read
174
+ ) -> list:
175
+ """The checksum request of each (data attribute, checksum attribute) of
176
+ `configuration` that the cache can use. The data itself is never part
177
+ of the poll batch (see _read_configuration())."""
178
+ if cache is None:
179
+ return []
180
+ return [
181
+ (checksum_attr, 0, 1) for _data_attr, checksum_attr in configuration
182
+ if checksum_attr in supported_attribute_ids
183
+ ]
192
184
 
193
185
 
194
186
  def _apply_static_cache(cache: ConfigurationCache, by_attr_id: dict, static_read: bool) -> None:
@@ -2506,10 +2498,12 @@ class MobiusDevice:
2506
2498
  get_device_info(), get_metadata_batch() and
2507
2499
  get_light_poll_batch() or get_pump_schedule()/get_pump_telemetry().
2508
2500
 
2509
- `cache` (one per device, kept by the caller): ConfiguredScenes and
2510
- the schedule are then read only when their checksum changed since
2511
- the previous poll (see ConfigurationCache); a changed checksum
2512
- costs a second, smaller request. With its static_refresh_interval
2501
+ The schedule and ConfiguredScenes are read in requests of their
2502
+ own after the batch, as the app does: combined with the rest, a
2503
+ light's reply is too large to be relayed. `cache` (one per device,
2504
+ kept by the caller): they are then read only when their checksum,
2505
+ part of the batch, changed since the previous poll (see
2506
+ ConfigurationCache). With its static_refresh_interval
2513
2507
  set, the STATIC_POLL_ATTRIBUTES are also read only that often.
2514
2508
  Used by the batched path only.
2515
2509
  """
@@ -2537,7 +2531,7 @@ class MobiusDevice:
2537
2531
  (schedule_attr, _schedule_checksum_attr(which)),
2538
2532
  (C2Attribute.ConfiguredScenes, C2Attribute.ConfiguredScenesChecksum),
2539
2533
  )
2540
- configuration_requests, data_read = _configuration_requests(configuration, cache, supported_attribute_ids)
2534
+ configuration_requests = _configuration_checksum_requests(configuration, cache, supported_attribute_ids)
2541
2535
  if cache is not None:
2542
2536
  configuration_requests.append((C2Attribute.SupportedAttributesCRC, 0, 1))
2543
2537
  requests = _DEVICE_INFO_REQUESTS + _METADATA_REQUESTS + configuration_requests + [
@@ -2558,9 +2552,7 @@ class MobiusDevice:
2558
2552
  )
2559
2553
  if attribute_table_changed:
2560
2554
  cache.invalidate_static()
2561
- data_read |= await self._apply_configuration_cache(
2562
- by_attr_id, cache, configuration, data_read, supported_attribute_ids,
2563
- )
2555
+ data_read = await self._read_configuration(by_attr_id, cache, configuration, supported_attribute_ids)
2564
2556
 
2565
2557
  def first(attr_id, index=0):
2566
2558
  return _first_value(by_attr_id, attr_id, index)
@@ -2621,38 +2613,44 @@ class MobiusDevice:
2621
2613
  static_read=static_read,
2622
2614
  )
2623
2615
 
2624
- async def _apply_configuration_cache(
2625
- self, by_attr_id: dict, cache: ConfigurationCache,
2626
- configuration: tuple, data_read: set, supported_attribute_ids: set,
2616
+ async def _read_configuration(
2617
+ self, by_attr_id: dict, cache: Optional[ConfigurationCache],
2618
+ configuration: tuple, supported_attribute_ids: set,
2627
2619
  ) -> set:
2628
2620
  """
2629
- After the poll batch: stores data read with its checksum, fills in
2630
- cached data whose checksum is unchanged, and reads the rest in a
2631
- second batch. Returns the attributes read by that second batch.
2621
+ Fills each data attribute of `configuration` (the schedule, the
2622
+ scenes) into `by_attr_id`: from `cache` when the checksum in the
2623
+ poll batch matches the cached one, else with a request of its own
2624
+ (plus its checksum, stored in the cache with it). Returns the
2625
+ attributes read.
2626
+
2627
+ Each gets its own request, as in the app: a light's schedule or
2628
+ scenes alone are close to the largest reply a relay carries, and
2629
+ together with the rest of the poll a relayed reply is too large
2630
+ and never arrives.
2632
2631
  """
2633
- stale = []
2632
+ read = set()
2634
2633
  for data_attr, checksum_attr in configuration:
2635
- if data_attr not in supported_attribute_ids or checksum_attr not in supported_attribute_ids:
2636
- continue
2637
- reported = _unpack(_first_value(by_attr_id, checksum_attr), "<H")
2638
- if data_attr in data_read:
2639
- _store_configuration(cache, data_attr, reported, by_attr_id)
2634
+ if data_attr not in supported_attribute_ids:
2640
2635
  continue
2641
- cached = cache.entries.get(data_attr)
2642
- if cached is not None and reported is not None and reported == cached[0]:
2643
- by_attr_id[data_attr] = cached[1]
2644
- else:
2645
- stale.append((data_attr, checksum_attr))
2646
- if not stale:
2647
- return set()
2648
- second = await self._read_supported_batch(
2649
- [r for data_attr, checksum_attr in stale for r in ((data_attr, 0, ALL_ELEMENTS), (checksum_attr, 0, 1))],
2650
- supported_attribute_ids,
2651
- )
2652
- for data_attr, checksum_attr in stale:
2653
- by_attr_id[data_attr] = second.get(data_attr, [])
2654
- _store_configuration(cache, data_attr, _unpack(_first_value(second, checksum_attr), "<H"), second)
2655
- return {data_attr for data_attr, _checksum_attr in stale}
2636
+ checksum_usable = cache is not None and checksum_attr in supported_attribute_ids
2637
+ if checksum_usable:
2638
+ reported = _unpack(_first_value(by_attr_id, checksum_attr), "<H")
2639
+ cached = cache.entries.get(data_attr)
2640
+ if cached is not None and reported is not None and reported == cached[0]:
2641
+ by_attr_id[data_attr] = cached[1]
2642
+ continue
2643
+ requests = [(data_attr, 0, ALL_ELEMENTS)]
2644
+ if checksum_usable:
2645
+ requests.append((checksum_attr, 0, 1))
2646
+ response = await self._read_supported_batch(requests, supported_attribute_ids)
2647
+ by_attr_id[data_attr] = response.get(int(data_attr), [])
2648
+ if checksum_usable:
2649
+ _store_configuration(
2650
+ cache, data_attr, _unpack(_first_value(response, checksum_attr), "<H"), response,
2651
+ )
2652
+ read.add(data_attr)
2653
+ return read
2656
2654
 
2657
2655
  async def _get_full_poll_via_individual_reads(
2658
2656
  self, primitive: PrimitiveType, model: Optional[Model],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-mobius
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: Reverse-engineered Python client for the Mobius BLE protocol (EcoTech Marine VorTech/Radion, AquaIllumination, Neptune Systems, NYOS)
5
5
  Project-URL: Homepage, https://code.r3pek.org/r3pek/python-mobius
6
6
  Project-URL: Documentation, https://code.r3pek.org/r3pek/python-mobius/src/branch/main/documentation
@@ -1,10 +1,10 @@
1
- mobius/__init__.py,sha256=4KhKL5RgHdYk77_OmINsr2YiWa1N1fTpDL4EI6J_3EY,8555
1
+ mobius/__init__.py,sha256=eObxukBi0TREh8e0TD74L5CzOxSma-dPaj9YAB_8QAc,8555
2
2
  mobius/checksums.py,sha256=PB9RqvaZu9AqfT6tU6NI2qbbZXrqaHUnow3Qi_6UFHs,5191
3
3
  mobius/cli.py,sha256=tyft0SzbuLgbmzps-Ym1hCzcr6A9D5MsALkg6o4ynBs,57876
4
4
  mobius/coap.py,sha256=-XV3kI4q-JoL8r0oLFNnHAdZAc_yUP-aICagKh-qbf4,4862
5
5
  mobius/constants.py,sha256=pcG9Su_b81pmMA_GxR41lZz9UM9BjtV0T6nuslMICko,41138
6
6
  mobius/crc.py,sha256=LOCHZe3a1UnR5thdpZ4S4SFP8BdmoMEnhDNiNMd0iJI,2508
7
- mobius/device.py,sha256=2WPsm-aJJdIDeypo_MQ6rpgI1NTljcOUC4lt04eISbQ,131678
7
+ mobius/device.py,sha256=tY4vSTiqHExwgfxQA2Z8FOGWS5RMUn1Zq6HAp0mdk-E,131600
8
8
  mobius/device_status.py,sha256=XclYijAknrgT8SdSW4XvyBemWHUQqw6UPE4tmwq6Yug,15658
9
9
  mobius/discovery.py,sha256=poNeXGekB44cpHOFbGyps9d4mwW_hJptmJODwSMTUSg,7176
10
10
  mobius/dump.py,sha256=eQBYoi8J6CxRd2ojgWK5QoB8z416oywLRTBnnh0pLwo,9253
@@ -19,8 +19,8 @@ mobius/relay.py,sha256=trGkWQSarwURF05gXHeb5jTJ9UvWbQGu8NarEP6sRqE,10107
19
19
  mobius/scenes.py,sha256=VLfDdTKSv3qTsBt2bJGg8iPtUkfNEmNgu0TTtYT6jJE,4274
20
20
  mobius/schedule.py,sha256=si9uJdYOj5vh6owuxxMyMyZRY0-tAmCPt3s6ROAeRww,13243
21
21
  mobius/timezone.py,sha256=Q7oPKtCdEYcEHXLx4lt-VPq6KH-MNgQwVnDtIXJV-kQ,2267
22
- python_mobius-0.10.0.dist-info/METADATA,sha256=fGt7VhAS5SQAA7lmw5E90nBAnbQMscCgT5WHOB6fLtg,5829
23
- python_mobius-0.10.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
24
- python_mobius-0.10.0.dist-info/entry_points.txt,sha256=Q2hlcek-bWm70zvd12v32essflPgC2su-dKDHAqbPoE,48
25
- python_mobius-0.10.0.dist-info/licenses/LICENSE,sha256=7a72Msu2Q-TnoiFxemxEGkwafJGObk1W3rw9hzmyM_Y,17984
26
- python_mobius-0.10.0.dist-info/RECORD,,
22
+ python_mobius-0.10.1.dist-info/METADATA,sha256=B1lQHhsAB0OH_ViOqQChhl4_zJ1o496C73dFM8Cc8t4,5829
23
+ python_mobius-0.10.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
24
+ python_mobius-0.10.1.dist-info/entry_points.txt,sha256=Q2hlcek-bWm70zvd12v32essflPgC2su-dKDHAqbPoE,48
25
+ python_mobius-0.10.1.dist-info/licenses/LICENSE,sha256=7a72Msu2Q-TnoiFxemxEGkwafJGObk1W3rw9hzmyM_Y,17984
26
+ python_mobius-0.10.1.dist-info/RECORD,,