Help with initial development of custom components

Hi all,
I’m learning about creating custom components for HASS.

Reading the documentation online, I started creating the example sensor reported here:

So I put the custome sensor in the folder .homeassistant\custom_components\sensor and I add it to the configuration with:

- platform: example
  name: sensor_custom_example

Now I’m trying to add it to a group I use as test, called “Room 1” where I put other sensor I’m testing. So I wrote:

    view: yes
    name: "Room 1"
      - group.room_1
      - sensor.sensor_custom_example

Configuration seems ok, HASS start correctly, but I cannot see anything in the tab “Room 1”.
What’s wrong?

Does your component show up in the state tab?

Keep in mind: File name = Platform name

No, I can’t see it.
I think I’m doing something wrong, but I cannot understand what. Does component require an UI or something to be displayed? I created only the file right now.

What do you mean? As I understand reading documentation the filename will be the platform type/name of the component, so will be:

- platform: example

Should the component name be the same too? Something like:

- platform: example
  name: example


- platform: example

looks ok. Sorry, I was irritated by the indent.

The “Developer Tools” could help to determine the name of the entity if something went wrong.

I cannot see my sensor neither using Developer Tools. Seems ignored by HASS, I don’t understand why

Did you check the logs?

Yep, I didn’t see any reference to my custom sensor.

I was able to create a custom component by creating a python file in /custom_components. I noticed you have your file in custom_components/sensor. Here is the code I used:

The "hello world" custom component.

This component implements the bare minimum that a component should implement.


To use the hello_word component you will need to add the following to your
configuration.yaml file.


# The domain of your component. Should be equal to the name of your component.
DOMAIN = "hello_world"

# List of component names (string) your component depends upon.

def setup(hass, config):
    """Setup our skeleton component."""
    # States are in the format DOMAIN.OBJECT_ID.
    hass.states.set('hello_world.Hello_World', 'Works!')

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

I’ll try your code asap.
As far I understand this way you create a new “domain” right?
What about if I want to simply create a custom sensor? (so domain should reamain “sensor”)