Correct unit_of_measurement for trigger-based template sensor (#69291)
This commit is contained in:
parent
d0288f14f0
commit
a95b4f6763
2 changed files with 6 additions and 12 deletions
|
@ -253,6 +253,11 @@ class TriggerSensorEntity(TriggerEntity, SensorEntity):
|
||||||
"""Sensor state class."""
|
"""Sensor state class."""
|
||||||
return self._config.get(CONF_STATE_CLASS)
|
return self._config.get(CONF_STATE_CLASS)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def native_unit_of_measurement(self) -> str | None:
|
||||||
|
"""Return the unit of measurement of the sensor, if any."""
|
||||||
|
return self._config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _process_data(self) -> None:
|
def _process_data(self) -> None:
|
||||||
"""Process new data."""
|
"""Process new data."""
|
||||||
|
|
|
@ -4,13 +4,7 @@ from __future__ import annotations
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_DEVICE_CLASS, CONF_ICON, CONF_NAME, CONF_UNIQUE_ID
|
||||||
CONF_DEVICE_CLASS,
|
|
||||||
CONF_ICON,
|
|
||||||
CONF_NAME,
|
|
||||||
CONF_UNIQUE_ID,
|
|
||||||
CONF_UNIT_OF_MEASUREMENT,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
from homeassistant.helpers import template
|
from homeassistant.helpers import template
|
||||||
|
@ -89,11 +83,6 @@ class TriggerEntity(CoordinatorEntity[TriggerUpdateCoordinator]):
|
||||||
"""Return device class of the entity."""
|
"""Return device class of the entity."""
|
||||||
return self._config.get(CONF_DEVICE_CLASS)
|
return self._config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self) -> str | None:
|
|
||||||
"""Return unit of measurement."""
|
|
||||||
return self._config.get(CONF_UNIT_OF_MEASUREMENT)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str | None:
|
def icon(self) -> str | None:
|
||||||
"""Return icon."""
|
"""Return icon."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue