Add support for occupancy/vacancy groups in Lutron Caseta component (#33032)
* Add support for Lutron Caseta occupancy/vacancy sensors This follows updates to pylutron-caseta to add support for these devices. This code works for me as a custom component in Home Assistant Core with pylutron-caseta 0.6.0 (currently unreleased). * black formatting * Update requirements_all.txt * Apply black formatting * Resolve some review comments * serial -> unique_id * Black formatting * Resolve linting errors * Add code owner... * Fix isort complaint * Fix remaining isort complaints * Update codeowners * Resolve outstanding review comments * Remove caseta_
This commit is contained in:
parent
b09a9fc81a
commit
49ebea2be3
5 changed files with 61 additions and 4 deletions
|
@ -211,6 +211,7 @@ homeassistant/components/luci/* @fbradyirl @mzdrale
|
|||
homeassistant/components/luftdaten/* @fabaff
|
||||
homeassistant/components/lupusec/* @majuss
|
||||
homeassistant/components/lutron/* @JonGilmore
|
||||
homeassistant/components/lutron_caseta/* @swails
|
||||
homeassistant/components/mastodon/* @fabaff
|
||||
homeassistant/components/matrix/* @tinloaf
|
||||
homeassistant/components/mcp23017/* @jardiamj
|
||||
|
|
|
@ -33,7 +33,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
LUTRON_CASETA_COMPONENTS = ["light", "switch", "cover", "scene", "fan"]
|
||||
LUTRON_CASETA_COMPONENTS = ["light", "switch", "cover", "scene", "fan", "binary_sensor"]
|
||||
|
||||
|
||||
async def async_setup(hass, base_config):
|
||||
|
|
56
homeassistant/components/lutron_caseta/binary_sensor.py
Normal file
56
homeassistant/components/lutron_caseta/binary_sensor.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
"""Support for Lutron Caseta Occupancy/Vacancy Sensors."""
|
||||
from pylutron_caseta import OCCUPANCY_GROUP_OCCUPIED
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
BinarySensorDevice,
|
||||
)
|
||||
|
||||
from . import LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Lutron Caseta lights."""
|
||||
entities = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
occupancy_groups = bridge.occupancy_groups
|
||||
for occupancy_group in occupancy_groups.values():
|
||||
entity = LutronOccupancySensor(occupancy_group, bridge)
|
||||
entities.append(entity)
|
||||
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class LutronOccupancySensor(LutronCasetaDevice, BinarySensorDevice):
|
||||
"""Representation of a Lutron occupancy group."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Flag supported features."""
|
||||
return DEVICE_CLASS_OCCUPANCY
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the brightness of the light."""
|
||||
return self._device["status"] == OCCUPANCY_GROUP_OCCUPIED
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
self._smartbridge.add_occupancy_subscriber(
|
||||
self.device_id, self.async_write_ha_state
|
||||
)
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
"""Return the device ID used for calling pylutron_caseta."""
|
||||
return self._device["occupancy_group_id"]
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier."""
|
||||
return f"occupancygroup_{self.device_id}"
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {"device_id": self.device_id}
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "lutron_caseta",
|
||||
"name": "Lutron Caseta",
|
||||
"documentation": "https://www.home-assistant.io/integrations/lutron_caseta",
|
||||
"requirements": ["pylutron-caseta==0.5.1"],
|
||||
"requirements": ["pylutron-caseta==0.6.0"],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
"codeowners": ["@swails"]
|
||||
}
|
||||
|
|
|
@ -1364,7 +1364,7 @@ pylitejet==0.1
|
|||
pyloopenergy==0.1.3
|
||||
|
||||
# homeassistant.components.lutron_caseta
|
||||
pylutron-caseta==0.5.1
|
||||
pylutron-caseta==0.6.0
|
||||
|
||||
# homeassistant.components.lutron
|
||||
pylutron==0.2.5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue