Avoid duplicate property lookups in camera state_attributes (#107627)

This commit is contained in:
J. Nick Koston 2024-01-08 21:16:19 -10:00 committed by GitHub
parent 955c70b8f1
commit a0b00d78b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -726,17 +726,17 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
"""Return the camera state attributes.""" """Return the camera state attributes."""
attrs = {"access_token": self.access_tokens[-1]} attrs = {"access_token": self.access_tokens[-1]}
if self.model: if model := self.model:
attrs["model_name"] = self.model attrs["model_name"] = model
if self.brand: if brand := self.brand:
attrs["brand"] = self.brand attrs["brand"] = brand
if self.motion_detection_enabled: if motion_detection_enabled := self.motion_detection_enabled:
attrs["motion_detection"] = self.motion_detection_enabled attrs["motion_detection"] = motion_detection_enabled
if self.frontend_stream_type: if frontend_stream_type := self.frontend_stream_type:
attrs["frontend_stream_type"] = self.frontend_stream_type attrs["frontend_stream_type"] = frontend_stream_type
return attrs return attrs