Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lutron_caseta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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):
Expand Down
56 changes: 56 additions & 0 deletions homeassistant/components/lutron_caseta/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 2 additions & 2 deletions homeassistant/components/lutron_caseta/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down