Fix aurora alert sensor always Off (#127780)
This commit is contained in:
parent
2c664efb3c
commit
217165208b
1 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
||||||
from .coordinator import AuroraDataUpdateCoordinator
|
from .coordinator import AuroraDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||||
|
@ -21,9 +22,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bo
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
|
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def update_listener(hass: HomeAssistant, entry: AuroraConfigEntry) -> None:
|
||||||
|
"""Handle options update."""
|
||||||
|
entry.runtime_data.threshold = int(
|
||||||
|
entry.options.get(CONF_THRESHOLD, DEFAULT_THRESHOLD)
|
||||||
|
)
|
||||||
|
# refresh the state of the visibility alert binary sensor
|
||||||
|
await entry.runtime_data.async_request_refresh()
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue