From f41b0452442374c8cfb5f94ecde7dc81ead4ec90 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Wed, 6 Sep 2023 09:55:25 +0200 Subject: [PATCH] Use shorthand attributes in Trend (#99695) --- CODEOWNERS | 2 ++ homeassistant/components/trend/binary_sensor.py | 16 +++------------- homeassistant/components/trend/manifest.json | 4 ++-- homeassistant/generated/integrations.json | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 79ff912f4b7..58812a0baf2 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1314,6 +1314,8 @@ build.json @home-assistant/supervisor /tests/components/trafikverket_weatherstation/ @endor-force @gjohansson-ST /homeassistant/components/transmission/ @engrbm87 @JPHutchins /tests/components/transmission/ @engrbm87 @JPHutchins +/homeassistant/components/trend/ @jpbede +/tests/components/trend/ @jpbede /homeassistant/components/tts/ @home-assistant/core @pvizeli /tests/components/tts/ @home-assistant/core @pvizeli /homeassistant/components/tuya/ @Tuya @zlinoliver @frenck diff --git a/homeassistant/components/trend/binary_sensor.py b/homeassistant/components/trend/binary_sensor.py index 020f7903060..815403e1e87 100644 --- a/homeassistant/components/trend/binary_sensor.py +++ b/homeassistant/components/trend/binary_sensor.py @@ -134,10 +134,10 @@ class SensorTrend(BinarySensorEntity): """Initialize the sensor.""" self._hass = hass self.entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass) - self._name = friendly_name + self._attr_name = friendly_name + self._attr_device_class = device_class self._entity_id = entity_id self._attribute = attribute - self._device_class = device_class self._invert = invert self._sample_duration = sample_duration self._min_gradient = min_gradient @@ -145,27 +145,17 @@ class SensorTrend(BinarySensorEntity): self._state = None self.samples = deque(maxlen=max_samples) - @property - def name(self): - """Return the name of the sensor.""" - return self._name - @property def is_on(self): """Return true if sensor is on.""" return self._state - @property - def device_class(self): - """Return the sensor class of the sensor.""" - return self._device_class - @property def extra_state_attributes(self): """Return the state attributes of the sensor.""" return { ATTR_ENTITY_ID: self._entity_id, - ATTR_FRIENDLY_NAME: self._name, + ATTR_FRIENDLY_NAME: self._attr_name, ATTR_GRADIENT: self._gradient, ATTR_INVERT: self._invert, ATTR_MIN_GRADIENT: self._min_gradient, diff --git a/homeassistant/components/trend/manifest.json b/homeassistant/components/trend/manifest.json index 77a0044ca1f..9bb5c4296c5 100644 --- a/homeassistant/components/trend/manifest.json +++ b/homeassistant/components/trend/manifest.json @@ -1,9 +1,9 @@ { "domain": "trend", "name": "Trend", - "codeowners": [], + "codeowners": ["@jpbede"], "documentation": "https://www.home-assistant.io/integrations/trend", - "iot_class": "local_push", + "iot_class": "calculated", "quality_scale": "internal", "requirements": ["numpy==1.23.2"] } diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index acf12b4f05d..39c7a82ce55 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -5930,7 +5930,7 @@ "name": "Trend", "integration_type": "hub", "config_flow": false, - "iot_class": "local_push" + "iot_class": "calculated" }, "tuya": { "name": "Tuya",