How to "package" custom_components

As many of you, I’m facing deprecated custom component. I’m relatively new to Home Assistant architecture and Python. I would like some help to create the package for my spa custom_components.

The source code can be found there:

the custom component files structure is:

custom_components/climate/my_bwa.py
custom_components/light/my_bwa.py
custom_components/switch/my_bwa.py
custom_components/my_bwa.py
custom_components/spaclient.py

…where:

/climate/my_bwa.py *manage the spa temperature with importing homeassistant.components.climate
/light/my_bwa.py *manage the spa lights with importing homeassistant.components.light
/switch/my_bwa.py *manage the spa pumps with importing homeassistant.components.switch
my_bwa.py *initiate the network for establishing the communication with the spa
spaclient.py *interprets the communication string of the spa

So… As this is an interesting custom component to make working in the new Home Assistant way to integrate custom components, have you any clues from where I need ton start to create the package? To make it work properly in >0.89.

Thank-you for your support!

PL

You pretty much just put them all in the same folder:

custom_components/my_bwa/climate.py
custom_components/my_bwa/light.py
custom_components/my_bwa/switch.py
custom_components/my_bwa/__init__.py
custom_components/my_bwa/spaclient.py

Hmmm… that was too much easy!

What I missed was to rename custom_components/my_bwa.py to custom_components/my_bwa/__init__.py

I had to slightly adjust a statement in the __init__.py file.
from custom_components.**my_bwa**.spaclient import SpaClient

A big thank you for helping!

You should also be able to use something like

from .spaclient import SpaClient

I saw a change not too long ago where they moved all the components to use relative imports. The advantage is that if you were to submit this as a core component, you wouldn’t have to adjust the imports.

Awesome! I adjusted my statement!

Thanks!

Hi all,
I have the same issues but I’m not able to fix it.
My custom_components is this one:

I’ve already asked to Alber Lee @trisk to fix his custom component to fit with the great migration and he told me he did it moving the tree in this way, from this:

custom_components/relaymaster/binary_sensor/relaymaster.py
custom_components/relaymaster/sensor/relaymaster.py
custom_components/relaymaster/switch/relaymaster.py

to this:
custom_components/relaymaster/binary_sensor.py
custom_components/relaymaster/sensor.py
custom_components/relaymaster/switch.py

or this:
custom_components/switch.relaymaster/binary_sensor.py
custom_components/switch.relaymaster/sensor.py
custom_components/switch.relaymaster/switch.py

but it doesn’t work, the system tells me:
Integration relaymaster not found when trying to verify its switch platform.
Integration relaymaster not found when trying to verify its binary_sensor platform.
Integration relaymaster not found when trying to verify its sensor platform.

I put an empty init.py in the same folder like I red here:

but it doesn’t work anyway.
Is someone able to help me please?

thank you
Igor

Your final custom component files structure should look like:

custom_components/relaymaster/__init__.py
custom_components/relaymaster/binary_sensor.py
custom_components/relaymaster/sensor.py
custom_components/relaymaster/switch.py

The __init__.py file can be empty…

Hi thank you but I got exactly what you wrote:
custom_components/relaymaster/ __init__.py
custom_components/relaymaster/binary_sensor.py
custom_components/relaymaster/sensor.py
custom_components/relaymaster/switch.py
with the empty __init__.py
nut it doesn’t work and I still have this errors:
Integration relaymaster not found when trying to verify its switch platform.
Integration relaymaster not found when trying to verify its binary_sensor platform.
Integration relaymaster not found when trying to verify its sensor platform.

I have the same problem with a custom component. Seems like something changed in 0.92 that doesn’t allow for a custom component that isn’t already in HA. I have 2 cover components, one which is a fix for a component already in HA and it works. Another cover.py with the same folder structure as outlined above and an empty __init__.py file a manifest.json but always gets errors upon attempting to restart.

You at least have 2 out of 3 working, in my case, no one is working… and none is helping me.
I don’t know how to have my custom component working again

@igorguida Yeah I hear ya. The one that I most need was a component that no longer works and I haven’t had any response either. Have you raised an issue on Github?