mirror of
https://github.com/home-assistant/core.git
synced 2025-05-04 14:09:16 +00:00

* Remove dependencies and requirements * Revert "Remove dependencies and requirements" This reverts commit fe7171b4cd30889bad5adc9a4fd60059d05ba5a7. * Remove dependencies and requirements * Revert "Remove dependencies and requirements" This reverts commit 391355ee2cc53cbe6954f940062b18ae34b05621. * Remove dependencies and requirements * Fix flake8 complaints * Fix more flake8 complaints * Revert non-component removals
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""Support for Lutron switches."""
|
|
import logging
|
|
|
|
from homeassistant.components.switch import SwitchDevice
|
|
|
|
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
|
"""Set up the Lutron switches."""
|
|
devs = []
|
|
for (area_name, device) in hass.data[LUTRON_DEVICES]['switch']:
|
|
dev = LutronSwitch(area_name, device, hass.data[LUTRON_CONTROLLER])
|
|
devs.append(dev)
|
|
|
|
add_entities(devs, True)
|
|
|
|
|
|
class LutronSwitch(LutronDevice, SwitchDevice):
|
|
"""Representation of a Lutron Switch."""
|
|
|
|
def turn_on(self, **kwargs):
|
|
"""Turn the switch on."""
|
|
self._lutron_device.level = 100
|
|
|
|
def turn_off(self, **kwargs):
|
|
"""Turn the switch off."""
|
|
self._lutron_device.level = 0
|
|
|
|
@property
|
|
def device_state_attributes(self):
|
|
"""Return the state attributes."""
|
|
attr = {}
|
|
attr['lutron_integration_id'] = self._lutron_device.id
|
|
return attr
|
|
|
|
@property
|
|
def is_on(self):
|
|
"""Return true if device is on."""
|
|
return self._lutron_device.last_level() > 0
|