From 79a418f1bcd5fef180ff67745f5dc4e74e4d876c Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Tue, 20 Jul 2021 06:20:56 -0400 Subject: [PATCH] Use entity class attributes for Brottsplatskartan (#53163) --- .../components/brottsplatskartan/sensor.py | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/brottsplatskartan/sensor.py b/homeassistant/components/brottsplatskartan/sensor.py index 32af96dfe60..c327f9122ce 100644 --- a/homeassistant/components/brottsplatskartan/sensor.py +++ b/homeassistant/components/brottsplatskartan/sensor.py @@ -82,25 +82,8 @@ class BrottsplatskartanSensor(SensorEntity): def __init__(self, bpk, name): """Initialize the Brottsplatskartan sensor.""" - self._attributes = {} self._brottsplatskartan = bpk - self._name = name - self._state = None - - @property - def name(self): - """Return the name of the sensor.""" - return self._name - - @property - def state(self): - """Return the state of the sensor.""" - return self._state - - @property - def extra_state_attributes(self): - """Return the state attributes.""" - return self._attributes + self._attr_name = name def update(self): """Update device state.""" @@ -116,6 +99,8 @@ class BrottsplatskartanSensor(SensorEntity): incident_type = incident.get("title_type") incident_counts[incident_type] += 1 - self._attributes = {ATTR_ATTRIBUTION: brottsplatskartan.ATTRIBUTION} - self._attributes.update(incident_counts) - self._state = len(incidents) + self._attr_extra_state_attributes = { + ATTR_ATTRIBUTION: brottsplatskartan.ATTRIBUTION + } + self._attr_extra_state_attributes.update(incident_counts) + self._attr_state = len(incidents)