Parsing config from YAML

Hi. I need some help in how to parse data from yaml.

My YAML configurations.yaml entry:

switch:
  - platform: maxsmart
    name: TV1
    host: maxsmart-tv1
    ports: 6
    outlets:
      1: Ampli TV
      4: nVidia Shield

I want to have in my components:

outlet 1 name = ampli TV
outlet 2 name = outlet 2
outlet 3 name = outlet 3
outlet 4 name = nVidia Shield
outlet 5 name = outlet 5
outlet 6 name = outlet 6

Can anyone give me directions ? I got how to parse name, home and ports value out from config file, but not outlets numbers and name.

Currently, the class starts as follow in the python component file. I need the outlet number and name to populate corretly the switch details.

class SmartSwitch(SwitchDevice):
    """Representation of a single outlet"""

    def __init__(self, host, name, number):
        """Initialize the switch."""

        self._host = host
        self._name = name
        self._number = number
        self._now_power = 0.0
        self._now_amp = 0.0
        self._state = False

What’s the overall goal here?

The overall goal is to create an entity for each outlet, named after the provided name, or a default name is none is provided for the socket. The device is a 1 or 6 outlet power strip (hence the “ports” value which set the number of outlet). In my example above, the maxsmart platform is a power strip (or plug), the name of the device (TV1), the host (hostname of the device (could be an IP), ports is the number of outlets (defined earlier in the script, and this works fine). The original script I modify is revogi.py

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the outlets."""

    dev = []

    number_outlets = config.get(CONF_PORTS) # MaxSmart Power Strip EU
    for number in range(1, number_outlets+1):
        dev.append(SmartSwitch(
            config.get(CONF_HOST),
            config.get(CONF_NAME),
            number))

    add_devices(dev)

class SmartSwitch(SwitchDevice):
    """Representation of a single outlet"""

    def __init__(self, host, name, number):
        """Initialize the switch."""

        self._host = host
        self._name = name
        self._number = number
        self._now_power = 0.0
        self._now_amp = 0.0
        self._state = False

I have created a GIT with the files I’m working on.

Can anyone give it an eye and help me on on how to parse the name of the outlets ?