mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix double call to options in sensor state (#93311)
This commit is contained in:
parent
780f9bcdc0
commit
90984c34a9
@ -548,7 +548,9 @@ class SensorEntity(Entity):
|
||||
) from err
|
||||
|
||||
# Enum checks
|
||||
if device_class == SensorDeviceClass.ENUM or self.options is not None:
|
||||
if (
|
||||
options := self.options
|
||||
) is not None or device_class == SensorDeviceClass.ENUM:
|
||||
if device_class != SensorDeviceClass.ENUM:
|
||||
reason = "is missing the enum device class"
|
||||
if device_class is not None:
|
||||
@ -557,7 +559,7 @@ class SensorEntity(Entity):
|
||||
f"Sensor {self.entity_id} is providing enum options, but {reason}"
|
||||
)
|
||||
|
||||
if (options := self.options) and value not in options:
|
||||
if options and value not in options:
|
||||
raise ValueError(
|
||||
f"Sensor {self.entity_id} provides state value '{value}', "
|
||||
"which is not in the list of options provided"
|
||||
|
Loading…
x
Reference in New Issue
Block a user