0.103: Unable to import timer component

I started 0.103.0 (docker), on my test system, and it reported that it cannot setup timers (confirmed; no timers are created). Is anyone else experiencing this issue?

The log’s message indicates the timer component could not be imported (from the docker version of 0.103.0):

Setup failed for timer: Unable to import component

Here’s the persistent notification generated at startup:

Screenshot from 2019-12-12 09-15-10

The following timer configuration was valid in all previous versions I’ve used, right up to 0.102.0.

    duration: '00:30:00'
    duration: '00:01:10'
    duration: '00:02:15'
    duration: 300

I didn’t see anything related to timers in the release notes nor recent changes to its documentation.

Bug or user error?

Hi Taras,
i can only say that i have no problems with timer with hassio running on ubuntu.
Upgraded 10min ago.

Just saw parallel topic… 0.103 - Undocumented Breaking Change?

Maybe quotes will help you too?

duration: ‘300’

Thanks. So the issue is not present in the hass.io version and possibly limited to the docker version (or user error).

Adding quotes didn’t help. It doesn’t appear to be a configuration error but a deeper problem: the entire timer component is unavailable.

One more clue, after running Config Check it reports:

Component error: timer - cannot import name ‘ENTITY_SERVICE_SCHEMA’ from ‘homeassistant.helpers.config_validation’ (/usr/src/homeassistant/homeassistant/helpers/config_validation.py)

That’s not complaining about a problem in my configuration file but, if I’m interpreting it correctly, it’s missing some fundamental piece it needs to perform validation (of timers).

Just used the console in Portainer to inspect the contents of the Home Assistant container and the timer component is present.

Maybe this isn’t about the timer component’s code being present but some ‘pointer’ failing to reference it? :man_shrugging:

I just searched the whole code base and I did not find ENTITY_SERVICE_SCHEMA anywhere. Is it possible you have something in /config or /config/custom_components or some subfolder named timer.py or a directory named timer?

I think I found the issue. A PR recorded 10 days ago performed a restructuring of helpers/config_validation.py.

Here’s the relevant history (it replaced ENTITY_SERVICE_SCHEMA, in many files, with something else):

So did you somehow only get part of that PR??? Along with changing config_validation.py it also changed the timer code, along with a lot of other files.

Beats me. I’m using the 0.103.0 “latest” docker container so it’s not likely I’m running a mangled instance; I have everything they chose to include in the container when it was built.

Posted it as an Issue in Github: 29885

I just upgraded my HA in docker to 103 and have exactly the same error.

Downgrading to 102.2 fixed it.

I added my input to the bug report.

Are those bugs not getting addressed due to the holidays? We usually have a few minor version/bug fixes by now so when there weren’t any I thought that I could safely update.

I’m not counting on any corrections to materialize until early January.

I’ve resolved the problem (at least in my case).

I decided to upgrade to 0.103.2. The problem persisted.

However, while running:

docker-compose up

on my test system (which displays its log on the command-line) I happened to notice the following message (one of the first to be reported upon startup):

INFO (SyncWorker_0) [homeassistant.config] Upgrading configuration directory from 0.103.0 to 0.103.2
(SyncWorker_2) [homeassistant.loader] Loaded timer from custom_components.timer
INFO (SyncWorker_8) [homeassistant.loader] Loaded my_mqtt from custom_components.my_mqtt

There it is, a custom timer component, whose source-code sits in a directory created November 4th. I must have been tinkering with it at the time (this is on my test system) and completely forgot about it.

I moved the custom_components\timer directory elsewhere (out of Home Assistant’s reach), restarted Home Assistant, and the (stock) timer component is loaded without complaint. All my timer entities are present.

I’m guessing the version of the timer’s source-code I had (in the custom_component) predated recent changes and is incompatible.

It’s strange but I don’t recall seeing the usual warning message (on the Log page) about having a custom timer component. Nevertheless, it’s definitely in the main log. :man_shrugging:

Check your system and let me know if you also have a custom timer component. If you do, I’ll close out the Issue on GitHub.

1 Like

Hmm, I never would have thought of that…

Oh, I did. :wink:

Here’s the culprit in the (old) timer’s source-code:

from homeassistant.helpers.config_validation import ENTITY_SERVICE_SCHEMA

So when ENTITY_SERVICE_SCHEMA was re-engineered it broke any custom_component that relied on it.

I’m currently waiting on a response from finity and another person (who commented in the GitHub issue) who reported a similar issue with utility_meter. I’m guessing they also have a custom_component version of it.

Well, whaddaya know… I have a timer custom component from around the same time.

I removed it and updated once again to v103 and it worked!

Isn’t that strange that we both had the same custom component from the same time frame.

I usually pout all references to any custom components (even the ones that override already existing core components) in a “custom_components” package so I always know if I’m using a custom version of something and where it came from. In this case I didn’t have any “timer:” entries in that file. Now I guess I have to figure out where that component came from and decide if I’m using any functionality in the custom thing that isn’t in the base component.

Thanks for that great find!

EDIT: I found it.

it’s from this repo: https://github.com/e2m32/hass_custom_timer

based on this thread: Resume timers after reboot

I recall I had created an automation-based solution to restore interrupted timers but forgot I also installed and tested gremblin’s custom timer component … and then left it in place where it remained forgotten … until 0.103 made an ‘oblique reference to it’. :slight_smile:

I’m satisfied this is the cause of the error message. However, I’ll wait a day or two for the other person to confirm they are using custom version of utility_meter before I close out the GitHub issue.

@finity just brought this to my attention (thank you again). I am using my custom timer on my main system currently with no issues in 0.102.2.

You said that you had this issue in 0.102? I’ll have to test the custom timer in 0.103 on my dev build. I am running in Hass.io, that shouldn’t make a difference… but you’re running in a docker container right?

If your code is still doing this:

from homeassistant.helpers.config_validation import ENTITY_SERVICE_SCHEMA

then it won’t work in 0.103.X because of PR29178 (I posted all the details earlier).

1 Like

Thank you. I just updated my dev build to 0.103.2 and I got that error.