mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use entity class attributes for Brottsplatskartan (#53163)
This commit is contained in:
parent
5d2ce19746
commit
79a418f1bc
@ -82,25 +82,8 @@ class BrottsplatskartanSensor(SensorEntity):
|
|||||||
|
|
||||||
def __init__(self, bpk, name):
|
def __init__(self, bpk, name):
|
||||||
"""Initialize the Brottsplatskartan sensor."""
|
"""Initialize the Brottsplatskartan sensor."""
|
||||||
self._attributes = {}
|
|
||||||
self._brottsplatskartan = bpk
|
self._brottsplatskartan = bpk
|
||||||
self._name = name
|
self._attr_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
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
@ -116,6 +99,8 @@ class BrottsplatskartanSensor(SensorEntity):
|
|||||||
incident_type = incident.get("title_type")
|
incident_type = incident.get("title_type")
|
||||||
incident_counts[incident_type] += 1
|
incident_counts[incident_type] += 1
|
||||||
|
|
||||||
self._attributes = {ATTR_ATTRIBUTION: brottsplatskartan.ATTRIBUTION}
|
self._attr_extra_state_attributes = {
|
||||||
self._attributes.update(incident_counts)
|
ATTR_ATTRIBUTION: brottsplatskartan.ATTRIBUTION
|
||||||
self._state = len(incidents)
|
}
|
||||||
|
self._attr_extra_state_attributes.update(incident_counts)
|
||||||
|
self._attr_state = len(incidents)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user