This commit is contained in:
J. Nick Koston
2022-05-04 16:07:17 -04:00
parent 5b4bfdee7d
commit 69d19dc008
2 changed files with 6 additions and 22 deletions

View File

@@ -38,7 +38,6 @@ from .const import (
CONF_CA_CERTS, CONF_CA_CERTS,
CONF_CERTFILE, CONF_CERTFILE,
CONF_KEYFILE, CONF_KEYFILE,
CONFIG_URL,
DOMAIN, DOMAIN,
LUTRON_CASETA_BUTTON_EVENT, LUTRON_CASETA_BUTTON_EVENT,
MANUFACTURER, MANUFACTURER,
@@ -243,6 +242,7 @@ def _async_subscribe_pico_remote_events(
type_ = device["type"] type_ = device["type"]
area, name = _area_and_name_from_name(device["name"]) area, name = _area_and_name_from_name(device["name"])
button_number = device["button_number"] button_number = device["button_number"]
# The original implementation used LIP instead of LEAP # The original implementation used LIP instead of LEAP
# so we need to convert the button number to maintain compat # so we need to convert the button number to maintain compat
sub_type_to_lip_button = DEVICE_TYPE_SUBTYPE_MAP_TO_LIP[type_] sub_type_to_lip_button = DEVICE_TYPE_SUBTYPE_MAP_TO_LIP[type_]
@@ -307,15 +307,13 @@ class LutronCasetaDevice(Entity):
self._device = device self._device = device
self._smartbridge = bridge self._smartbridge = bridge
self._bridge_device = bridge_device self._bridge_device = bridge_device
if "serial" not in self._device:
return
info = DeviceInfo( info = DeviceInfo(
identifiers={(DOMAIN, self.serial)}, identifiers={(DOMAIN, self.unique_id)},
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
model=f"{device['model']} ({device['type']})", model=f"{device['model']} ({device['type']})",
name=self.name, name=self.name,
via_device=(DOMAIN, self._bridge_device["serial"]), via_device=(DOMAIN, self._bridge_device["serial"]),
configuration_url=CONFIG_URL, configuration_url="https://device-login.lutron.com",
) )
area, _ = _area_and_name_from_name(device["name"]) area, _ = _area_and_name_from_name(device["name"])
if area != UNASSIGNED_AREA: if area != UNASSIGNED_AREA:

View File

@@ -6,14 +6,12 @@ from homeassistant.components.binary_sensor import (
BinarySensorEntity, BinarySensorEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_SUGGESTED_AREA
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice, _area_and_name_from_name from . import DOMAIN as CASETA_DOMAIN, LutronCasetaDevice
from .const import BRIDGE_DEVICE, BRIDGE_LEAP, CONFIG_URL, MANUFACTURER, UNASSIGNED_AREA from .const import BRIDGE_DEVICE, BRIDGE_LEAP
async def async_setup_entry( async def async_setup_entry(
@@ -45,19 +43,7 @@ class LutronOccupancySensor(LutronCasetaDevice, BinarySensorEntity):
def __init__(self, device, bridge, bridge_device): def __init__(self, device, bridge, bridge_device):
"""Init an occupancy sensor.""" """Init an occupancy sensor."""
super().__init__(device, bridge, bridge_device) super().__init__(device, bridge, bridge_device)
info = DeviceInfo( self._attr_device_info["entry_type"] = DeviceEntryType.SERVICE
identifiers={(CASETA_DOMAIN, self.unique_id)},
manufacturer=MANUFACTURER,
model=f"{device['model']} ({device['type']})",
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 @property
def device_class(self): def device_class(self):