mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +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):
|
||||
"""Register callbacks."""
|
||||
self._smartbridge.add_subscriber(
|
||||
self.device_id, self.async_schedule_update_ha_state
|
||||
)
|
||||
self._smartbridge.add_subscriber(self.device_id, self.async_write_ha_state)
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
@ -108,7 +106,7 @@ class LutronCasetaDevice(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""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
|
||||
|
||||
@property
|
||||
|
@ -17,14 +17,14 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Lutron Caseta shades as a cover device."""
|
||||
devs = []
|
||||
entities = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
cover_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||
for cover_device in cover_devices:
|
||||
dev = LutronCasetaCover(cover_device, bridge)
|
||||
devs.append(dev)
|
||||
entity = LutronCasetaCover(cover_device, bridge)
|
||||
entities.append(entity)
|
||||
|
||||
async_add_entities(devs, True)
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
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):
|
||||
"""Set up the Lutron Caseta lights."""
|
||||
devs = []
|
||||
entities = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
light_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||
for light_device in light_devices:
|
||||
dev = LutronCasetaLight(light_device, bridge)
|
||||
devs.append(dev)
|
||||
entity = LutronCasetaLight(light_device, bridge)
|
||||
entities.append(entity)
|
||||
|
||||
async_add_entities(devs, True)
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
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):
|
||||
"""Set up the Lutron Caseta lights."""
|
||||
devs = []
|
||||
entities = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
scenes = bridge.get_scenes()
|
||||
for scene in scenes:
|
||||
dev = LutronCasetaScene(scenes[scene], bridge)
|
||||
devs.append(dev)
|
||||
entity = LutronCasetaScene(scenes[scene], bridge)
|
||||
entities.append(entity)
|
||||
|
||||
async_add_entities(devs, True)
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class LutronCasetaScene(Scene):
|
||||
|
@ -10,15 +10,15 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up Lutron switch."""
|
||||
devs = []
|
||||
entities = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
switch_devices = bridge.get_devices_by_domain(DOMAIN)
|
||||
|
||||
for switch_device in switch_devices:
|
||||
dev = LutronCasetaLight(switch_device, bridge)
|
||||
devs.append(dev)
|
||||
entity = LutronCasetaLight(switch_device, bridge)
|
||||
entities.append(entity)
|
||||
|
||||
async_add_entities(devs, True)
|
||||
async_add_entities(entities, True)
|
||||
return True
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user