diff --git a/custom_components/localthings/config_flow.py b/custom_components/localthings/config_flow.py index fa986cd..8b0e097 100644 --- a/custom_components/localthings/config_flow.py +++ b/custom_components/localthings/config_flow.py @@ -91,7 +91,7 @@ def _fetch_samsung_uuid() -> str: raise RuntimeError(f"No certificate received from {_SAMSUNG_CLOUD_HOST}") cert = _x509.load_der_x509_certificate(der) for attr in cert.subject: - if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME: + if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME and isinstance(attr.value, str): m = re.search(r"uuid:([0-9a-f-]+)", attr.value, re.IGNORECASE) if m: return m.group(1) diff --git a/custom_components/localthings/sensor.py b/custom_components/localthings/sensor.py index 4d98c33..eccbb3e 100644 --- a/custom_components/localthings/sensor.py +++ b/custom_components/localthings/sensor.py @@ -5,7 +5,7 @@ from __future__ import annotations from datetime import timedelta from typing import cast -from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorStateClass from homeassistant.config_entries import ConfigEntry from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant @@ -47,7 +47,7 @@ class LocalThingsSensor(LocalThingsEntity, SensorEntity): self._attr_device_class = ( SensorDeviceClass(desc.device_class) if desc.device_class else None ) - self._attr_state_class = desc.state_class + self._attr_state_class = SensorStateClass(desc.state_class) if desc.state_class else None if desc.options: self._attr_options = list(desc.options) self._hysteresis_value = None