Add the ability to reload trend platforms from yaml (#39341)
This commit is contained in:
1 parent
526c418e1e
commit
0db5bb27a8
5 files changed
+68
-3
No files matched your search
@@ -26,8 +26,11 @@ from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.reload import setup_reload_service
|
||||
from homeassistant.util import utcnow
|
||||
|
||||
from . import DOMAIN, PLATFORMS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_ATTRIBUTE = "attribute"
|
||||
@@ -63,6 +66,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the trend sensors."""
|
||||
|
||||
setup_reload_service(hass, DOMAIN, PLATFORMS)
|
||||
|
||||
sensors = []
|
||||
|
||||
for device_id, device_config in config[CONF_SENSORS].items():
|
||||
@@ -179,8 +185,10 @@ class SensorTrend(BinarySensorEntity):
|
||||
except (ValueError, TypeError) as ex:
|
||||
_LOGGER.error(ex)
|
||||
|
||||
async_track_state_change_event(
|
||||
self.hass, [self._entity_id], trend_sensor_state_listener
|
||||
self.async_on_remove(
|
||||
async_track_state_change_event(
|
||||
self.hass, [self._entity_id], trend_sensor_state_listener
|
||||
)
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
|
||||
Reference in new issue
Block a user