diff --git a/custom_components/hubitat/binary_sensor.py b/custom_components/hubitat/binary_sensor.py index 23a3b8b..84567c1 100644 --- a/custom_components/hubitat/binary_sensor.py +++ b/custom_components/hubitat/binary_sensor.py @@ -220,10 +220,10 @@ def is_sensor( def _get_contact_device_class(device: Device) -> str: """Guess the type of contact sensor from the device's label.""" - name = device.name + label = device.label for matcher in _CONTACT_MATCHERS: - if matcher[0].search(name): + if matcher[0].search(label): return matcher[1] return BinarySensorDeviceClass.DOOR @@ -231,10 +231,10 @@ def _get_contact_device_class(device: Device) -> str: def _get_presence_device_class(device: Device) -> str: """Guess the type of presence sensor from the device's label.""" - name = device.name + label = device.label for matcher in _PRESENCE_MATCHERS: - if matcher[0].search(name): + if matcher[0].search(label): return matcher[1] return BinarySensorDeviceClass.CONNECTIVITY diff --git a/custom_components/hubitat/config_flow.py b/custom_components/hubitat/config_flow.py index 9984706..9c7d497 100644 --- a/custom_components/hubitat/config_flow.py +++ b/custom_components/hubitat/config_flow.py @@ -380,7 +380,7 @@ async def _async_step_override_type( default_value = [] possible_overrides = { - id: devices[id].name for id in devices if matcher(devices[id]) + id: devices[id].label for id in devices if matcher(devices[id]) } if existing_overrides: diff --git a/custom_components/hubitat/light.py b/custom_components/hubitat/light.py index 4cc7e3f..bcb5ea2 100644 --- a/custom_components/hubitat/light.py +++ b/custom_components/hubitat/light.py @@ -269,7 +269,7 @@ def is_light(device: Device, overrides: Optional[Dict[str, str]] = None) -> bool if is_definitely_light(device): return True if DeviceCapability.SWITCH in device.capabilities and MATCH_LIGHT.search( - device.name + device.label ): return True if DeviceCapability.LIGHT in device.capabilities: diff --git a/custom_components/hubitat/switch.py b/custom_components/hubitat/switch.py index 117d0ad..1aa1b5a 100644 --- a/custom_components/hubitat/switch.py +++ b/custom_components/hubitat/switch.py @@ -45,7 +45,7 @@ def is_on(self) -> bool: @property def device_class(self) -> Optional[str]: """Return the class of this device, from component DEVICE_CLASSES.""" - if _NAME_TEST.search(self._device.name): + if _NAME_TEST.search(self._device.label): return SwitchDeviceClass.SWITCH return SwitchDeviceClass.OUTLET