Bootstrap.setup_component purpose

Hello everyone,

I’m working on a new component for the envisalink alarm panel (binary_sensor + alarm_control_panel). This is my first time making a platform + subcomponent- style component, and I’m struggling quite a bit with the section of code that nearly all platform-level components have in their setup() method:

component = get_component(comp_name)
bootstrap.setup_component(hass, component.DOMAIN, base_config),
{ATTR_SERVICE: discovery,

My understanding is that the “bootstrap.setup_component” should take care of setting up my embedded binary_sensors, right? So I don’t need to declare them in my configuration.yaml?

If my assumption is correct, my setup_platform in my binary_sensor/envisalink component never fires:
Is there something intricate i’m missing?

Right now if I explicitly have an envisalink: section AND a binary_sensor, platform: envisalink, everything works, but my understanding is that i shouldn’t have to do that, and if I have the two config sections (one for the whole envisalink platform + one for binary sensor) then I don’t understand the purpose of those 3 lines of code (often put into a for loop).

Can someone explain how this is supposed to work? Or maybe i need to edit a file somewhere else?


My setup looks a little something like this:
def setup(hass, base_config):
“”“Common setup for Vera devices.”""
from pyenvisalink import EnvisalinkAlarmPanel

config = base_config.get(DOMAIN)
host = config.get('host')
if not host:
        "The required parameter 'host'"
        " was not found in config"
    return False'****************SETUP PANEL***************')
EVL_CONTROLLER = EnvisalinkAlarmPanel(host)

def stop_subscription(event):
    """Shutdown Vera subscriptions and subscription thread on exit.""""Shutting down subscriptions.")

hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription)
component = get_component('binary_sensor')
bootstrap.setup_component(hass, component.DOMAIN, base_config)

and the setup_platform of the binary_sensor/envisalink looks like this:

def setup_platform(hass, config, add_devices_callback, discovery_info=None):’*****SETUP ZONES’)

    EnvisalinkBinarySensor(zoneNum, zone, EVL_CONTROLLER)
    for zoneNum, zone in enumerate(EVL_CONTROLLER.alarm_state['zone'], start=1))

Okay- nevermind I found it. I was missing some entries in /components/binary_sensor/

I still think this was very challenging to figure out- I think this would need to be explained better in the developer documentation- I can make a start at it, but it may be better coming from someone with more experience!

Hi Cinntax,

You should try to use components.discovery.load_platform for sub component discovery. In this case there is no need to add that Discovery_platform strings in the init files

It should be in the latest dev branch

Cheers, JK

Oh great thanks! I see how you used it in the qwikswitch component… nice and clean. I’ll switch over if it’s the path forward.

Thanks, there should be some docs for it in ‘next’ as well :wink: