Use shorthand attributes in Trend (#99695)

This commit is contained in:
Jan-Philipp Benecke 2023-09-06 09:55:25 +02:00 committed by GitHub
parent cdca4591a4
commit f41b045244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 16 deletions

View File

@ -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

View File

@ -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,

View File

@ -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"]
}

View File

@ -5930,7 +5930,7 @@
"name": "Trend",
"integration_type": "hub",
"config_flow": false,
"iot_class": "local_push"
"iot_class": "calculated"
},
"tuya": {
"name": "Tuya",