within the integration python code I create an object like
myobj = async_track_time_change(..............
how do I cancel/remove the async tracking object from firing??
setting myobj = None
does nothing… the object still fires
within the integration python code I create an object like
myobj = async_track_time_change(..............
how do I cancel/remove the async tracking object from firing??
setting myobj = None
does nothing… the object still fires
You call the returned object, I.e. myobj()
.
I’d like to piggyback on that question:
While I can cancel the time tracking this way before the first time it fires, this doesn’t seem to work for me if it was executed at least once.
In my case I create a time tracker that I may cancel - if it fires, I get a notification. If I cancel it before the first notification, everything is fine, but if I get a notification, I get that notification every day at the same time, even if I cancel the time tracker.
Is that expected behavior? Can I still cancel the time tracking after the first execution?
Thanks.
Looks like I should be using async_track_point_in_time
instead. But I still think I should be able to cancel an async_track_time_change
after it fired.
I agree, you can create an issue in GitHub to initiate the discussion.
According to code pointer here (https://github.com/home-assistant/core/blob/9fd842825488d59aa4ccf6b805f1b828d72052aa/homeassistant/helpers/event.py#L1505) you have only reference to first incoming trigger and not consecutive ones.
Looking at the code, I feel like this should be working as expected. The returned unsub_pattern_time_change_listener
calls the variable time_listener
, which gets updated every time it fires …