python-mobius 0.7.0__tar.gz → 0.7.2__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 (79) hide show
  1. {python_mobius-0.7.0 → python_mobius-0.7.2}/CHANGELOG.md +17 -0
  2. {python_mobius-0.7.0 → python_mobius-0.7.2}/PKG-INFO +14 -3
  3. {python_mobius-0.7.0 → python_mobius-0.7.2}/README.md +13 -2
  4. {python_mobius-0.7.0 → python_mobius-0.7.2}/pyproject.toml +1 -1
  5. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/__init__.py +4 -1
  6. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/cli.py +46 -0
  7. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/constants.py +1 -0
  8. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/device.py +69 -13
  9. python_mobius-0.7.2/src/mobius/scenes.py +97 -0
  10. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_full_poll_batch.py +71 -1
  11. python_mobius-0.7.2/tests/test_scenes.py +241 -0
  12. {python_mobius-0.7.0 → python_mobius-0.7.2}/.forgejo/scripts/extract_changelog_section.py +0 -0
  13. {python_mobius-0.7.0 → python_mobius-0.7.2}/.forgejo/workflows/release.yml +0 -0
  14. {python_mobius-0.7.0 → python_mobius-0.7.2}/.gitignore +0 -0
  15. {python_mobius-0.7.0 → python_mobius-0.7.2}/LICENSE +0 -0
  16. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/00-overview.md +0 -0
  17. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/01-ble-transport.md +0 -0
  18. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/02-framing-and-crc.md +0 -0
  19. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/03-attributes-and-opcodes.md +0 -0
  20. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/04-device-identity.md +0 -0
  21. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/05-scenes.md +0 -0
  22. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/06-light-schedule.md +0 -0
  23. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/07-pump-schedule.md +0 -0
  24. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/08-manufacturer-data.md +0 -0
  25. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/09-thread-coap-relay.md +0 -0
  26. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/10-known-gaps-and-open-questions.md +0 -0
  27. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/11-device-status-attributes.md +0 -0
  28. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/12-device-identity-and-address-stability.md +0 -0
  29. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/13-attribute-dump.md +0 -0
  30. {python_mobius-0.7.0 → python_mobius-0.7.2}/documentation/14-batched-attribute-reads.md +0 -0
  31. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/coap.py +0 -0
  32. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/crc.py +0 -0
  33. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/device_status.py +0 -0
  34. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/discovery.py +0 -0
  35. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/dump.py +0 -0
  36. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/frame.py +0 -0
  37. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/manufacturer.py +0 -0
  38. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/mesh_address.py +0 -0
  39. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/modifiers.py +0 -0
  40. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/power.py +0 -0
  41. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/pump_status.py +0 -0
  42. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/relay.py +0 -0
  43. {python_mobius-0.7.0 → python_mobius-0.7.2}/src/mobius/schedule.py +0 -0
  44. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_attributes_batch.py +0 -0
  45. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_coap.py +0 -0
  46. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_coap_indication_handling.py +0 -0
  47. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_connection_cleanup.py +0 -0
  48. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_device_control.py +0 -0
  49. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_device_status.py +0 -0
  50. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_device_summary.py +0 -0
  51. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_device_time.py +0 -0
  52. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_discovery_company_ids.py +0 -0
  53. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_dump.py +0 -0
  54. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_firmware_versions.py +0 -0
  55. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_frame.py +0 -0
  56. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_frame_sniffer.py +0 -0
  57. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_hyperdrive_device.py +0 -0
  58. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_insolation_detection.py +0 -0
  59. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_light_intensity_branching.py +0 -0
  60. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_light_poll_batch.py +0 -0
  61. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_light_schedule.py +0 -0
  62. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_manufacturer.py +0 -0
  63. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_manufacturer_lookup.py +0 -0
  64. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_mesh_address.py +0 -0
  65. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_mesh_discovery.py +0 -0
  66. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_mesh_discovery_direct_connect.py +0 -0
  67. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_metadata_batch.py +0 -0
  68. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_modifiers.py +0 -0
  69. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_networked_thread_devices.py +0 -0
  70. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_new_diagnostic_attributes.py +0 -0
  71. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_power.py +0 -0
  72. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_pump_schedule.py +0 -0
  73. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_pump_status.py +0 -0
  74. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_pump_telemetry.py +0 -0
  75. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_relay.py +0 -0
  76. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_schedule_intensity_scalar.py +0 -0
  77. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_serial_decoding.py +0 -0
  78. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_serial_identity.py +0 -0
  79. {python_mobius-0.7.0 → python_mobius-0.7.2}/tests/test_supported_attributes.py +0 -0
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2
4
+
5
+ - get_full_poll_batch() now includes scene data (ConfiguredScenes/
6
+ CurrentScene) in the same combined request, falling back to
7
+ get_configured_scenes()/get_current_scene() if the batch itself
8
+ fails.
9
+ - start_scene()/start_feed_mode() now broadcast to the whole mesh by
10
+ default (one write instead of one per device) -- pass
11
+ broadcast=False for the old, single-device-only behavior.
12
+
13
+ ## 0.7.1
14
+
15
+ - Added scene support: get_configured_scenes(), get_current_scene(),
16
+ start_scene(). Fixed get_current_scene() crashing on a custom
17
+ (non-preset) scene, and start_scene()'s duration being in seconds,
18
+ not minutes as previously labeled.
19
+
3
20
  ## 0.7.0
4
21
 
5
22
  - Added get_full_poll_batch() -- one round-trip for device identity +
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-mobius
3
- Version: 0.7.0
3
+ Version: 0.7.2
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
@@ -108,14 +108,25 @@ mobius-scan --adapter hci0
108
108
  - **Read light schedules**: per-channel intensity at any given time,
109
109
  replicating the app's own client-side interpolation (there's no "current
110
110
  intensity" attribute — lights only expose the programmed curve).
111
+ - **Read every configured scene** (`get_configured_scenes()`) — name,
112
+ timeout, and its own light/pump payload, at whatever slot it lives in,
113
+ plus the currently active one (`get_current_scene()`).
114
+ - **Control scenes**: start feed mode, resume the normal schedule, or any
115
+ other configured scene — one write, broadcast to the whole mesh by
116
+ default (`broadcast=True`). Uses the same mesh-propagation mechanism
117
+ confirmed against real hardware for the clock-sync write below;
118
+ applying it to scene activation specifically hasn't been
119
+ independently verified the same way yet.
120
+ - **Fetch everything one device poll needs in a single round-trip**
121
+ (`get_full_poll_batch()`) — identity, metadata, light/pump state, and
122
+ scene data together, confirmed 2-2.6x faster on real hardware than
123
+ reading each piece separately.
111
124
  - **Read device-specific settings**: VorTech's own "Local Control"/"Led
112
125
  Auto Dim" and Radion's own "Max Fan Speed"/"Fan Shutdown"
113
126
  (`get_advanced_features()`), plus Vectra and NYOS Quantum settings
114
127
  (`get_vectra_info()`/`get_coffee_info()` — no real hardware to verify
115
128
  either against, see
116
129
  [known gaps](./documentation/10-known-gaps-and-open-questions.md)).
117
- - **Control scenes**: start feed mode, resume the normal schedule, or any
118
- other configured scene.
119
130
  - **Fix a desynced device clock** (`set_time_to_now()`) — a WRITE.
120
131
  Writing to one device appears to propagate to the rest of its Thread
121
132
  mesh too, confirmed against real hardware — see
@@ -76,14 +76,25 @@ mobius-scan --adapter hci0
76
76
  - **Read light schedules**: per-channel intensity at any given time,
77
77
  replicating the app's own client-side interpolation (there's no "current
78
78
  intensity" attribute — lights only expose the programmed curve).
79
+ - **Read every configured scene** (`get_configured_scenes()`) — name,
80
+ timeout, and its own light/pump payload, at whatever slot it lives in,
81
+ plus the currently active one (`get_current_scene()`).
82
+ - **Control scenes**: start feed mode, resume the normal schedule, or any
83
+ other configured scene — one write, broadcast to the whole mesh by
84
+ default (`broadcast=True`). Uses the same mesh-propagation mechanism
85
+ confirmed against real hardware for the clock-sync write below;
86
+ applying it to scene activation specifically hasn't been
87
+ independently verified the same way yet.
88
+ - **Fetch everything one device poll needs in a single round-trip**
89
+ (`get_full_poll_batch()`) — identity, metadata, light/pump state, and
90
+ scene data together, confirmed 2-2.6x faster on real hardware than
91
+ reading each piece separately.
79
92
  - **Read device-specific settings**: VorTech's own "Local Control"/"Led
80
93
  Auto Dim" and Radion's own "Max Fan Speed"/"Fan Shutdown"
81
94
  (`get_advanced_features()`), plus Vectra and NYOS Quantum settings
82
95
  (`get_vectra_info()`/`get_coffee_info()` — no real hardware to verify
83
96
  either against, see
84
97
  [known gaps](./documentation/10-known-gaps-and-open-questions.md)).
85
- - **Control scenes**: start feed mode, resume the normal schedule, or any
86
- other configured scene.
87
98
  - **Fix a desynced device clock** (`set_time_to_now()`) — a WRITE.
88
99
  Writing to one device appears to propagate to the rest of its Thread
89
100
  mesh too, confirmed against real hardware — see
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-mobius"
7
- version = "0.7.0"
7
+ version = "0.7.2"
8
8
  description = "Reverse-engineered Python client for the Mobius BLE protocol (EcoTech Marine VorTech/Radion, AquaIllumination, Neptune Systems, NYOS)"
9
9
  readme = "README.md"
10
10
  license = { text = "GPL-2.0-only" }
@@ -35,6 +35,7 @@ from .schedule import (
35
35
  LightPrimitive, SchedulePoint, interpolate_light_schedule,
36
36
  PumpPrimitiveValue, PumpSchedulePoint, get_active_pump_block,
37
37
  )
38
+ from .scenes import Scene, ActiveScene, decode_configured_scenes, decode_active_scene
38
39
  from .manufacturer import MOBIUS_COMPANY_ID_ECOTECH, MOBIUS_COMPANY_ID_AQUAILLUMINATION, MOBIUS_COMPANY_IDS, MobiusAdvertisement, parse_manufacturer_data
39
40
  from .modifiers import (
40
41
  AcclimationInfo, is_night_segment,
@@ -71,7 +72,7 @@ from .dump import (
71
72
  enrich_attribute_dump,
72
73
  )
73
74
 
74
- __version__ = "0.7.0"
75
+ __version__ = "0.7.2"
75
76
 
76
77
  __all__ = [
77
78
  "__version__",
@@ -98,6 +99,8 @@ __all__ = [
98
99
  # schedule
99
100
  "LightPrimitive", "SchedulePoint", "interpolate_light_schedule",
100
101
  "PumpPrimitiveValue", "PumpSchedulePoint", "get_active_pump_block",
102
+ # scenes
103
+ "Scene", "ActiveScene", "decode_configured_scenes", "decode_active_scene",
101
104
  # manufacturer
102
105
  "MOBIUS_COMPANY_ID_ECOTECH", "MOBIUS_COMPANY_ID_AQUAILLUMINATION", "MOBIUS_COMPANY_IDS", "MobiusAdvertisement", "parse_manufacturer_data",
103
106
  # modifiers
@@ -18,6 +18,7 @@ from .device import MobiusDevice
18
18
  from .relay import RelayedMobiusDevice
19
19
  from .device_status import MeshPeer
20
20
  from .mesh_address import extract_short_address
21
+ from .constants import PrimitiveType, SceneID
21
22
  from .discovery import (
22
23
  scan_for_mobius_devices_with_info, group_by_pan_id, dedupe_by_serial,
23
24
  find_device_by_serial, discover_mesh_peers_via_direct_connect, discover_tank,
@@ -99,6 +100,37 @@ async def _dump_schedule(device: MobiusDevice, support: str) -> None:
99
100
  print(f" (schedule dumping not supported for support={support!r})")
100
101
 
101
102
 
103
+ async def _dump_scenes(device: MobiusDevice, primitive: PrimitiveType | None) -> None:
104
+ """Prints every configured scene, at whatever slot it lives in,
105
+ including empty/unused slots. The currently active scene is
106
+ already shown by the summary above (info["current_scene"])."""
107
+ print(" --- configured scenes ---")
108
+ scenes = await device.get_configured_scenes(primitive=primitive)
109
+ if not scenes:
110
+ print(" (none)")
111
+ return
112
+ for scene in scenes:
113
+ if scene.scene_type == SceneID.EmptyScene and not scene.name:
114
+ print(f" [{scene.index}] (empty)")
115
+ continue
116
+ type_label = scene.scene_type.name if scene.scene_type else "custom"
117
+ if scene.light is not None:
118
+ payload = ", ".join(
119
+ f"{vid.name}={val}"
120
+ for vid, val in sorted(scene.light.channels.items(), key=lambda x: x[0].name)
121
+ )
122
+ elif scene.pump is not None:
123
+ params = ", ".join(
124
+ f"{p.name}={v.hex() if isinstance(v, bytes) else (v.name if hasattr(v, 'name') else v)}"
125
+ for p, v in scene.pump.params.items()
126
+ )
127
+ payload = f"mode={scene.pump.mode.name} {params}"
128
+ else:
129
+ payload = "(no primitive data decoded)"
130
+ print(f" [{scene.index}] id={scene.id} ({type_label}) name={scene.name!r} "
131
+ f"timeout={scene.timeout}s: {payload}")
132
+
133
+
102
134
  async def _debug_mesh_discovery(device) -> list:
103
135
  """
104
136
  Verbose, step-by-step version of discover_mesh_peers_auto() for CLI
@@ -273,6 +305,10 @@ async def _run(args) -> None:
273
305
  print(f" {k}: {v}")
274
306
  if args.dump_schedule:
275
307
  await _dump_schedule(mdevice, summary.get("support", ""))
308
+ if args.dump_scenes:
309
+ primitive_name = summary.get("primitive_type")
310
+ primitive = PrimitiveType[primitive_name] if primitive_name else None
311
+ await _dump_scenes(mdevice, primitive)
276
312
 
277
313
  relayed = None # set below only if --relay-target resolves successfully
278
314
  if args.dump_mesh_peers or args.relay_target:
@@ -620,6 +656,10 @@ async def _run(args) -> None:
620
656
  print(f" {k}: {v}")
621
657
  if args.dump_schedule:
622
658
  await _dump_schedule(mdevice, summary.get("support", ""))
659
+ if args.dump_scenes:
660
+ primitive_name = summary.get("primitive_type")
661
+ primitive = PrimitiveType[primitive_name] if primitive_name else None
662
+ await _dump_scenes(mdevice, primitive)
623
663
  except Exception as e:
624
664
  print(" failed to connect/read:", e)
625
665
 
@@ -667,6 +707,12 @@ def main() -> None:
667
707
  "hardware -- see LunarPhaseInfo's own docstring) -- compare against "
668
708
  "\"current_intensities\"/\"light_diagnostics\" in the summary output "
669
709
  "above for this library's own calculated value.")
710
+ parser.add_argument("--dump-scenes", action="store_true",
711
+ help="Also print every configured scene on each connected device -- "
712
+ "id, name, timeout, and its own light/pump payload -- at whatever "
713
+ "slot it lives in, including empty/unused slots. The currently "
714
+ "active scene is already shown by the summary above "
715
+ "(\"current_scene\").")
670
716
  parser.add_argument("--dump-mesh-peers", action="store_true",
671
717
  help="Only usable with --by-serial. After connecting, calls "
672
718
  "discover_mesh_peers_auto() on it and prints every other device "
@@ -436,6 +436,7 @@ class C2Attribute(IntEnum):
436
436
  SceneTimeout = 402
437
437
  SceneTimer = 403
438
438
  # Scene diagnostics -- named, not yet exposed by a get_*() method.
439
+ LiveDemoSceneNero = 404
439
440
  LiveDemoTimeout = 405
440
441
  LiveDemoTimer = 406
441
442
  LiveDemoScene = 407
@@ -12,7 +12,7 @@ from __future__ import annotations
12
12
  import asyncio
13
13
  import struct
14
14
  import time
15
- from dataclasses import dataclass
15
+ from dataclasses import dataclass, field
16
16
  from typing import Optional, Callable
17
17
 
18
18
  from bleak import BleakClient, BleakScanner
@@ -43,6 +43,7 @@ from .schedule import (
43
43
  SchedulePoint, interpolate_light_schedule,
44
44
  PumpSchedulePoint, get_active_pump_block,
45
45
  )
46
+ from .scenes import Scene, ActiveScene, decode_configured_scenes, decode_active_scene
46
47
  from .modifiers import (
47
48
  AcclimationInfo, is_night_segment, lunar_percent_reduction,
48
49
  )
@@ -189,6 +190,11 @@ class FullPollResult:
189
190
  caller needing a separate get_pump_schedule() call just to also
190
191
  get schedule_point_count alongside everything else here.
191
192
 
193
+ configured_scenes/current_scene -- everything get_configured_scenes()/
194
+ get_current_scene() themselves cover, for whichever device types
195
+ support scenes at all (an empty list / None if not, matching those
196
+ methods' own behavior exactly).
197
+
192
198
  used_batch mirrors every other *Result/Snapshot's own field of the
193
199
  same name and purpose.
194
200
  """
@@ -197,6 +203,8 @@ class FullPollResult:
197
203
  light_poll: Optional[LightPollResult]
198
204
  pump_telemetry: Optional[dict]
199
205
  pump_schedule_points: Optional[list[PumpSchedulePoint]] = None
206
+ configured_scenes: list[Scene] = field(default_factory=list)
207
+ current_scene: Optional[ActiveScene] = None
200
208
  used_batch: bool = True
201
209
 
202
210
 
@@ -1276,22 +1284,53 @@ class MobiusDevice:
1276
1284
 
1277
1285
  # ---- scenes -----------------------------------------------------------
1278
1286
 
1279
- async def start_scene(self, scene_id: SceneID, duration_minutes: int = 0) -> None:
1280
- """duration_minutes=0 lets the device use the scene's own configured duration."""
1281
- value = struct.pack("<HH", int(scene_id), duration_minutes)
1282
- await self.set_attribute(C2Attribute.CurrentScene, value)
1287
+ async def start_scene(self, scene_id: int, duration_seconds: int = 0, broadcast: bool = True) -> None:
1288
+ """
1289
+ Activates a scene by id -- one of the ten SceneID presets, or a
1290
+ user-created scene's own device-assigned id (see get_configured_scenes()).
1291
+ duration_seconds=0 lets the device use the scene's own configured
1292
+ timeout instead.
1293
+
1294
+ broadcast=True (the default) sets the frame's own reserved-byte
1295
+ "group" field to 1 (see make_reserved()), which propagates this
1296
+ write to the rest of the mesh from a single write to just this
1297
+ device -- confirmed against real hardware for set_time_to_now()'s
1298
+ own Epoch write; the same group=1 mechanism is used here, though
1299
+ this hasn't been independently confirmed against real hardware
1300
+ for CurrentScene specifically. group=1 only ever reaches devices
1301
+ on THIS SAME mesh (a Thread network is its own isolated network,
1302
+ identified by its own pan_id) -- it cannot reach a different
1303
+ tank's own, separate mesh, even one within physical radio range.
1304
+ Pass broadcast=False to write to only this one device instead.
1305
+ """
1306
+ value = struct.pack("<HH", int(scene_id), duration_seconds)
1307
+ reserved = make_reserved(group=1) if broadcast else b"\x00\x00"
1308
+ await self.set_attribute(C2Attribute.CurrentScene, value, reserved=reserved)
1283
1309
 
1284
- async def start_feed_mode(self, duration_minutes: int = 0) -> None:
1285
- await self.start_scene(SceneID.FeedMode, duration_minutes)
1310
+ async def start_feed_mode(self, duration_seconds: int = 0, broadcast: bool = True) -> None:
1311
+ await self.start_scene(SceneID.FeedMode, duration_seconds, broadcast=broadcast)
1286
1312
 
1287
1313
  async def resume_schedule(self) -> None:
1288
1314
  """Cancel whatever scene is running and go back to the normal schedule."""
1289
1315
  await self.set_attribute(C2Attribute.OperationState, bytes([OperationState.Schedule]))
1290
1316
 
1291
- async def get_current_scene(self) -> tuple[SceneID, int]:
1292
- raw = await self.get_attribute(C2Attribute.CurrentScene)
1293
- scene_id, duration = struct.unpack("<HH", raw[0])
1294
- return SceneID(scene_id), duration
1317
+ async def get_current_scene(self) -> Optional[ActiveScene]:
1318
+ try:
1319
+ raw = await self.get_attribute(C2Attribute.CurrentScene)
1320
+ except Exception:
1321
+ return None
1322
+ return decode_active_scene(raw[0]) if raw else None
1323
+
1324
+ async def get_configured_scenes(self, primitive: Optional[PrimitiveType] = None) -> list[Scene]:
1325
+ """
1326
+ Every configured scene, at whatever slots this device actually
1327
+ has one in -- including slots holding a genuinely empty/unused
1328
+ scene. Pass primitive so each scene's own light/pump payload
1329
+ can be decoded; omit it (or leave as None) to get every other
1330
+ field with light/pump both left None.
1331
+ """
1332
+ raw = await self.get_attribute(C2Attribute.ConfiguredScenes, index=0, count=0xFFFF)
1333
+ return decode_configured_scenes(raw, primitive)
1295
1334
 
1296
1335
  async def get_operation_state(self) -> OperationState:
1297
1336
  raw = await self.get_attribute(C2Attribute.OperationState)
@@ -2931,6 +2970,8 @@ class MobiusDevice:
2931
2970
  info["firmware_versions"] = await self.get_firmware_versions(model)
2932
2971
  info["hardware_info"] = await self.get_hardware_info()
2933
2972
  info["device_time"] = await self.get_device_time_info()
2973
+ current_scene = await self.get_current_scene()
2974
+ info["current_scene"] = current_scene
2934
2975
 
2935
2976
  return info
2936
2977
 
@@ -3634,6 +3675,8 @@ class MobiusDevice:
3634
3675
  (C2Attribute.FirmwareVersion, 0, 0xFFFF),
3635
3676
  (C2Attribute.HardwareRevision, 0, 0xFFFF),
3636
3677
  (schedule_attr, 0, 0xFFFF),
3678
+ (C2Attribute.ConfiguredScenes, 0, 0xFFFF),
3679
+ (C2Attribute.CurrentScene, 0, 1),
3637
3680
  ]
3638
3681
  if primitive == PrimitiveType.VisualV1:
3639
3682
  intensity_attr = C2Attribute.Schedule1Intensity if which == 1 else C2Attribute.Schedule2Intensity
@@ -3705,10 +3748,16 @@ class MobiusDevice:
3705
3748
  [motor_power_raw] if motor_power_raw else [], flow_range, model, primitive,
3706
3749
  )
3707
3750
 
3751
+ configured_scenes = decode_configured_scenes(_values_for(C2Attribute.ConfiguredScenes), primitive)
3752
+ current_scene_raw = _first_value(C2Attribute.CurrentScene)
3753
+ current_scene = decode_active_scene(current_scene_raw) if current_scene_raw else None
3754
+
3708
3755
  return FullPollResult(
3709
3756
  device_info=device_info, metadata=metadata,
3710
3757
  light_poll=light_poll, pump_telemetry=pump_telemetry,
3711
- pump_schedule_points=pump_schedule_points, used_batch=True,
3758
+ pump_schedule_points=pump_schedule_points,
3759
+ configured_scenes=configured_scenes, current_scene=current_scene,
3760
+ used_batch=True,
3712
3761
  )
3713
3762
 
3714
3763
  async def _get_full_poll_via_individual_reads(
@@ -3731,10 +3780,17 @@ class MobiusDevice:
3731
3780
  else:
3732
3781
  pump_schedule_points = await self.get_pump_schedule(which=which)
3733
3782
  pump_telemetry = await self.get_pump_telemetry(model=model, primitive=primitive)
3783
+ try:
3784
+ configured_scenes = await self.get_configured_scenes(primitive=primitive)
3785
+ except Exception:
3786
+ configured_scenes = []
3787
+ current_scene = await self.get_current_scene()
3734
3788
  return FullPollResult(
3735
3789
  device_info=device_info, metadata=metadata,
3736
3790
  light_poll=light_poll, pump_telemetry=pump_telemetry,
3737
- pump_schedule_points=pump_schedule_points, used_batch=False,
3791
+ pump_schedule_points=pump_schedule_points,
3792
+ configured_scenes=configured_scenes, current_scene=current_scene,
3793
+ used_batch=False,
3738
3794
  )
3739
3795
 
3740
3796
  async def get_current_light_percentages(self, which: int = 1,
@@ -0,0 +1,97 @@
1
+ """
2
+ Scenes: a device-side preset that can be activated on demand, separate
3
+ from the normal time-based schedule (Schedule1/Schedule2). Each
4
+ configured scene stores exactly the same kind of payload a schedule
5
+ point would (channel intensities for a light, mode+parameters for a
6
+ pump), plus a name and a timeout, at a fixed slot within
7
+ ConfiguredScenes (400). Activating one writes CurrentScene (401).
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import struct
13
+ from dataclasses import dataclass
14
+ from typing import Optional
15
+
16
+ from .constants import SceneID, PrimitiveType, LIGHT_PRIMITIVES, PUMP_PRIMITIVES_VERIFIED, PUMP_PRIMITIVES_EXPERIMENTAL
17
+ from .schedule import LightPrimitive, PumpPrimitiveValue
18
+
19
+ SCENE_HEADER_SIZE = 20 # id(2) + timeout(2) + name(16), before primitiveData
20
+ SCENE_NAME_SIZE = 16
21
+
22
+
23
+ @dataclass
24
+ class Scene:
25
+ """One configured scene, at a fixed slot (`index`) within
26
+ ConfiguredScenes. `scene_type` is one of the ten built-in presets
27
+ if `id` matches one, or None for a user-created scene (whose own
28
+ `id` is a device-assigned value outside that range). Exactly one
29
+ of `light`/`pump` is populated, matching the device's own
30
+ PrimitiveType -- the other stays None."""
31
+ index: int
32
+ id: int
33
+ scene_type: Optional[SceneID]
34
+ name: str
35
+ timeout: int
36
+ light: Optional[LightPrimitive]
37
+ pump: Optional[PumpPrimitiveValue]
38
+
39
+
40
+ @dataclass
41
+ class ActiveScene:
42
+ """The currently active scene (CurrentScene, 401) and how many
43
+ seconds it has left. `scene_type` is None if `id` doesn't match
44
+ one of the ten built-in presets (i.e. a user-created scene is
45
+ active) -- id itself is always present either way."""
46
+ id: int
47
+ scene_type: Optional[SceneID]
48
+ duration_seconds: int
49
+
50
+
51
+ def decode_configured_scenes(values: list[bytes], primitive: Optional[PrimitiveType]) -> list[Scene]:
52
+ """
53
+ Pure decode for ConfiguredScenes (400) -- one call's worth of
54
+ values from a "get all elements" read (index=0, count=0xFFFF),
55
+ one element per slot, in index order. A slot with fewer than
56
+ SCENE_HEADER_SIZE bytes is skipped rather than raising.
57
+ """
58
+ scenes = []
59
+ for index, raw in enumerate(values):
60
+ if len(raw) < SCENE_HEADER_SIZE:
61
+ continue
62
+ scene_id = struct.unpack_from("<H", raw, 0)[0]
63
+ timeout = struct.unpack_from("<H", raw, 2)[0]
64
+ name_bytes = raw[4:4 + SCENE_NAME_SIZE]
65
+ name = name_bytes.split(b"\x00", 1)[0].decode("utf-8", errors="replace")
66
+ primitive_data = raw[SCENE_HEADER_SIZE:]
67
+
68
+ try:
69
+ scene_type = SceneID(scene_id)
70
+ except ValueError:
71
+ scene_type = None
72
+
73
+ light = None
74
+ pump = None
75
+ if primitive in LIGHT_PRIMITIVES:
76
+ light = LightPrimitive.parse(primitive_data)
77
+ elif primitive in PUMP_PRIMITIVES_VERIFIED or primitive in PUMP_PRIMITIVES_EXPERIMENTAL:
78
+ pump = PumpPrimitiveValue.parse(primitive_data)
79
+
80
+ scenes.append(Scene(
81
+ index=index, id=scene_id, scene_type=scene_type, name=name,
82
+ timeout=timeout, light=light, pump=pump,
83
+ ))
84
+ return scenes
85
+
86
+
87
+ def decode_active_scene(raw: bytes) -> Optional[ActiveScene]:
88
+ """Pure decode for CurrentScene (401): id(u16 LE) + duration
89
+ seconds(u16 LE). None if raw is too short to contain both fields."""
90
+ if len(raw) < 4:
91
+ return None
92
+ scene_id, duration = struct.unpack_from("<HH", raw, 0)
93
+ try:
94
+ scene_type = SceneID(scene_id)
95
+ except ValueError:
96
+ scene_type = None
97
+ return ActiveScene(id=scene_id, scene_type=scene_type, duration_seconds=duration)
@@ -14,6 +14,7 @@ already covered by test_metadata_batch.py/test_light_poll_batch.py.
14
14
  """
15
15
 
16
16
  import datetime
17
+ import struct
17
18
  from unittest.mock import AsyncMock
18
19
 
19
20
  import pytest
@@ -21,7 +22,7 @@ from bleak.backends.device import BLEDevice
21
22
 
22
23
  from mobius import (
23
24
  C2Attribute, AttributeValue, SupportedAttribute, PrimitiveType, Model,
24
- SchedulePoint, MetadataSnapshot, LightPollResult, LightIntensityResult,
25
+ SchedulePoint, MetadataSnapshot, LightPollResult, LightIntensityResult, SceneID,
25
26
  )
26
27
  from mobius.device import MobiusDevice
27
28
 
@@ -178,6 +179,75 @@ async def test_pump_combined_batch_decodes_every_piece():
178
179
  assert len(result.pump_schedule_points) == 1
179
180
 
180
181
 
182
+ def _scene_bytes(scene_id: int, timeout: int, name: str, primitive_data: bytes) -> bytes:
183
+ name_bytes = name.encode("utf-8")[:16].ljust(16, b"\x00")
184
+ return struct.pack("<HH", scene_id, timeout) + name_bytes + primitive_data
185
+
186
+
187
+ async def test_light_combined_batch_includes_scenes_when_supported():
188
+ """The actual point of folding scenes into this combined batch:
189
+ ConfiguredScenes/CurrentScene are actually REQUESTED as part of
190
+ this same batch (not a separate round-trip), and decode from the
191
+ SAME response as everything else."""
192
+ device = MobiusDevice(_fake_ble_device())
193
+ scene_bytes = _scene_bytes(
194
+ int(SceneID.AllOn), 60, "Bright",
195
+ struct.pack("<BH", 18, 1000), # VisualID.RoyalBlue=18
196
+ )
197
+ captured_requests = []
198
+
199
+ async def fake_get_attributes_batch(requests):
200
+ captured_requests.extend(requests)
201
+ return [
202
+ _av(C2Attribute.Model, 0, bytes.fromhex("b300")),
203
+ _av(C2Attribute.SerialNumber, 0, b"7V4Z00F143RBED\x00\x00"),
204
+ _av(C2Attribute.ErrorState, 0, bytes.fromhex("0000")),
205
+ _av(C2Attribute.Schedule1, 0, *_day_schedule()),
206
+ _av(C2Attribute.LunarPhasesEnabled, 0, bytes([1])),
207
+ _av(C2Attribute.ConfiguredScenes, 0, scene_bytes),
208
+ _av(C2Attribute.CurrentScene, 0, struct.pack("<HH", int(SceneID.AllOn), 45)),
209
+ ]
210
+
211
+ device.get_attributes_batch = fake_get_attributes_batch
212
+ supported = LIGHT_SUPPORTED | {C2Attribute.ConfiguredScenes, C2Attribute.CurrentScene}
213
+ result = await device.get_full_poll_batch(
214
+ primitive=PrimitiveType.VisualV1, model=Model.RadionXR15wG6Pro,
215
+ supported_attribute_ids=supported,
216
+ )
217
+
218
+ requested_attr_ids = {r[0] for r in captured_requests}
219
+ assert C2Attribute.ConfiguredScenes in requested_attr_ids
220
+ assert C2Attribute.CurrentScene in requested_attr_ids
221
+ assert len(result.configured_scenes) == 1
222
+ assert result.configured_scenes[0].name == "Bright"
223
+ assert result.current_scene.scene_type == SceneID.AllOn
224
+ assert result.current_scene.duration_seconds == 45
225
+
226
+
227
+ async def test_scenes_absent_from_the_request_when_unsupported():
228
+ """Confirms filtering by supported_attribute_ids applies to the
229
+ new scene attributes the same way it already does for everything
230
+ else -- a device that doesn't report supporting them never has
231
+ them in its own request at all."""
232
+ device = MobiusDevice(_fake_ble_device())
233
+ captured_requests = []
234
+
235
+ async def fake_get_attributes_batch(requests):
236
+ captured_requests.extend(requests)
237
+ return [_av(C2Attribute.Model, 0, bytes.fromhex("2a00"))]
238
+
239
+ device.get_attributes_batch = fake_get_attributes_batch
240
+ result = await device.get_full_poll_batch(
241
+ primitive=PrimitiveType.VorTechV1, supported_attribute_ids={C2Attribute.Model},
242
+ )
243
+
244
+ requested_attr_ids = {r[0] for r in captured_requests}
245
+ assert C2Attribute.ConfiguredScenes not in requested_attr_ids
246
+ assert C2Attribute.CurrentScene not in requested_attr_ids
247
+ assert result.configured_scenes == []
248
+ assert result.current_scene is None
249
+
250
+
181
251
  # --------------------------------------------------------------------------
182
252
  # Fallback to individual reads -- same confirmed-necessary reason as
183
253
  # every other *_batch() method in this library.
@@ -0,0 +1,241 @@
1
+ """Tests for scenes.py's decode_configured_scenes()/decode_active_scene(),
2
+ and the device.py methods built on top of them."""
3
+
4
+ import struct
5
+ from unittest.mock import AsyncMock
6
+
7
+ import pytest
8
+ from bleak.backends.device import BLEDevice
9
+
10
+ from mobius import (
11
+ Scene, ActiveScene, SceneID, PrimitiveType, VisualID, PumpMode, PumpParam,
12
+ decode_configured_scenes, decode_active_scene,
13
+ )
14
+ from mobius.frame import make_reserved
15
+ from mobius.device import MobiusDevice
16
+
17
+
18
+ def _scene_bytes(scene_id: int, timeout: int, name: str, primitive_data: bytes) -> bytes:
19
+ name_bytes = name.encode("utf-8")[:16].ljust(16, b"\x00")
20
+ return struct.pack("<HH", scene_id, timeout) + name_bytes + primitive_data
21
+
22
+
23
+ def _light_primitive_bytes(channel: VisualID, intensity: int) -> bytes:
24
+ return struct.pack("<BH", int(channel), intensity)
25
+
26
+
27
+ def _pump_primitive_bytes(mode: PumpMode, max_speed: int) -> bytes:
28
+ return bytes([int(mode)]) + struct.pack("<h", max_speed)
29
+
30
+
31
+ # --------------------------------------------------------------------------
32
+ # decode_configured_scenes
33
+ # --------------------------------------------------------------------------
34
+
35
+ def test_decode_light_scene():
36
+ raw = _scene_bytes(int(SceneID.AllOn), 60, "Bright", _light_primitive_bytes(VisualID.RoyalBlue, 1000))
37
+ scenes = decode_configured_scenes([raw], PrimitiveType.VisualV1)
38
+
39
+ assert len(scenes) == 1
40
+ scene = scenes[0]
41
+ assert scene.index == 0
42
+ assert scene.id == int(SceneID.AllOn)
43
+ assert scene.scene_type == SceneID.AllOn
44
+ assert scene.name == "Bright"
45
+ assert scene.timeout == 60
46
+ assert scene.pump is None
47
+ assert scene.light.get(VisualID.RoyalBlue) == 1000
48
+
49
+
50
+ def test_decode_pump_scene():
51
+ raw = _scene_bytes(int(SceneID.FeedMode), 30, "Feed", _pump_primitive_bytes(PumpMode.Feed, 0))
52
+ scenes = decode_configured_scenes([raw], PrimitiveType.VorTechV1)
53
+
54
+ assert len(scenes) == 1
55
+ scene = scenes[0]
56
+ assert scene.scene_type == SceneID.FeedMode
57
+ assert scene.name == "Feed"
58
+ assert scene.light is None
59
+ assert scene.pump.mode == PumpMode.Feed
60
+ assert scene.pump.params[PumpParam.MaxSpeed] == 0
61
+
62
+
63
+ def test_decode_custom_scene_has_no_scene_type():
64
+ """A user-created scene's own id is a device-assigned value outside
65
+ the ten built-in presets -- confirms this doesn't raise, and
66
+ scene_type comes back None rather than a wrong/guessed preset."""
67
+ raw = _scene_bytes(65000, 60, "Sushi", _light_primitive_bytes(VisualID.RoyalBlue, 500))
68
+ scenes = decode_configured_scenes([raw], PrimitiveType.VisualV1)
69
+
70
+ assert scenes[0].id == 65000
71
+ assert scenes[0].scene_type is None
72
+ assert scenes[0].name == "Sushi"
73
+
74
+
75
+ def test_decode_multiple_slots_preserves_index_order():
76
+ raw1 = _scene_bytes(int(SceneID.EmptyScene), 0, "", bytes(3))
77
+ raw2 = _scene_bytes(int(SceneID.AllOn), 60, "Bright", _light_primitive_bytes(VisualID.RoyalBlue, 1000))
78
+ scenes = decode_configured_scenes([raw1, raw2], PrimitiveType.VisualV1)
79
+
80
+ assert len(scenes) == 2
81
+ assert scenes[0].index == 0 and scenes[0].name == ""
82
+ assert scenes[1].index == 1 and scenes[1].name == "Bright"
83
+
84
+
85
+ def test_decode_skips_elements_shorter_than_the_header():
86
+ raw_short = bytes(10) # shorter than the 20-byte header
87
+ raw_ok = _scene_bytes(int(SceneID.AllOn), 60, "Bright", _light_primitive_bytes(VisualID.RoyalBlue, 1000))
88
+ scenes = decode_configured_scenes([raw_short, raw_ok], PrimitiveType.VisualV1)
89
+
90
+ assert len(scenes) == 1
91
+ assert scenes[0].name == "Bright"
92
+
93
+
94
+ def test_decode_with_no_primitive_type_leaves_light_and_pump_none():
95
+ raw = _scene_bytes(int(SceneID.AllOn), 60, "Bright", _light_primitive_bytes(VisualID.RoyalBlue, 1000))
96
+ scenes = decode_configured_scenes([raw], None)
97
+
98
+ assert scenes[0].light is None
99
+ assert scenes[0].pump is None
100
+ assert scenes[0].name == "Bright"
101
+
102
+
103
+ # --------------------------------------------------------------------------
104
+ # decode_active_scene -- the actual bug fix (used to raise on a custom id)
105
+ # --------------------------------------------------------------------------
106
+
107
+ def test_decode_active_scene_known_preset():
108
+ raw = struct.pack("<HH", int(SceneID.FeedMode), 45)
109
+ active = decode_active_scene(raw)
110
+
111
+ assert active.id == int(SceneID.FeedMode)
112
+ assert active.scene_type == SceneID.FeedMode
113
+ assert active.duration_seconds == 45
114
+
115
+
116
+ def test_decode_active_scene_custom_id_does_not_raise():
117
+ """The actual bug this fixes: SceneID(scene_id) used to raise
118
+ ValueError outright whenever a custom (non-preset) scene was the
119
+ one currently active."""
120
+ raw = struct.pack("<HH", 65000, 12)
121
+ active = decode_active_scene(raw)
122
+
123
+ assert active.id == 65000
124
+ assert active.scene_type is None
125
+ assert active.duration_seconds == 12
126
+
127
+
128
+ def test_decode_active_scene_too_short_returns_none():
129
+ assert decode_active_scene(bytes(2)) is None
130
+
131
+
132
+ # --------------------------------------------------------------------------
133
+ # Device methods
134
+ # --------------------------------------------------------------------------
135
+
136
+ def _fake_ble_device():
137
+ return BLEDevice("AA:BB:CC:DD:EE:FF", "MOBIUS", {})
138
+
139
+
140
+ @pytest.mark.asyncio
141
+ async def test_get_configured_scenes_reads_all_elements():
142
+ device = MobiusDevice(_fake_ble_device())
143
+ raw = _scene_bytes(int(SceneID.AllOn), 60, "Bright", _light_primitive_bytes(VisualID.RoyalBlue, 1000))
144
+ device.get_attribute = AsyncMock(return_value=[raw])
145
+
146
+ scenes = await device.get_configured_scenes(primitive=PrimitiveType.VisualV1)
147
+
148
+ device.get_attribute.assert_awaited_once()
149
+ call_args = device.get_attribute.call_args
150
+ assert call_args.kwargs.get("index") == 0
151
+ assert call_args.kwargs.get("count") == 0xFFFF
152
+ assert scenes[0].name == "Bright"
153
+
154
+
155
+ @pytest.mark.asyncio
156
+ async def test_get_current_scene_decodes_the_response():
157
+ device = MobiusDevice(_fake_ble_device())
158
+ raw = struct.pack("<HH", int(SceneID.FeedMode), 45)
159
+ device.get_attribute = AsyncMock(return_value=[raw])
160
+
161
+ active = await device.get_current_scene()
162
+
163
+ assert active.scene_type == SceneID.FeedMode
164
+ assert active.duration_seconds == 45
165
+
166
+
167
+ @pytest.mark.asyncio
168
+ async def test_get_current_scene_fails_soft_when_unsupported():
169
+ device = MobiusDevice(_fake_ble_device())
170
+ device.get_attribute = AsyncMock(side_effect=IOError("not supported"))
171
+
172
+ assert await device.get_current_scene() is None
173
+
174
+
175
+ @pytest.mark.asyncio
176
+ async def test_start_scene_writes_id_and_seconds():
177
+ """Confirms the actual unit is seconds, not minutes -- the
178
+ parameter used to be misleadingly named duration_minutes even
179
+ though the device treats it as seconds."""
180
+ device = MobiusDevice(_fake_ble_device())
181
+ device.set_attribute = AsyncMock()
182
+
183
+ await device.start_scene(int(SceneID.FeedMode), duration_seconds=90)
184
+
185
+ device.set_attribute.assert_awaited_once()
186
+ call_args = device.set_attribute.call_args
187
+ written = call_args.args[1] if len(call_args.args) > 1 else call_args.kwargs.get("value")
188
+ scene_id, seconds = struct.unpack("<HH", written)
189
+ assert scene_id == int(SceneID.FeedMode)
190
+ assert seconds == 90
191
+
192
+
193
+ @pytest.mark.asyncio
194
+ async def test_start_scene_accepts_a_custom_scene_id():
195
+ """A user-created scene's own id isn't a SceneID enum member at
196
+ all -- confirms start_scene() accepts a plain int, not just SceneID."""
197
+ device = MobiusDevice(_fake_ble_device())
198
+ device.set_attribute = AsyncMock()
199
+
200
+ await device.start_scene(65000, duration_seconds=0)
201
+
202
+ written = device.set_attribute.call_args.args[1]
203
+ scene_id, _ = struct.unpack("<HH", written)
204
+ assert scene_id == 65000
205
+
206
+
207
+ @pytest.mark.asyncio
208
+ async def test_start_scene_broadcasts_by_default():
209
+ """The actual point of broadcast=True (the default): the frame's
210
+ own reserved-byte group field is set to 1, which propagates a
211
+ single write to the rest of the mesh."""
212
+ device = MobiusDevice(_fake_ble_device())
213
+ device.set_attribute = AsyncMock()
214
+
215
+ await device.start_scene(int(SceneID.FeedMode))
216
+
217
+ device.set_attribute.assert_awaited_once()
218
+ reserved = device.set_attribute.call_args.kwargs.get("reserved")
219
+ assert reserved == make_reserved(group=1)
220
+
221
+
222
+ @pytest.mark.asyncio
223
+ async def test_start_scene_broadcast_false_writes_only_this_device():
224
+ device = MobiusDevice(_fake_ble_device())
225
+ device.set_attribute = AsyncMock()
226
+
227
+ await device.start_scene(int(SceneID.FeedMode), broadcast=False)
228
+
229
+ reserved = device.set_attribute.call_args.kwargs.get("reserved")
230
+ assert reserved == b"\x00\x00"
231
+
232
+
233
+ @pytest.mark.asyncio
234
+ async def test_start_feed_mode_passes_through_broadcast():
235
+ device = MobiusDevice(_fake_ble_device())
236
+ device.set_attribute = AsyncMock()
237
+
238
+ await device.start_feed_mode(broadcast=False)
239
+
240
+ reserved = device.set_attribute.call_args.kwargs.get("reserved")
241
+ assert reserved == b"\x00\x00"
File without changes
File without changes