Can't make a simple example work

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

├── custom_components
│   └── ezplug
│       ├──
│       ├── manifest.json
│       └── file:

import logging
DOMAIN = "ezplug"

_LOGGER = logging.getLogger(__name__)

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

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

from homeassistant.components.switch import SwitchEntity
import logging

_LOGGER = logging.getLogger(__name__)

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

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

    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):"Setting up virtual switch")
    return True

M\y configuration.yaml:

  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 script is never even executed.
Am I forgetting something or what’s the problem?

  platform: ezplug
1 Like