hass-core/homeassistant/components/pilight/switch.py
Trekky12 5ed1f16f25 Add pilight dimmer as light component (#30107)
* Add pilight dimmer as light component

* fix CI errors

* fix missing new lines

* improve formatting and addresses comments of @springstan

* rename config parameter and remove super() call to match pylint

* import only used constants of the pilight component

* Add myself to the code owners

* fix CODEOWNERS
2020-01-06 20:13:08 -05:00

31 lines
912 B
Python

"""Support for switching devices via Pilight to on and off."""
import logging
import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
from homeassistant.const import CONF_SWITCHES
import homeassistant.helpers.config_validation as cv
from .base_class import SWITCHES_SCHEMA, PilightBaseDevice
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{vol.Required(CONF_SWITCHES): vol.Schema({cv.string: SWITCHES_SCHEMA})}
)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Pilight platform."""
switches = config.get(CONF_SWITCHES)
devices = []
for dev_name, dev_config in switches.items():
devices.append(PilightSwitch(hass, dev_name, dev_config))
add_entities(devices)
class PilightSwitch(PilightBaseDevice, SwitchDevice):
"""Representation of a Pilight switch."""