Cache entity properties that are never expected to change in the base class (#95315)

This commit is contained in:
J. Nick Koston 2023-09-14 17:48:48 -05:00 committed by GitHub
parent 5f20725fd5
commit 042776ebb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 146 additions and 48 deletions

View file

@ -5,6 +5,7 @@ from typing import Any
import voluptuous as vol
from homeassistant.backports.functools import cached_property
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA,
DOMAIN as BINARY_SENSOR_DOMAIN,
@ -147,7 +148,7 @@ class BinarySensorGroup(GroupEntity, BinarySensorEntity):
# Set as ON if any / all member is ON
self._attr_is_on = self.mode(state == STATE_ON for state in states)
@property
@cached_property
def device_class(self) -> BinarySensorDeviceClass | None:
"""Return the sensor class of the binary sensor."""
return self._device_class