Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.0b25 (2026-12-01)

### Fixed

- Respect manual overrides when closing after a window is closed, and cancel pending retries when a user takes over a moving cover.

## 1.0.0b24 (2026-11-29)

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions custom_components/house_assistant/frontend/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ export const LABELS = {
],
"follow_up_close": [
"Nachziehen",
"Wird das Fenster am Abend geschlossen, fährt das Rollo zu (auch bei Übersteuerung)."
"Wird das Fenster am Abend geschlossen, fährt das Rollo zu, sofern keine Übersteuerung das abendliche Schließen blockiert."
],
"evening_custom": [
"Eigene Abendzeiten",
Expand Down Expand Up @@ -4337,7 +4337,7 @@ export const LABELS = {
],
"follow_up_close": [
"Close after window closed",
"If the window is closed in the evening, the cover closes (also during an override)."
"If the window is closed in the evening, the cover closes unless an override blocks evening closing."
],
"evening_custom": [
"Own evening times",
Expand Down Expand Up @@ -6918,7 +6918,7 @@ export const SHUTTER = {
],
"follow_up_close": [
"Nachziehen",
"Wird das Fenster am Abend geschlossen, fährt das Rollo zu (auch bei Übersteuerung)."
"Wird das Fenster am Abend geschlossen, fährt das Rollo zu, sofern keine Übersteuerung das abendliche Schließen blockiert."
],
"follow_up_earliest": [
"Nachziehen ab",
Expand Down Expand Up @@ -7316,7 +7316,7 @@ export const SHUTTER = {
],
"follow_up_close": [
"Close after window closed",
"If the window is closed in the evening, the cover closes (also during an override)."
"If the window is closed in the evening, the cover closes unless an override blocks evening closing."
],
"follow_up_earliest": [
"Close after window closed, from",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/house_assistant/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"loggers": ["anthropic"],
"requirements": ["anthropic>=0.125.0"],
"single_config_entry": true,
"version": "1.0.0b24"
"version": "1.0.0b25"
}
15 changes: 14 additions & 1 deletion custom_components/house_assistant/shutter/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ def _on_cover(self, event: Event[EventStateChangedData]) -> None:
return
now = dt_util.now()
new_pos = as_float(new.attributes.get("current_position"))
takeover = self.tracker.take_over(entity_id, new.context.id, new.context.user_id)
own = self.tracker.explains(
entity_id,
new.context.id,
Expand All @@ -1751,7 +1752,19 @@ def _on_cover(self, event: Event[EventStateChangedData]) -> None:
old_position=old_pos,
new_position=new_pos,
)
if self.opt(CONF_OVERRIDE_TRIGGER) == TRIGGER_COMMAND:
if takeover and self.automatic:
self.movements.update(
entity_id,
started=False,
own=True,
old_state=None,
old_position=None,
new_state=new.state,
new_position=new_pos,
now=now.timestamp(),
)
manual = True
elif self.opt(CONF_OVERRIDE_TRIGGER) == TRIGGER_COMMAND:
manual = started
else:
manual = self.movements.update(
Expand Down
8 changes: 8 additions & 0 deletions custom_components/house_assistant/shutter/logic/override.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class CommandTracker:
def register(self, cover: str, target: int | None, context_id: str | None, now: float) -> None:
self._commands[cover] = _Command(target, context_id, now)

def take_over(self, cover: str, context_id: str | None, user_id: str | None) -> bool:
"""Forget our command when a different user command takes over."""
command = self._commands.get(cover)
if command is None or user_id is None or context_id == command.context_id:
return False
del self._commands[cover]
return True

def explains(
self,
cover: str,
Expand Down
10 changes: 8 additions & 2 deletions custom_components/house_assistant/shutter/logic/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,14 @@ def evening(rules: WindowRules, s: Situation) -> list[Action]:

def follow_up(rules: WindowRules, s: Situation, after_earliest: bool) -> list[Action]:
"""Window closed in the evening: close the cover to the evening position
(ignores overrides)."""
if rules.follow_up_close and s.active and s.evening and after_earliest:
unless an override blocks evening closing."""
if (
rules.follow_up_close
and s.active
and s.evening
and after_earliest
and not _override_blocks_evening(rules, s)
):
return [_move(rules.evening_position, R_FOLLOW_UP), Action(MARK_EVENING, R_FOLLOW_UP)]
return []

Expand Down
2 changes: 1 addition & 1 deletion custom_components/house_assistant/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@
"data_description": {
"evening_close": "Close at the start of the evening mode, once per evening and only with a closed window.",
"evening_position": "Target of the evening run and of closing after the window was closed. 0 % = closed; e.g. 20 % leaves a gap on warm nights.",
"follow_up_close": "If the window is closed in the evening, the cover closes (also during an override).",
"follow_up_close": "If the window is closed in the evening, the cover closes unless an override blocks evening closing.",
"evening_custom": "Use the following values instead of the global ones.",
"evening_earliest": "The evening mode never starts before this time.",
"evening_elevation": "The evening mode starts when the sun drops below this elevation (e.g. -4 °).",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/house_assistant/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@
"data_description": {
"evening_close": "Zu Beginn des Abendmodus schließen, einmal pro Abend und nur bei geschlossenem Fenster.",
"evening_position": "Ziel des Abendlaufs und des Nachziehens. 0 % = zu; z. B. 20 % lässt in warmen Nächten einen Spalt.",
"follow_up_close": "Wird das Fenster am Abend geschlossen, fährt das Rollo zu (auch bei Übersteuerung).",
"follow_up_close": "Wird das Fenster am Abend geschlossen, fährt das Rollo zu, sofern keine Übersteuerung das abendliche Schließen blockiert.",
"evening_custom": "Die folgenden Werte statt der globalen verwenden.",
"evening_earliest": "Vor dieser Uhrzeit beginnt der Abendmodus nie.",
"evening_elevation": "Der Abendmodus beginnt, wenn die Sonne unter diese Höhe sinkt (z. B. -4 °).",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/house_assistant/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@
"data_description": {
"evening_close": "Close at the start of the evening mode, once per evening and only with a closed window.",
"evening_position": "Target of the evening run and of closing after the window was closed. 0 % = closed; e.g. 20 % leaves a gap on warm nights.",
"follow_up_close": "If the window is closed in the evening, the cover closes (also during an override).",
"follow_up_close": "If the window is closed in the evening, the cover closes unless an override blocks evening closing.",
"evening_custom": "Use the following values instead of the global ones.",
"evening_earliest": "The evening mode never starts before this time.",
"evening_elevation": "The evening mode starts when the sun drops below this elevation (e.g. -4 °).",
Expand Down
4 changes: 2 additions & 2 deletions docs/covers.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The module is event driven: it reacts only to state changes of the entities conf
* **Evening mode:** starts when the sun sinks below the configured elevation (default -4 °), at the earliest at 17:00 and at the latest at 21:00. It ends at 03:30 or at sunrise. Values global or per window.
* **Evening run:** at the start of the evening mode each cover closes once if the window is closed and no override is active (per window: close despite an override, e.g. bedrooms).
* **Evening position:** per window the target of evening run, follow-up closing and vacation in the evening. Default 0 % = closed; e.g. 20 % leaves a gap on warm nights.
* **Follow-up closing:** when a window is closed in the evening, the cover closes (from 16:00, also with an override).
* **Follow-up closing:** when a window is closed in the evening, the cover closes (from 16:00, unless an override blocks evening closing).
* **Ventilation position:** when a window is opened and the cover is (almost) closed, it moves to the ventilation position (default 30 %). In the evening after 3 s, in daytime after 60 s, if the window is still open then.

### Window contacts, tilted and door
Expand Down Expand Up @@ -59,7 +59,7 @@ The module is event driven: it reacts only to state changes of the entities conf

Every manual movement (at the switch, in the app, not by House Assistant and not by other automations or scripts) starts an override for the window, default 60 min. Every further movement restarts it. Optionally it also ends at sunrise, with duration 0 only at sunrise. The module remembers its own movements, so late position reports are not taken for manual ones.

In the settings (panel *Covers > General*, card **Manual override**) you choose when it starts: **only when the cover really moves** (default; the position changes by more than 2 %, for covers without a position it stands differently afterwards) or **on every command by hand, also without a movement**. With the default, e.g. "Alexa, open all covers" starts no override for covers already open.
In the settings (panel *Covers > General*, card **Manual override**) you choose when it starts: **only when the cover really moves** (default; the position changes by more than 2 %, for covers without a position it stands differently afterwards) or **on every command by hand, also without a movement**. A user command taking over an active module movement starts an override immediately and cancels its retry. With the default, e.g. "Alexa, open all covers" starts no override for covers already open.

### Extra conditions instead of special rules

Expand Down
4 changes: 2 additions & 2 deletions docs/covers.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Das Modul arbeitet ereignisgesteuert: Es reagiert nur auf Zustandswechsel der ei
* **Abendmodus:** beginnt, wenn die Sonne unter die eingestellte Höhe sinkt (Standard -4 °), frühestens um 17:00 und spätestens um 21:00. Er endet um 03:30 oder bei Sonnenaufgang. Werte global oder pro Fenster.
* **Abendlauf:** zu Beginn des Abendmodus schließt jedes Rollo einmal, wenn das Fenster zu ist und keine Übersteuerung aktiv ist (pro Fenster einstellbar: trotz Übersteuerung schließen, z. B. Schlafräume).
* **Abendposition:** pro Fenster das Ziel von Abendlauf, Nachziehen und Urlaub abends. Standard 0 % = zu; z. B. 20 % lässt in warmen Nächten einen Spalt.
* **Nachziehen:** wird am Abend ein Fenster geschlossen, fährt das Rollo zu (ab 16:00, auch bei Übersteuerung).
* **Nachziehen:** wird am Abend ein Fenster geschlossen, fährt das Rollo zu (ab 16:00, sofern keine Übersteuerung das abendliche Schließen blockiert).
* **Lüftungsposition:** wird ein Fenster geöffnet und das Rollo ist (fast) zu, fährt es auf die Lüftungsposition (Standard 30 %). Abends nach 3 s, tagsüber nach 60 s, wenn das Fenster dann noch offen ist.

### Fensterkontakte, gekippt und Tür
Expand Down Expand Up @@ -59,7 +59,7 @@ Das Modul arbeitet ereignisgesteuert: Es reagiert nur auf Zustandswechsel der ei

Jede manuelle Bewegung (am Taster, in der App, nicht durch House Assistant und nicht durch andere Automationen oder Skripte) startet eine Übersteuerung für das Fenster, Standard 60 min. Jede weitere Bewegung startet sie neu. Optional endet sie zusätzlich bei Sonnenaufgang, mit Dauer 0 nur bei Sonnenaufgang. Das Modul merkt sich seine eigenen Fahrten, späte Positionsmeldungen werden deshalb nicht fälschlich als manuell gewertet.

In den Einstellungen (Panel *Rollos > Allgemein*, Karte **Manuelle Übersteuerung**) lässt sich wählen, wann sie beginnt: **nur wenn das Rollo wirklich fährt** (Standard; die Position ändert sich um mehr als 2 %, bei Rollos ohne Position steht es danach anders) oder **bei jedem Befehl von Hand, auch ohne Fahrt**. Mit dem Standard startet z. B. „Alexa, alle Rollos auf“ keine Übersteuerung bei Rollos, die schon offen sind.
In den Einstellungen (Panel *Rollos > Allgemein*, Karte **Manuelle Übersteuerung**) lässt sich wählen, wann sie beginnt: **nur wenn das Rollo wirklich fährt** (Standard; die Position ändert sich um mehr als 2 %, bei Rollos ohne Position steht es danach anders) oder **bei jedem Befehl von Hand, auch ohne Fahrt**. Übernimmt ein Benutzerbefehl eine laufende Fahrt des Moduls, startet sofort eine Übersteuerung und der Wiederholungsversuch entfällt. Mit dem Standard startet z. B. „Alexa, alle Rollos auf“ keine Übersteuerung bei Rollos, die schon offen sind.

### Zusatzbedingungen statt Sonderregeln

Expand Down
54 changes: 54 additions & 0 deletions tests/shutter/ha/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,3 +830,57 @@ async def test_heating_day_with_a_too_warm_room_still_protects(
await _summer_noon(hass, freezer, heating_entity=HEATING_DAY, room={"temperature_sensor": ROOM})
await advance(hass, freezer, 15 * 60)
assert len(calls["set_cover_position"]) == 1


async def test_follow_up_does_not_close_during_override(
hass: HomeAssistant, base_states, calls, freezer: FrozenDateTimeFactory
) -> None:
freezer.move_to("2026-12-15 16:55:00+01:00")
await setup_entry(hass, make_entry())
await advance(hass, freezer, 10 * 60)
assert len(calls["close_cover"]) == 1
set_cover(hass, 0)
await hass.async_block_till_done()
await advance(hass, freezer, 20)
set_cover(hass, 0, state="opening")
set_cover(hass, 40)
await hass.async_block_till_done()
assert hass.states.get(OVERRIDE).state == "on"
hass.states.async_set(CONTACT, "on")
await hass.async_block_till_done()
await advance(hass, freezer, 4, step=1)
hass.states.async_set(CONTACT, "off")
await hass.async_block_till_done()
await advance(hass, freezer, 6, step=1)
assert len(calls["close_cover"]) == 1


async def test_user_takes_over_own_movement_cancels_retry(
hass: HomeAssistant, base_states, calls, freezer: FrozenDateTimeFactory
) -> None:
freezer.move_to("2026-12-15 16:55:00+01:00")
await setup_entry(hass, make_entry(verify_after=90))
await advance(hass, freezer, 6 * 60)
assert len(calls["close_cover"]) == 1
set_cover(hass, 80, state="closing")
await hass.async_block_till_done()
set_cover(hass, 75, state="opening", context=Context(user_id="user"))
await hass.async_block_till_done()
assert hass.states.get(OVERRIDE).state == "on"
await advance(hass, freezer, 120)
assert len(calls["close_cover"]) == 1
assert engine_of(hass).windows[WINDOW_ID].last_reason.get("code") != "cover_retry"


async def test_ordinary_report_during_own_movement_keeps_retry(
hass: HomeAssistant, base_states, calls, freezer: FrozenDateTimeFactory
) -> None:
freezer.move_to("2026-12-15 16:55:00+01:00")
await setup_entry(hass, make_entry(verify_after=90))
await advance(hass, freezer, 6 * 60)
assert len(calls["close_cover"]) == 1
set_cover(hass, 80, state="closing", context=Context(parent_id="automation"))
await hass.async_block_till_done()
assert hass.states.get(OVERRIDE).state == "off"
await advance(hass, freezer, 120)
assert len(calls["close_cover"]) >= 2
10 changes: 10 additions & 0 deletions tests/shutter/logic/test_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,13 @@ def test_reached() -> None:
assert not reached(100, None, "closed")
assert reached(0, None, "closed")
assert reached(50, None, "open")


def test_user_takes_over_tracked_command() -> None:
tracker = CommandTracker()
tracker.register("cover.a", 0, "ours", 0)
assert not tracker.take_over("cover.a", "ours", "user")
assert not tracker.take_over("cover.a", "other", None)
assert tracker.explains("cover.a", "other", "closing", 50, 1)
assert tracker.take_over("cover.a", "other", "user")
assert not tracker.explains("cover.a", "other", "closing", 50, 2)
12 changes: 10 additions & 2 deletions tests/shutter/logic/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,17 @@ def test_evening_run_for_window_not_in_vacation_simulation() -> None:
assert w.evening(replace(RULES, vacation=False), replace(EVENING, vacation=True))


def test_follow_up_closes_in_the_evening_regardless_of_override() -> None:
def test_follow_up_respects_override() -> None:
s = replace(EVENING, override=True, evening_marker=True)
assert kinds(w.follow_up(RULES, s, after_earliest=True))[0] == (w.POSITION, w.R_FOLLOW_UP, 0)
assert w.follow_up(RULES, s, after_earliest=True) == []
assert kinds(w.follow_up(replace(RULES, override_ignore_evening=True), s, after_earliest=True))[
0
] == (w.POSITION, w.R_FOLLOW_UP, 0)
assert kinds(w.follow_up(RULES, replace(s, override=False), after_earliest=True))[0] == (
w.POSITION,
w.R_FOLLOW_UP,
0,
)
assert w.follow_up(RULES, s, after_earliest=False) == []
assert w.follow_up(RULES, replace(s, evening=False), after_earliest=True) == []
assert w.follow_up(replace(RULES, follow_up_close=False), s, after_earliest=True) == []
Expand Down
Loading