Can't make a simple example work

Hi.
I’m trying to create a custom integration and I was trying out some examples.

config
├── custom_components
│   └── ezplug
│       ├── __init__.py
│       ├── manifest.json
│       └── switch.py

__init__.py file:

import logging
DOMAIN = "ezplug"

_LOGGER = logging.getLogger(__name__)

def setup(hass, config):
    hass.states.set("ezplug.integration", "Ready")

    _LOGGER.info("EZPLUG Ready!")

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

switch.py file:

from homeassistant.components.switch import SwitchEntity
import logging

_LOGGER = logging.getLogger(__name__)

class MySwitch(SwitchEntity):
    def __init__(self):
        self._is_on = False

    @property
    def name(self):
        """Name of the entity."""
        return "My Switch"

    @property
    def is_on(self):
        """If the switch is currently on or off."""
        return self._is_on

    def turn_on(self, **kwargs):
        """Turn the switch on."""
        self._is_on = True

    def turn_off(self, **kwargs):
        """Turn the switch off."""
        self._is_on = False

def setup_platform(hass, config, add_devices, discovery_info=None):
    _LOGGER.info("Setting up virtual switch")
    add_devices([MySwitch()])
    return True

M\y configuration.yaml:

ezplug:
  platform: switch

Apparently this is supposed to create a “fake” switch in Home Assistant, but the only entity it creates is ezplug.integration. There is no “My Switch” or anything like that.
I’ve seen that in a lot of examples setup_platform is defined before the custom class (in this case MySwitch), but I don’t think it matters. In fact, isn’t it better if the custom class is defined before it’s used?
I can see “EZPLUG Ready!” in the logs, but not “Setting up virtual switch”, so the switch.py script is never even executed.
Am I forgetting something or what’s the problem?

switch:
  platform: ezplug
1 Like