Home Assistant Community

Updade to 0.93.1 causes `homeassistant.loader.get_component` breaking change?


I wrote this component a while ago and having trouble migrating it to the new layout in 0.93.

I created the directory layout to match the example_load_platform one and added a manifest.json file. The directory looks like this:



  "domain": "processor",
  "name": "Processor",
  "documentation": "https://www.example.com",
  "dependencies": ["mqtt"],
  "codeowners": [],
  "requirements": []

You can find the source code for the files above in the Github repository.

I read the release 0.93 notes and release 0.92 notes which mention the following:

  • Load requirements and dependencies from manifests - Developers - Setup entity platform will set up its component now despite DEPENDENCIES. (@rohankapoorcom - #22717)

I thought adding the manifest file as I did above would fix the problem
I am not getting any useful error in the logs (even when setting the logger component to debug.
All it says is that the mqtt_code integration cannot be found.
Are there any breaking changes with homeassistant.loader's get_component method? That throws an error as well.

I didn’t think the migration would require a change in source code, other than moving and renaming files around.

The configuration looks like this:

  - platform: mqtt_code
    topic: /rf/all
    callback_script: script.buzz_short
    event: True
      - name: Black Button 
        type: panel
            payload: 1870753
                - service: fan.toggle
                  entity_id: fan.bedroom_fan

The last known working version is 0.91.3 (before the big migration in 0.92 of course).
I upgraded one version at a time and resolved all warnings in the logs before moving to next version. I am now at a point where the migration problems are resolved. However, there seems to be an undocumented breaking change to homeassistant.loader

2019-05-21 17:44:16 ERROR (MainThread) [custom_components.processor] Error while setting up platform mqtt_code
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mqtt_code/processor.py", line 40, in setup_platform
    mqtt = loader.get_component(hass, 'mqtt')
AttributeError: module 'homeassistant.loader' has no attribute 'get_component'

Any idea why this would stop working in 0.93?

import homeassistant.loader as loader
import logging
import asyncio
from datetime import datetime,  timedelta, date, time
from homeassistant.helpers.entity import Entity
from custom_components.processor import ProcessorDevice
from homeassistant.util import dt
from homeassistant.core import HomeAssistant as hass
from homeassistant.components.script import ScriptEntity
from homeassistant.loader import bind_hass
import homeassistant.helpers.script as script 
from custom_components.processor.yaml_scheduler import Action, Scheduler, TimeSchedule, Mapping
# from datetimerange import DateTimeRange

VERSION = '1.0.1'

# REQUIREMENTS = ['datetimerange']
CONF_TOPIC = 'topic'
ACTION_ON = 'on'
ACTION_OFF = 'off'
DEFAULT_ACTION = 'default'
_LOGGER = logging.getLogger(__name__)

def setup_platform(hass, config, add_entities, discovery_info=None):
    entities = []

    mqtt = loader.get_component(hass, 'mqtt')
    topic = config.get('topic', DEFAULT_TOPIC)
    _LOGGER.info("Platform Config:" + str(config))