Skip to content

Commit

Permalink
fix: state trigger working correctly on consequetive executions
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed May 3, 2024
1 parent 8daf8c8 commit ec631ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/powercalc/strategy/playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async def activate_playbook(self, playbook_id: str) -> None:

_LOGGER.debug("Activating playbook %s", playbook_id)
playbook = await self._load_playbook(playbook_id=playbook_id)
playbook.queue.reset()
self._active_playbook = playbook
self._start_time = dt.utcnow()

Expand Down
10 changes: 10 additions & 0 deletions tests/strategy/test_playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ async def test_state_trigger(hass: HomeAssistant) -> None:

await elapse_and_assert_power(hass, 1, "0.10")

hass.states.async_set("media_player.sonos", STATE_IDLE)
await hass.async_block_till_done()

await elapse_and_assert_power(hass, 2, "5.00")

hass.states.async_set("media_player.sonos", STATE_OFF)
await hass.async_block_till_done()

await elapse_and_assert_power(hass, 1, "0.10")


async def elapse_and_assert_power(
hass: HomeAssistant,
Expand Down

0 comments on commit ec631ac

Please sign in to comment.