Core: AttributeError: 'NoneType' object has no attribute '__file__'

Created on 15 Jan 2018  Â·  18Comments  Â·  Source: home-assistant/core

Home Assistant release (hass --version): 0.6.1
Python release (python3 --version): 3.6.3
Component/platform:switch.broadlink

Description of problem:
Something broke broadlink when i was updating HASS. Now, the webUI doesn't load and I see exceptions in the log from broadlink.

Expected:
WebUI should work as normal and no exceptions from broadlink should be there.

Problem-relevant configuration.yaml entries and steps to reproduce:

  1. Update to latest HASS. I also ran apt-get upgrade.
  2. Restart HASS. No errors on startup.
  3. Try to open WebUI, errors are seen now:
    a. Timer out of sync
    b. Unable to find component broadlink
    c. Attribute error

Traceback (if applicable):

ERROR:homeassistant.core:Timer got out of sync. Resetting
ERROR:homeassistant.loader:Unable to find component broadlink
ERROR:homeassistant.core:Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api.py", line 473, in get_services_helper
    descriptions = yield from async_get_all_descriptions(self.hass)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 153, in async_get_all_descriptions
    yaml_file = domain_yaml_file(domain)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 137, in domain_yaml_file
    component_path = path.dirname(get_component(domain).__file__)
AttributeError: 'NoneType' object has no attribute '__file__'

Additional info:
Things I've tried to fix this with no luck:

  1. Removing crypto and using AES instead. Installing both manually and using pip.
  2. Starting from a fresh HASSbian image.

Most helpful comment

I'm sure it is due to #11479 ... I can hopefully fix it tonight

All 18 comments

Paging Dr. @Danielhiversen

The Broadlink switch has not changed for months

This goes for snapcast aswell

Further findings by testing the python broadlink API in VENV and out of the VENV.

"import broadlink" works without error inside the VENV. Outside of the venv, it doesn't.

Tried installing broadlink outside of VENV but HASS still errors out.

Kind of confused why the broadlink API is being used outside of VENV.

Could it be the service.py helper? It was changed 8 days ago to lazily load service descriptions and the lines 137 and 153 from the exception/error were part of the commit.

https://github.com/home-assistant/home-assistant/commit/8267a21bfe74520c7c8e0a8e94114476106261d9
https://github.com/home-assistant/home-assistant/pull/11479

I'm sure it is due to #11479 ... I can hopefully fix it tonight

i can confirm the error that @mouth4war described (with HA 0.6.1 on os x 10.11.6 python 3.6.4).

Confirmed here as well.. hope for a quick fix.

Commenting out broadlink in configuration does not help.

Edit: Commenting out broadlink does make it start but still lots of timer got out of sync in the logs. Not sure what the edits @amelchio did does, so dont know if it is related and maybe part of a bigger problem than only the broadlink component?

@olskar Commenting out the broadlink switch part from the configuration file (and restarting) should be enough.

What errors did you get with broadlink commented?

i have 90% of my home working with broadlink switches... commenting it out is same as just turn off HA

I have a possible "fix" for this, Im nont sure what it does to the
component though

On Jan 15, 2018 20:01, "Dima Goltsman" notifications@github.com wrote:

i have 90% of my home working with broadlink switches... commenting it out
is same as just turn off HA

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/11654#issuecomment-357764411,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMaakiAISmrGBmaHP0uJRVq8xVpB2gCks5tK6B-gaJpZM4RePZx
.

@RyuzakiKK If I dont comment out broadlink I get this:

2018-01-15 20:06:02 ERROR (MainThread) [homeassistant.loader] Unable to find component broadlink 2018-01-15 20:06:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api.py", line 473, in get_services_helper descriptions = yield from async_get_all_descriptions(self.hass) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 153, in async_get_all_descriptions yaml_file = domain_yaml_file(domain) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 137, in domain_yaml_file component_path = path.dirname(get_component(domain).__file__) AttributeError: 'NoneType' object has no attribute '__file__' 2018-01-15 20:06:05 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

If I do comment it out, home assistant starts, but I get lots of "2018-01-15 20:10:42 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting" when I do something in home assistant. I think it is related to the changes @amelchio made, thats why i mentioned it

@amelchio hope you will find the solution soon.
The strange thing is that Broadlink sensor is working just fine at the same setup.

The problem is that switch.broadlink adds services like broadlink.send_packet_192_168_0_107 and the NoneType error is due to the domain mismatch (broadlink. is not switch.).

My fix will be the breaking change of renaming the services to their proper names, for example switch.broadlink_send_packet_192.168_0_107.

From quickly looking around, this issue seems to affect calendar.todoist, media_player.snapcast, sensor.mopar and obviously switch.broadlink.

Yea, you are right.
The temporal workaround is now to comment service registers in broadlink switches.

        hass.services.register(DOMAIN, SERVICE_LEARN + '_' +
                              ip_addr.replace('.', '_'), _learn_command)
        hass.services.register(DOMAIN, SERVICE_SEND + '_' +
                               ip_addr.replace('.', '_'), _send_packet)

Line 142-145 'homeassistant/components/switch/broadlink.py'

You will get working switches and automatization at least.

I tried fixing it with #11677. However, I do not use any of the affected platforms so if someone is able to test it, that would be great.

The "Timer got out of sync." errors are probably unrelated to this issue.

@amelchio can confirm that this has fixed two of the three errors (b and c). Still getting a timer sync error when loading UI but that could be something else. Will close this after a day of observing. Thanks!

The timer sync error is fixed by #11733. It is fairly harmless and can be ignored until 0.62 is released.

Was this page helpful?
0 / 5 - 0 ratings