mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
General code cleanups for lutron_caseta component (#33144)
* General code cleanups for lutron_caseta component * black * Update homeassistant/components/lutron_caseta/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
ca3a22b5a3
commit
2a3d688923
@ -81,9 +81,7 @@ class LutronCasetaDevice(Entity):
|
|||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
self._smartbridge.add_subscriber(
|
self._smartbridge.add_subscriber(self.device_id, self.async_write_ha_state)
|
||||||
self.device_id, self.async_schedule_update_ha_state
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_id(self):
|
def device_id(self):
|
||||||
@ -108,7 +106,7 @@ class LutronCasetaDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attr = {"Device ID": self.device_id, "Zone ID": self._device["zone"]}
|
attr = {"device_id": self.device_id, "zone_id": self._device["zone"]}
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -17,14 +17,14 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up the Lutron Caseta shades as a cover device."""
|
"""Set up the Lutron Caseta shades as a cover device."""
|
||||||
devs = []
|
entities = []
|
||||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||||
cover_devices = bridge.get_devices_by_domain(DOMAIN)
|
cover_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
for cover_device in cover_devices:
|
for cover_device in cover_devices:
|
||||||
dev = LutronCasetaCover(cover_device, bridge)
|
entity = LutronCasetaCover(cover_device, bridge)
|
||||||
devs.append(dev)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(devs, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
|
class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
|
||||||
|
@ -25,14 +25,14 @@ def to_hass_level(level):
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up the Lutron Caseta lights."""
|
"""Set up the Lutron Caseta lights."""
|
||||||
devs = []
|
entities = []
|
||||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||||
light_devices = bridge.get_devices_by_domain(DOMAIN)
|
light_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
for light_device in light_devices:
|
for light_device in light_devices:
|
||||||
dev = LutronCasetaLight(light_device, bridge)
|
entity = LutronCasetaLight(light_device, bridge)
|
||||||
devs.append(dev)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(devs, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class LutronCasetaLight(LutronCasetaDevice, Light):
|
class LutronCasetaLight(LutronCasetaDevice, Light):
|
||||||
|
@ -10,14 +10,14 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up the Lutron Caseta lights."""
|
"""Set up the Lutron Caseta lights."""
|
||||||
devs = []
|
entities = []
|
||||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||||
scenes = bridge.get_scenes()
|
scenes = bridge.get_scenes()
|
||||||
for scene in scenes:
|
for scene in scenes:
|
||||||
dev = LutronCasetaScene(scenes[scene], bridge)
|
entity = LutronCasetaScene(scenes[scene], bridge)
|
||||||
devs.append(dev)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(devs, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class LutronCasetaScene(Scene):
|
class LutronCasetaScene(Scene):
|
||||||
|
@ -10,15 +10,15 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up Lutron switch."""
|
"""Set up Lutron switch."""
|
||||||
devs = []
|
entities = []
|
||||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||||
switch_devices = bridge.get_devices_by_domain(DOMAIN)
|
switch_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||||
|
|
||||||
for switch_device in switch_devices:
|
for switch_device in switch_devices:
|
||||||
dev = LutronCasetaLight(switch_device, bridge)
|
entity = LutronCasetaLight(switch_device, bridge)
|
||||||
devs.append(dev)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(devs, True)
|
async_add_entities(entities, True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user