Custom Component Sample Not Working

Hi everyone,

I’ve spent the past 2 hours trying to get the custom component samples to work. I’ve read over https://home-assistant.io/developers/creating_components/ and https://home-assistant.io/cookbook/python_component_basic_state/. I’ve tried both of those samples. I’ve launched hass using the config flag to the config folder. I have a folder named “custom_components” in the same folder as the config file. When I launch hass, it doesn’t detect the custom component at all. I have no idea if this is an issue with outdated documentation or something else. How can I resolve this issue?

Inside custom_components directory there should be directories for each component type, and the components inside those directories. eg

ls -l /home/homeassistant/.homeassistant/custom_components total 36 drwxr-xr-x 3 homeassistant homeassistant 4096 Mar 3 19:24 binary_sensor drwxr-xr-x 3 homeassistant homeassistant 4096 Mar 3 19:24 light drwxr-xr-x 2 homeassistant homeassistant 4096 Mar 3 19:20 __pycache__ drwxr-xr-x 3 homeassistant homeassistant 4096 Mar 3 19:24 sensor drwxr-xr-x 3 homeassistant homeassistant 4096 Mar 3 19:24 switch

I created another folder names “other” under the custom components and placed the hello_service.py file in there. Ran hass and still no luck. hello_service does not appear under the dev tools. Below is what is in the hello service file:

import logging

_LOGGER = logging.getLogger(__name__)

# The domain of your component. Should be equal to the name of your component.
DOMAIN = 'hello_service'

ATTR_NAME = 'name'
DEFAULT_NAME = 'World'
DEPENDENCIES = []


def setup(hass, config):
    """Setup is called when Home Assistant is loading our component."""
	_LOGGER.info("The 'hello state" component is ready")!"

    def handle_hello(call):
        name = call.data.get(ATTR_NAME, DEFAULT_NAME)

        hass.states.set('hello_service.hello', name)

    hass.services.register(DOMAIN, 'hello', handle_hello)

    # Return boolean to indicate that initialization was successfully.
    return True

Seems you need to put it into a directory reflecting the type of component.
ie a sensor under custom_components/sensor etc