From a0b00d78b1364b606884881d30d6a1a5bf1a54c9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 8 Jan 2024 21:16:19 -1000 Subject: [PATCH] Avoid duplicate property lookups in camera state_attributes (#107627) --- homeassistant/components/camera/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index ce75f064d47..5a78728697b 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -726,17 +726,17 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): """Return the camera state attributes.""" attrs = {"access_token": self.access_tokens[-1]} - if self.model: - attrs["model_name"] = self.model + if model := self.model: + attrs["model_name"] = model - if self.brand: - attrs["brand"] = self.brand + if brand := self.brand: + attrs["brand"] = brand - if self.motion_detection_enabled: - attrs["motion_detection"] = self.motion_detection_enabled + if motion_detection_enabled := self.motion_detection_enabled: + attrs["motion_detection"] = motion_detection_enabled - if self.frontend_stream_type: - attrs["frontend_stream_type"] = self.frontend_stream_type + if frontend_stream_type := self.frontend_stream_type: + attrs["frontend_stream_type"] = frontend_stream_type return attrs