diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index 50b8adb4c03..114abfa9cd6 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -175,12 +175,11 @@ class AlarmControlPanelEntity(Entity): @property def state_attributes(self): """Return the state attributes.""" - state_attr = { + return { ATTR_CODE_FORMAT: self.code_format, ATTR_CHANGED_BY: self.changed_by, ATTR_CODE_ARM_REQUIRED: self.code_arm_required, } - return state_attr class AlarmControlPanel(AlarmControlPanelEntity): diff --git a/homeassistant/components/alarmdecoder/binary_sensor.py b/homeassistant/components/alarmdecoder/binary_sensor.py index 89b7d00b3a4..55bf13d7fef 100644 --- a/homeassistant/components/alarmdecoder/binary_sensor.py +++ b/homeassistant/components/alarmdecoder/binary_sensor.py @@ -120,8 +120,7 @@ class AlarmDecoderBinarySensor(BinarySensorEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {} - attr[CONF_ZONE_NUMBER] = self._zone_number + attr = {CONF_ZONE_NUMBER: self._zone_number} if self._rfid and self._rfstate is not None: attr[ATTR_RF_BIT0] = bool(self._rfstate & 0x01) attr[ATTR_RF_LOW_BAT] = bool(self._rfstate & 0x02) diff --git a/homeassistant/components/bom/sensor.py b/homeassistant/components/bom/sensor.py index 12f43430829..0470ea6e970 100644 --- a/homeassistant/components/bom/sensor.py +++ b/homeassistant/components/bom/sensor.py @@ -175,7 +175,7 @@ class BOMCurrentSensor(Entity): @property def device_state_attributes(self): """Return the state attributes of the device.""" - attr = { + return { ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_LAST_UPDATE: self.bom_data.last_updated, ATTR_SENSOR_ID: self._condition, @@ -184,8 +184,6 @@ class BOMCurrentSensor(Entity): ATTR_ZONE_ID: self.bom_data.latest_data["history_product"], } - return attr - @property def unit_of_measurement(self): """Return the units of measurement.""" diff --git a/homeassistant/components/environment_canada/camera.py b/homeassistant/components/environment_canada/camera.py index 706308830f6..bf35da16fa5 100644 --- a/homeassistant/components/environment_canada/camera.py +++ b/homeassistant/components/environment_canada/camera.py @@ -86,9 +86,7 @@ class ECCamera(Camera): @property def device_state_attributes(self): """Return the state attributes of the device.""" - attr = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_UPDATED: self.timestamp} - - return attr + return {ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_UPDATED: self.timestamp} @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): diff --git a/homeassistant/components/filesize/sensor.py b/homeassistant/components/filesize/sensor.py index 63042ec6292..27122a3cb9c 100644 --- a/homeassistant/components/filesize/sensor.py +++ b/homeassistant/components/filesize/sensor.py @@ -78,12 +78,11 @@ class Filesize(Entity): @property def device_state_attributes(self): """Return other details about the sensor state.""" - attr = { + return { "path": self._path, "last_updated": self._last_updated, "bytes": self._size, } - return attr @property def unit_of_measurement(self): diff --git a/homeassistant/components/folder/sensor.py b/homeassistant/components/folder/sensor.py index 19a5791d7cb..9a062133718 100644 --- a/homeassistant/components/folder/sensor.py +++ b/homeassistant/components/folder/sensor.py @@ -94,14 +94,13 @@ class Folder(Entity): @property def device_state_attributes(self): """Return other details about the sensor state.""" - attr = { + return { "path": self._folder_path, "filter": self._filter_term, "number_of_files": self._number_of_files, "bytes": self._size, "file_list": self._file_list, } - return attr @property def unit_of_measurement(self): diff --git a/homeassistant/components/fritzbox_netmonitor/sensor.py b/homeassistant/components/fritzbox_netmonitor/sensor.py index c0d010cf37e..5601ad5d74f 100644 --- a/homeassistant/components/fritzbox_netmonitor/sensor.py +++ b/homeassistant/components/fritzbox_netmonitor/sensor.py @@ -98,7 +98,7 @@ class FritzboxMonitorSensor(Entity): # Don't return attributes if FritzBox is unreachable if self._state == STATE_UNAVAILABLE: return {} - attr = { + return { ATTR_IS_LINKED: self._is_linked, ATTR_IS_CONNECTED: self._is_connected, ATTR_EXTERNAL_IP: self._external_ip, @@ -110,7 +110,6 @@ class FritzboxMonitorSensor(Entity): ATTR_MAX_BYTE_RATE_UP: self._max_byte_rate_up, ATTR_MAX_BYTE_RATE_DOWN: self._max_byte_rate_down, } - return attr @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): diff --git a/homeassistant/components/hikvision/binary_sensor.py b/homeassistant/components/hikvision/binary_sensor.py index c0da593a039..359f966d119 100644 --- a/homeassistant/components/hikvision/binary_sensor.py +++ b/homeassistant/components/hikvision/binary_sensor.py @@ -255,8 +255,7 @@ class HikvisionBinarySensor(BinarySensorEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {} - attr[ATTR_LAST_TRIP_TIME] = self._sensor_last_update() + attr = {ATTR_LAST_TRIP_TIME: self._sensor_last_update()} if self._delay != 0: attr[ATTR_DELAY] = self._delay diff --git a/homeassistant/components/homematic/entity.py b/homeassistant/components/homematic/entity.py index 49d3ee1f170..8578be93555 100644 --- a/homeassistant/components/homematic/entity.py +++ b/homeassistant/components/homematic/entity.py @@ -233,8 +233,7 @@ class HMHub(Entity): @property def state_attributes(self): """Return the state attributes.""" - attr = self._variables.copy() - return attr + return self._variables.copy() @property def icon(self): diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index 84ba5b45fc4..4617e78a6ec 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -173,9 +173,7 @@ class ImageProcessingFaceEntity(ImageProcessingEntity): @property def state_attributes(self): """Return device specific state attributes.""" - attr = {ATTR_FACES: self.faces, ATTR_TOTAL_FACES: self.total_faces} - - return attr + return {ATTR_FACES: self.faces, ATTR_TOTAL_FACES: self.total_faces} def process_faces(self, faces, total): """Send event with detected faces and store data.""" diff --git a/homeassistant/components/iota/__init__.py b/homeassistant/components/iota/__init__.py index 497e94a08d6..dbf5fc15007 100644 --- a/homeassistant/components/iota/__init__.py +++ b/homeassistant/components/iota/__init__.py @@ -72,8 +72,7 @@ class IotaDevice(Entity): @property def device_state_attributes(self): """Return the state attributes of the device.""" - attr = {CONF_WALLET_NAME: self._name} - return attr + return {CONF_WALLET_NAME: self._name} @property def api(self): diff --git a/homeassistant/components/lutron/binary_sensor.py b/homeassistant/components/lutron/binary_sensor.py index e2e143da435..f77a2b120da 100644 --- a/homeassistant/components/lutron/binary_sensor.py +++ b/homeassistant/components/lutron/binary_sensor.py @@ -51,6 +51,4 @@ class LutronOccupancySensor(LutronDevice, BinarySensorEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {} - attr["lutron_integration_id"] = self._lutron_device.id - return attr + return {"lutron_integration_id": self._lutron_device.id} diff --git a/homeassistant/components/lutron/cover.py b/homeassistant/components/lutron/cover.py index 438a433fb0f..1ec7c07aac0 100644 --- a/homeassistant/components/lutron/cover.py +++ b/homeassistant/components/lutron/cover.py @@ -66,6 +66,4 @@ class LutronCover(LutronDevice, CoverEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {} - attr["Lutron Integration ID"] = self._lutron_device.id - return attr + return {"Lutron Integration ID": self._lutron_device.id} diff --git a/homeassistant/components/lutron/light.py b/homeassistant/components/lutron/light.py index 2b5bff7d848..411a1d494df 100644 --- a/homeassistant/components/lutron/light.py +++ b/homeassistant/components/lutron/light.py @@ -71,8 +71,7 @@ class LutronLight(LutronDevice, LightEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {"lutron_integration_id": self._lutron_device.id} - return attr + return {"lutron_integration_id": self._lutron_device.id} @property def is_on(self): diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index d03cb4a1953..ac00faaa9bc 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -48,9 +48,7 @@ class LutronSwitch(LutronDevice, SwitchEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {} - attr["lutron_integration_id"] = self._lutron_device.id - return attr + return {"lutron_integration_id": self._lutron_device.id} @property def is_on(self): @@ -83,12 +81,11 @@ class LutronLed(LutronDevice, SwitchEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = { + return { "keypad": self._keypad_name, "scene": self._scene_name, "led": self._lutron_device.name, } - return attr @property def is_on(self): diff --git a/homeassistant/components/mfi/switch.py b/homeassistant/components/mfi/switch.py index 3dfbf3fb594..21963140547 100644 --- a/homeassistant/components/mfi/switch.py +++ b/homeassistant/components/mfi/switch.py @@ -109,7 +109,7 @@ class MfiSwitch(SwitchEntity): @property def device_state_attributes(self): """Return the state attributes for the device.""" - attr = {} - attr["volts"] = round(self._port.data.get("v_rms", 0), 1) - attr["amps"] = round(self._port.data.get("i_rms", 0), 1) - return attr + return { + "volts": round(self._port.data.get("v_rms", 0), 1), + "amps": round(self._port.data.get("i_rms", 0), 1), + } diff --git a/homeassistant/components/miflora/sensor.py b/homeassistant/components/miflora/sensor.py index 94db0417ddb..5c5257d4181 100644 --- a/homeassistant/components/miflora/sensor.py +++ b/homeassistant/components/miflora/sensor.py @@ -184,8 +184,7 @@ class MiFloraSensor(Entity): @property def device_state_attributes(self): """Return the state attributes of the device.""" - attr = {ATTR_LAST_SUCCESSFUL_UPDATE: self.last_successful_update} - return attr + return {ATTR_LAST_SUCCESSFUL_UPDATE: self.last_successful_update} @property def unit_of_measurement(self): diff --git a/homeassistant/components/openalpr_local/image_processing.py b/homeassistant/components/openalpr_local/image_processing.py index c7c96b05872..644f2c687b2 100644 --- a/homeassistant/components/openalpr_local/image_processing.py +++ b/homeassistant/components/openalpr_local/image_processing.py @@ -104,9 +104,7 @@ class ImageProcessingAlprEntity(ImageProcessingEntity): @property def state_attributes(self): """Return device specific state attributes.""" - attr = {ATTR_PLATES: self.plates, ATTR_VEHICLES: self.vehicles} - - return attr + return {ATTR_PLATES: self.plates, ATTR_VEHICLES: self.vehicles} def process_plates(self, plates, vehicles): """Send event with new plates and store data.""" diff --git a/homeassistant/components/plex/media_player.py b/homeassistant/components/plex/media_player.py index f5dc98e4eb1..94bed1db7de 100644 --- a/homeassistant/components/plex/media_player.py +++ b/homeassistant/components/plex/media_player.py @@ -597,7 +597,7 @@ class PlexMediaPlayer(MediaPlayerEntity): @property def device_state_attributes(self): """Return the scene state attributes.""" - attr = { + return { "media_content_rating": self._media_content_rating, "session_username": self.username, "media_library_name": self._app_name, @@ -605,8 +605,6 @@ class PlexMediaPlayer(MediaPlayerEntity): "player_source": self.player_source, } - return attr - @property def device_info(self): """Return a device description for device registry.""" diff --git a/homeassistant/components/simulated/sensor.py b/homeassistant/components/simulated/sensor.py index d05448a82c7..fba8b497d51 100644 --- a/homeassistant/components/simulated/sensor.py +++ b/homeassistant/components/simulated/sensor.py @@ -142,7 +142,7 @@ class SimulatedSensor(Entity): @property def device_state_attributes(self): """Return other details about the sensor state.""" - attr = { + return { "amplitude": self._amp, "mean": self._mean, "period": self._period, @@ -151,4 +151,3 @@ class SimulatedSensor(Entity): "seed": self._seed, "relative_to_epoch": self._relative_to_epoch, } - return attr diff --git a/homeassistant/components/swiss_public_transport/sensor.py b/homeassistant/components/swiss_public_transport/sensor.py index 1562a498080..2c7fb483eff 100644 --- a/homeassistant/components/swiss_public_transport/sensor.py +++ b/homeassistant/components/swiss_public_transport/sensor.py @@ -103,7 +103,7 @@ class SwissPublicTransportSensor(Entity): self._opendata.connections[0]["departure"] ) - dt_util.as_local(dt_util.utcnow()) - attr = { + return { ATTR_TRAIN_NUMBER: self._opendata.connections[0]["number"], ATTR_PLATFORM: self._opendata.connections[0]["platform"], ATTR_TRANSFERS: self._opendata.connections[0]["transfers"], @@ -116,7 +116,6 @@ class SwissPublicTransportSensor(Entity): ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_DELAY: self._opendata.connections[0]["delay"], } - return attr @property def icon(self): diff --git a/homeassistant/components/synology_dsm/binary_sensor.py b/homeassistant/components/synology_dsm/binary_sensor.py index a75f57db678..6c11d31b7f7 100644 --- a/homeassistant/components/synology_dsm/binary_sensor.py +++ b/homeassistant/components/synology_dsm/binary_sensor.py @@ -67,7 +67,4 @@ class SynoDSMStorageBinarySensor(SynologyDSMDeviceEntity, BinarySensorEntity): @property def is_on(self) -> bool: """Return the state.""" - attr = getattr(self._api.storage, self.entity_type)(self._device_id) - if attr is None: - return None - return attr + return getattr(self._api.storage, self.entity_type)(self._device_id) diff --git a/homeassistant/components/tradfri/cover.py b/homeassistant/components/tradfri/cover.py index 2d99de7756a..72597637bd3 100644 --- a/homeassistant/components/tradfri/cover.py +++ b/homeassistant/components/tradfri/cover.py @@ -31,8 +31,7 @@ class TradfriCover(TradfriBaseDevice, CoverEntity): @property def device_state_attributes(self): """Return the state attributes.""" - attr = {ATTR_MODEL: self._device.device_info.model_number} - return attr + return {ATTR_MODEL: self._device.device_info.model_number} @property def current_cover_position(self):