Add support for reloading min_max from yaml (#39327)
* Add support for reloading min_max from yaml * git add
This commit is contained in:
1 parent
e6141ae558
commit
d2195e2b37
5 files changed
+75
-3
No files matched your search
@@ -15,6 +15,9 @@ from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.reload import async_setup_reload_service
|
||||
|
||||
from . import DOMAIN, PLATFORMS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -72,6 +75,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
sensor_type = config.get(CONF_TYPE)
|
||||
round_digits = config.get(CONF_ROUND_DIGITS)
|
||||
|
||||
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
|
||||
|
||||
async_add_entities(
|
||||
[MinMaxSensor(hass, entity_ids, name, sensor_type, round_digits)], True
|
||||
)
|
||||
@@ -188,8 +193,10 @@ class MinMaxSensor(Entity):
|
||||
|
||||
hass.async_add_job(self.async_update_ha_state, True)
|
||||
|
||||
async_track_state_change_event(
|
||||
hass, entity_ids, async_min_max_sensor_state_listener
|
||||
self.async_on_remove(
|
||||
async_track_state_change_event(
|
||||
hass, entity_ids, async_min_max_sensor_state_listener
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
Reference in new issue
Block a user