Repository navigation
Add internal schedule control for Plugwise Circle(+) and Stealth devices - #517
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| def _setup_circle_protocol( | ||
| self, | ||
| firmware: dict[datetime, SupportedVersions], | ||
| features: tuple[NodeFeature, ...], | ||
| ) -> None: | ||
| """Set up features for Circles and related hardware.""" | ||
| # A Stealth+ shares the Circle+ node type. Require an identified Circle model. | ||
| hardware_model = HW_MODELS.get(self._node_info.version or "", "") | ||
| if self.node_type in (NodeType.CIRCLE, NodeType.CIRCLE_PLUS) and ( | ||
| hardware_model == "Circle" or hardware_model.startswith("Circle ") | ||
| ): | ||
| features += (NodeFeature.SCHEDULE_CONTROL,) | ||
| self._setup_protocol(firmware, features) |
There was a problem hiding this comment.
I don't think this bit of code is required when you add the NodeFeature.SCHEDULE_CONTROL to the CIRCLE_FEATURES constant.
There was a problem hiding this comment.
I don't think this bit of code is required when you add the
NodeFeature.SCHEDULE_CONTROLto theCIRCLE_FEATURESconstant.
I added this check because PlugwiseStealth inherits the Circle setup and Stealth+ shares the Circle+ node type. Adding SCHEDULE_CONTROL directly to the shared feature lists would also expose it on those models. I’ve only verified schedule control on Circle and Circle+. Is there an existing model-specific feature check I could reuse here?
There was a problem hiding this comment.
Circles and Stealths share the same functions so no need to limit this functionality to Circles only.
There was a problem hiding this comment.
@blb4github please implement the above suggestion: add the NodeFeature.SCHEDULE_CONTROL to the CIRCLE_FEATURES constant, remove the _setup_circle_protocol() change.
And fully remove the update of the get_state() function shown below.
There was a problem hiding this comment.
@bouwew, I’ve addressed your feedback in 5d3af93. SCHEDULE_CONTROL now uses the existing feature lists for Circle and Stealth devices, including the coordinator variants. I removed _setup_circle_protocol() and the schedule-specific handling in get_state(). All 57 tests passed. Could you take another look?
| self, features: tuple[NodeFeature, ...] | ||
| ) -> dict[NodeFeature, Any]: | ||
| """Update latest state for given feature.""" | ||
| if NodeFeature.SCHEDULE_CONTROL in features: |
There was a problem hiding this comment.
You don't want to store the state of this feature?
This depends on how it's implemented in the custom_component.
I'm thinking of a schedule_enabled switch: enabled = schedule enabled, disabled = schedule disabled.
If you agree, just add to the existing match-feature-case construct.
There was a problem hiding this comment.
A switch would make sense if we could read the current schedule state from the device. I have done an attempt to find the state but in my tests, 36 Node Information replies and 36 Clock Information replies showed no reproducible change after enabling or disabling the schedule. The device acknowledges the command, so the only value we could store today is the last acknowledged setting. After a restart, that could give Home Assistant a misleading state.
That’s why the companion integration uses two configuration buttons, Enable internal schedule and Disable internal schedule, and treats SCHEDULE_CONTROL as an action-only capability. Do you know of a command or response field that reports the current schedule state? If so, I’d be happy to test it on my Circle and Circle+.
There was a problem hiding this comment.
Now that I've slept on it, I realize that too, a getter-function is required for what I have in mind.
I've found a way to look inside the Source windows files, I'll have a look to see if such a getter-function exists.
There was a problem hiding this comment.
I would suggest to fully remove this code-change-chunk, the feature will be ignored because there is no match-case entry for the new feature.
|
@blb4github Very nice addition! Please see my feedback below 🙂 Hmm, only two comments are shown here, I added 3. I would suggest you read them in the |
bouwew
left a comment
There was a problem hiding this comment.
I think the update can be simplified somewhat, please see my comments.
I checked the Files changed view too. I can see the comments about CIRCLE_FEATURES and the proposed schedule_enabled switch but not a third one, sorry. Could you send me the permalink to the third comment, or repost it? |
|
Sorry, I forget to finish that comment, it's visible now 🙂 |
|
@blb4github I've looked in the Source files, I could not find anything on how to see if a Circle has a schedule enabled, or not. Do you remember if there is something in Source that shows this? If not, then I will need to retract my comment on the name with Also, my comment on getting the state is then not correct. My comment on |
Advertise schedule control through normal firmware capability setup for Circle and Stealth families. Restore the standard state polling path and cover hardware variants and firmware gating with simulated responses.
|
bouwew
left a comment
There was a problem hiding this comment.
Approved after addressing the comments, thanks!



Summary
Addresses #516. This adds an explicit API to enable or disable an existing
on-device schedule while preserving its contents.
Circle and Stealth devices, including their coordinator variants, advertise
NodeFeature.SCHEDULE_CONTROLwhen their firmware supports protocol 2.0.Call
await node.set_schedule_enabled(enabled)to control the schedule.The library sends request
0040with0101to enable or0001to disable.It validates the matching MAC address, sequence and node acknowledgement
(
00E4or00E5), then attempts a fresh relay read. The API returns therequested setting after the matching acknowledgement. The protocol messages
and firmware tested did not expose a reliable way to read the current schedule
state, so the capability is exposed as an action.
Schedule transactions serialize per node through all attempts and the relay
refresh. This prevents an earlier enable retry from following a later
confirmed disable. Cancellation while waiting drops the queued action.
An in-flight transaction finishes before cancellation propagates. Other nodes
and regular polling continue through the existing USB queue.
Validation
enable and disable on Circle, Circle+, Stealth, Stealth+ and Stealth M+,
as well as firmware gating, retry ordering, cancellation, terminal timeout,
relay refresh and independent operation of different nodes.
8 enables and 10 disables across a Circle and Circle+. All succeeded on the
first attempt. The trace captured 17 of 18 relay readbacks, and both devices
ended with a confirmed disable.
did not encounter a timeout or independently establish service-call overlap.
Stealth variants were tested in simulation. Autonomous relay switching at a
known scheduled time, persistence across a device power cycle and live
schedule-state readback remain unverified.
See the protocol findings and validation details
and the hardware retest procedure.