From 1337dfed8c722294bd10edb48a338b9d8c6d1e90 Mon Sep 17 00:00:00 2001 From: Yuval Aboulafia Date: Thu, 1 Jul 2021 22:31:30 +0300 Subject: [PATCH] Use attributes instead of properties for uptime (#52398) * Use attributes instead of properties for uptime * add missing types --- homeassistant/components/uptime/sensor.py | 26 ++++------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/uptime/sensor.py b/homeassistant/components/uptime/sensor.py index 98c673b8878..5b31b2e81d0 100644 --- a/homeassistant/components/uptime/sensor.py +++ b/homeassistant/components/uptime/sensor.py @@ -47,25 +47,7 @@ class UptimeSensor(SensorEntity): def __init__(self, name: str) -> None: """Initialize the uptime sensor.""" - self._name = name - self._state = dt_util.now().isoformat() - - @property - def name(self) -> str: - """Return the name of the sensor.""" - return self._name - - @property - def device_class(self) -> str: - """Return device class.""" - return DEVICE_CLASS_TIMESTAMP - - @property - def state(self) -> str: - """Return the state of the sensor.""" - return self._state - - @property - def should_poll(self) -> bool: - """Disable polling for this entity.""" - return False + self._attr_name: str = name + self._attr_device_class: str = DEVICE_CLASS_TIMESTAMP + self._attr_should_poll: bool = False + self._attr_state: str = dt_util.now().isoformat()