mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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
|
) from err
|
||||||
|
|
||||||
# Enum checks
|
# 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:
|
if device_class != SensorDeviceClass.ENUM:
|
||||||
reason = "is missing the enum device class"
|
reason = "is missing the enum device class"
|
||||||
if device_class is not None:
|
if device_class is not None:
|
||||||
@ -557,7 +559,7 @@ class SensorEntity(Entity):
|
|||||||
f"Sensor {self.entity_id} is providing enum options, but {reason}"
|
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(
|
raise ValueError(
|
||||||
f"Sensor {self.entity_id} provides state value '{value}', "
|
f"Sensor {self.entity_id} provides state value '{value}', "
|
||||||
"which is not in the list of options provided"
|
"which is not in the list of options provided"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user