Skip to content

Commit ca34471

Browse files
docs(octopus): explain why a Smart Control change is always sent, and count four car entities (#5341 review)
The switch handler sends SUSPEND/UNSUSPEND even when the switch already shows that state: the cached device state can be up to a poll old, so skipping the call could drop a real change made in the Octopus app just before. The build_discovery docstring now lists four car entities, and a leftover smart_control_confirmed line is removed from the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1ec5f67 commit ca34471

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎apps/predbat/octopus.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,9 @@ async def async_set_intelligent_smart_control(self, device_id, enabled):
12301230
"""
12311231
Turn Octopus Smart Control on (UNSUSPEND) or off (SUSPEND) for an intelligent device, and show it on the switch
12321232
once Octopus accepts it. If Octopus rejects it the switch is left as it was.
1233+
1234+
It is sent even when the device already shows the asked-for state: that state can be up to a poll old, so
1235+
skipping it could drop a change the user really asked for.
12331236
"""
12341237
device = self.intelligent_devices.get(device_id)
12351238
if not device:
@@ -1653,9 +1656,9 @@ def build_discovery(self):
16531656
16541657
One `cars` record per ACTIVE (non-suspended) intelligent device: get_active_intelligent_device_ids()
16551658
is the exact filter automatic_config() itself applies when wiring the car slots into
1656-
apps.yaml, so the catalogue never lists a slot that is no longer being wired. Its three
1657-
entities (octopus_intelligent_slot, octopus_ready_time, octopus_charge_limit - see
1658-
OCTOPUS_CAR_ENTITY_SPEC) are included only when they actually exist in the state store:
1659+
apps.yaml, so the catalogue never lists a slot that is no longer being wired. Its four
1660+
entities (octopus_intelligent_slot, octopus_intelligent_smart_control, octopus_ready_time,
1661+
octopus_charge_limit - see OCTOPUS_CAR_ENTITY_SPEC) are included only when they actually exist in the state store:
16591662
async_intelligent_update_sensor() publishes them per device, never as a fixed set, so the
16601663
catalogue must not claim one exists that Home Assistant has never seen. Vehicle battery
16611664
size and charge-point power are reported in ratings where Octopus's own vehicle/charger

‎apps/predbat/tests/test_octopus_smart_control_switch.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ async def _switch_back_on_while_sending(query, *args, **kwargs):
175175

176176
print("Test 6: events for other entities, other services and unknown devices are ignored")
177177
api.commands = []
178-
api.smart_control_confirmed = {}
179178
await api.switch_event("switch.predbat_octopus_acc_1_something_else_1001", "turn_off")
180179
await api.switch_event(active_switch, "bogus")
181180
await api.switch_event(api.get_entity_name("switch", "intelligent_smart_charge", index="9999"), "turn_off")

0 commit comments

Comments
 (0)