Skip to content

[BUG]: Activating a schedule does nothing when the Smile keeps the location in the inactive rule's contexts #933

Closed

Description

@voidzero

Describe the bug.

After switching off a named schedule outside Home Assistant (Plugwise app), the Smile reports <active>false</active> but keeps the location in the rule's contexts.

Selecting that schedule with select.select_option returns success, but the select stays off and the schedule remains inactive. climate.set_hvac_mode with auto goes through the same path.

Steps to reproduce:

  1. Switch off an active schedule outside HA.
  2. Confirm in /core/domain_objects that the rule has active=false while its contexts still include the thermostat's location.
  3. Select that schedule in HA.
  4. The service call succeeds, but the rule stays active=false and HA still shows off.

Expected behavior

Selecting a schedule activates its rule, and HA shows the selected schedule / auto after polling.

What version of Home Assistant Core has the issue?

core-2026.10.2

What type of installation are you running?

Home Assistant OS

How and which version of the integration do you have installed?

Home Assistant Core (python-plugwise 1.14.7)

What kind of Plugwise device is having issues?

Smile: Anna

What firmware version is your Plugwise product at?

Smile Anna gateway 4.4.4 (AME Smile 2.0 board); Anna ThermoTouch

Home Assistant Logging (optional)

No error is logged; the service call returns success.

Diagnostics information

Verified on the real device on 2026-10-23. Condensed, redacted /core/domain_objects fixture:

<domain_objects>
  <location id="LIVINGROOM_LOC_ID"><name>Living room</name></location>
  <rule id="RULE_ID">
    <name>Daily routiner</name>
    <active>false</active>
    <template id="TEMPLATE_ID" tag="zone_preset_based_on_time_and_presence_with_override"/>
    <directives><when time="[mo 07:00,mo 08:00)"><then preset="home"/></when></directives>
    <contexts><context><zone><location id="LIVINGROOM_LOC_ID"/></zone></context></contexts>
  </rule>
</domain_objects>

In plugwise/smile.py, SmileAPI.set_schedule_state() (approximately lines 360–414 in 1.14.7) proceeds because _schedules() reports OFF from active=false, leaving _schedule_old_states[loc][name] == "off".

determine_contexts() (approximately lines 416–430) finds the existing location element and appends that same element, leaving the contexts unchanged. The PUT to /core/rules;id=RULE_ID contains <name>, <template id="TEMPLATE_ID" .../> and the unchanged <contexts>, but no <active> element. The Smile returns HTTP 200 and leaves the rule inactive. This code was also unchanged on main when checked on 2026-10-23.

An offline reproduction against the real 1.14.7 wheel captures the request from set_schedule_state("LIVINGROOM_LOC_ID", "Daily routine", "on") with the fixture above and _schedule_old_states = {"LIVINGROOM_LOC_ID": {"Daily routine": "off"}}. The unpatched request satisfies:

assert "<active>" not in sent[0]  # reproduces the missing activation

Additional information

On the real device, sending the same PUT body with <active>true</active> inserted between <template .../> and <contexts> returned HTTP 200 and changed the rule to active=true, with the location linked. HA showed the selected schedule / auto on the next poll.

A local HA custom integration now wraps SmileAPI.determine_contexts() and prefixes <active>true</active> when state == "on"; the off path is unchanged. End-to-end verification: force the rule back to active=false while keeping the location, call HA select.select_option, then observe active=true and the schedule selected. The offline test also passes with this workaround and checks that the off path remains unchanged.

Suggested fix: include <active>true</active> in the rule body when switching a schedule on. Consider including <active>false</active> when switching off so both states are explicit; that off change has not been tested here.

As supporting context, another named rule has active=true with no location in its contexts. The firmware therefore does not keep active and contexts in sync on its own. This is an observation relevant to the activation logic, not a separate bug claim.

Activity

  1. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    @voidzero Thanks for reporting!

    I have a look at this during the weekend.

  2. voidzero commented on Oct 24, 2026

    @voidzero
    Author

    Thank you, @bouwew. This part of the module was not functioning for me for a long time, and finally this got it fixed. I turn off the schedule often, for example when I am only in my living room burning wood, and the rest of the house does not need to be heated. But at the end of the day i want to automatically resume the schedule if it's off, so my family won't be cold in the morning. 🙂 Thanks for taking a look.

  3. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    I've had a quick look at my Adam, when I create a new schedule and not assign it to a Zone yet, the active key shows true
    When I link it to a Zone or unlink it to a Zone, the active key does not change.

    I now realize that I miss this information for an Anna or Emma. What Plugwise device do you have?

  4. voidzero commented on Oct 24, 2026

    @voidzero
    Author

    I only have the Anna.

  5. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    I had a look at some Anna userdata, it looks like the Anna (software) does the same: remove the location id key from the rule id that represents the schedule, when the schedule is made inactive.
    Can you please look at your Smile xml-data to confirm if you see this as well?

    active always true

    		<contexts>
    		</contexts>
    

    when no active schedule, and

    		<contexts>
    			<context>
    				<zone><location id="some_id"/></zone>
    			</context>
    		</contexts>
    

    when the schedule is active.

  6. voidzero commented on Oct 24, 2026

    @voidzero
    Author

    Confirmed on my Anna (Smile 4.4.4, AME Smile 2.0 board), read from /core/domain_objects a few minutes ago:

    Dagelijkse sleur     active=true   contexts empty   modified 2026-10-24 09:25
    Weg op zondag        active=true   contexts empty   modified 2026-10-12
    Thermostat schedule  active=false  contexts empty   modified 2025-11-16
    

    So yes: I see your inactive state too. That is exactly what I get when I switch the schedule off from the Plugwise app - the Anna empties the contexts. Yesterday I got a different result from the same action though: the rule came out with active=false and the location still linked.

    <rule id="RULE_ID">
      <name>Dagelijkse sleur</name>
      <active>false</active>
      <template id="TEMPLATE_ID" tag="zone_preset_based_on_time_and_presence_with_override" />
      <contexts><context><zone><location id="LIVINGROOM_LOC_ID" /></zone></context></contexts>
    </rule>

    In that state HA's select and hvac_mode: auto do nothing: the PUT carries the same contexts and no <active>, the Smile returns 200 and the rule stays as it is. The same PUT with <active>true</active> added between <template/> and <contexts> activates it.

    So active is not always true here either ("Thermostat schedule" has been sitting at active=false since 2025), and contexts are not always emptied. The two deactivations gave me two different states, and I cannot say what caused the difference - both were done from the app as far as I know.

    If it helps: I can deactivate it deliberately both ways (Plugwise app and long press on the Anna) and send you the rule XML after each. That should show whether the firmware behaves differently per path.

  7. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    I've captured the data between my computer and the Adam with Wireshark, I could see that in the PUT the active key was never included.

    I will have a look at the code, update it based on what we know now.

  8. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    @voidzero please see the linked PR #933, this should fix the issue.
    Can you test this update in some way?

  9. added a commit that references this issue on Oct 24, 2026
  10. bouwew commented on Oct 24, 2026

    @bouwew
    Contributor

    Fixed in release v1.14.8

  11. voidzero commented on Oct 24, 2026

    @voidzero
    Author

    Works for me, @bouwew, much thanks for getting this fixed. Have a good weekend. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions