Home / Home Assistant Custom Component Upgrade Guide for v0.93
Home Assistant Integrations

Home Assistant Custom Component Upgrade Guide for v0.93

Home Assistant introduced major breaking changes in release 0.93, with the addition of manifest files and a restructured folder layout. This caused some of my components to break very badly and I spent too much time attempting to fix them.

Directory Layout Change (before migration)

custom_components/
  mycomp/
    __init__.py
    myplatform.py

Directory Layout Change (after migration)

custom_components/
  mycomp/
    __init__.py
    manifest.json     (new file)
  myplatform/
    __init__.py       (new empty file containing doc string)
    processor.py      (myplatform.py renamed)

The second item that caused problems for me is the fact my component uses loader.get_component to load the mqtt component (in order to subscribe to topics). The correct way to use other components from within your own component is to simply import it. loader.get_component was removed in 0.92. Cheeky.

Using other components from your custom component (before migration)

import homeassistant.loader as loader
mqtt = loader.get_component(hass, 'mqtt')

Using other components from your custom component (after migration)

from homeassistant.components import mqtt
# This line can be removed completely.
# mqtt = loader.get_component(hass, 'mqtt')

Advise when fixing broken components

Once you know your component/s are broken, go back to the last known, working version of Home Assistant and check the logs carefully for deprecation warnings. Action and fix all deprecation warnings and make sure the component still works as intended. Only then update to the next patch version, making sure your cmoponent continues to work. This way you will figure out exactly which version broke it and you can fix any deprecation warnings along the way as well. If something breaks without a warning, check the breaking changes section in the release notes carefully.

Finally

My MQTT Payload Processor is a critical component in my home automation system because it handles all the translation of device specific RF codes into easy-to-consume home assistant events.

I spent 4 hours resolving this, and learned a lot about the new component architecture and myself along the way. My desperate post on the Home Assistant forum received no attention unfortunately.

Continue your adventure here

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

DON’T MISS OUT!
Subscribe To Newsletter
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Give it a try, you can unsubscribe anytime.
close-link