Collection of changing entity properties to class attributes (#51248)

* Collection of changing entity properties to class attributes

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Franck Nijhof 2021-05-31 10:50:11 +02:00 committed by GitHub
parent 5acc3a1083
commit 258b388f41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 106 additions and 305 deletions

View file

@ -166,6 +166,8 @@ class NMBSLiveBoard(SensorEntity):
class NMBSSensor(SensorEntity):
"""Get the the total travel time for a given connection."""
_attr_unit_of_measurement = TIME_MINUTES
def __init__(
self, api_client, name, show_on_map, station_from, station_to, excl_vias
):
@ -185,11 +187,6 @@ class NMBSSensor(SensorEntity):
"""Return the name of the sensor."""
return self._name
@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return TIME_MINUTES
@property
def icon(self):
"""Return the sensor default icon or an alert icon if any delay."""