nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
631 stars 41 forks source link

Switch doesn't turn off on scheduled time, log shows: "Task was destroyed but it is pending!" #233

Closed shlomki closed 1 year ago

shlomki commented 1 year ago

Checklist

Steps to Reproduce

  1. Set a schedule for a water boiler switch from "Switcher" to turn on and turn off after 1 hour (this is a normal switch entity in HA). This doesn't seem to happen with other switches.
  2. At this point - the schedule runs as expected.
  3. Wait a few days.

Expected behavior

Expected that the schedule would continue running as expected (turn on at a certain time and turn off after 1 hour).

Actual behavior

After a few days have passed with the schedule working properly, a day would come where the switch would turn on but never turns off. From that point, the switch wouldn't even turn on the next day, and more of the same error would appear in the logs.

An error appears in the log at the same time the switch was scheduled to turn off: 2022-12-10 18:15:00.024 ERROR (Recorder) [homeassistant] Error doing job: Task was destroyed but it is pending! 2022-12-10 18:15:00.064 ERROR (Recorder) [homeassistant] Error doing job: Task was destroyed but it is pending! 2022-12-10 18:15:00.075 ERROR (Recorder) [homeassistant] Error doing job: Task was destroyed but it is pending!

nielsfaber commented 1 year ago

This is not caused by scheduler. You would have gotten the same error when using a regular HA automation for operating the switch. It is probably caused by the integration which controls your switch entity. Please raise the issue in the HA core instead.

shlomki commented 1 year ago

Thanks for the reply, I will try to make an automation that does the same to see if it reproduces that way.

shlomki commented 1 year ago

Hey again @nielsfaber , I've been running this as an automation and it doesn't seem to happen at all. It turns on & off as expected and keeps working this way. The problem seems to be related to the scheduler component and not to HA Core. Are there any logs that I could turn on?

nielsfaber commented 1 year ago

You can enable debug logging by adding this to configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.scheduler: debug

You will need to restart HA afterwards.

When the timer is set you should see something like (this information is also visible in the properties of the switch entity):

DEBUG (MainThread) [custom_components.scheduler.timer] Timer of 9514a0 set for 2022-12-15 20:03:00+01:00

When the schedule triggers you should see something like:

Timer 9514a0 has reached slot 0 Schedule 9514a0 is triggered, proceed with actions Executing service switch.turn_on on entity switch.my_switch Finished execution of actions

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days