mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix lutron caseta occupancy sensors (#71309)
* Fix lutron_caseta occupancy sensors * Fix lutron_caseta occupancy sensors * Make as service since its a group * merge * Revert "merge" This reverts commit 69d19dc0088bd1b3483cfc481ed2f72e49599cf8. * model and type not present
This commit is contained in:
parent
5a5cde690f
commit
7be5eed25c
@ -38,6 +38,7 @@ from .const import (
|
||||
CONF_CA_CERTS,
|
||||
CONF_CERTFILE,
|
||||
CONF_KEYFILE,
|
||||
CONFIG_URL,
|
||||
DOMAIN,
|
||||
LUTRON_CASETA_BUTTON_EVENT,
|
||||
MANUFACTURER,
|
||||
@ -306,13 +307,15 @@ class LutronCasetaDevice(Entity):
|
||||
self._device = device
|
||||
self._smartbridge = bridge
|
||||
self._bridge_device = bridge_device
|
||||
if "serial" not in self._device:
|
||||
return
|
||||
info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.serial)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=f"{device['model']} ({device['type']})",
|
||||
name=self.name,
|
||||
via_device=(DOMAIN, self._bridge_device["serial"]),
|
||||
configuration_url="https://device-login.lutron.com",
|
||||
configuration_url=CONFIG_URL,
|
||||
)
|
||||
area, _ = _area_and_name_from_name(device["name"])
|
||||
if area != UNASSIGNED_AREA:
|
||||
|
@ -6,11 +6,14 @@ from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_SUGGESTED_AREA
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice
|
||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP
|
||||
from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice, _area_and_name_from_name
|
||||
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, CONFIG_URL, MANUFACTURER, UNASSIGNED_AREA
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
@ -39,6 +42,23 @@ async def async_setup_entry(
|
||||
class LutronOccupancySensor(LutronCasetaDevice, BinarySensorEntity):
|
||||
"""Representation of a Lutron occupancy group."""
|
||||
|
||||
def __init__(self, device, bridge, bridge_device):
|
||||
"""Init an occupancy sensor."""
|
||||
super().__init__(device, bridge, bridge_device)
|
||||
info = DeviceInfo(
|
||||
identifiers={(CASETA_DOMAIN, self.unique_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model="Lutron Occupancy",
|
||||
name=self.name,
|
||||
via_device=(CASETA_DOMAIN, self._bridge_device["serial"]),
|
||||
configuration_url=CONFIG_URL,
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
)
|
||||
area, _ = _area_and_name_from_name(device["name"])
|
||||
if area != UNASSIGNED_AREA:
|
||||
info[ATTR_SUGGESTED_AREA] = area
|
||||
self._attr_device_info = info
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Flag supported features."""
|
||||
@ -65,16 +85,6 @@ class LutronOccupancySensor(LutronCasetaDevice, BinarySensorEntity):
|
||||
"""Return a unique identifier."""
|
||||
return f"occupancygroup_{self.device_id}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info.
|
||||
|
||||
Sensor entities are aggregated from one or more physical
|
||||
sensors by each room. Therefore, there shouldn't be devices
|
||||
related to any sensor entities.
|
||||
"""
|
||||
return None
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
@ -35,3 +35,5 @@ CONF_SUBTYPE = "subtype"
|
||||
BRIDGE_TIMEOUT = 35
|
||||
|
||||
UNASSIGNED_AREA = "Unassigned"
|
||||
|
||||
CONFIG_URL = "https://device-login.lutron.com"
|
||||
|
Loading…
x
Reference in New Issue
Block a user