mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
Ensure ESPHome device classes are valid (#60594)
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from aioesphomeapi import BinarySensorInfo, BinarySensorState
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@@ -45,8 +45,10 @@ class EsphomeBinarySensor(
|
||||
return self._state.state
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
if self._static_info.device_class not in DEVICE_CLASSES:
|
||||
return None
|
||||
return self._static_info.device_class
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user