1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Remove undo listener variable in cloudflare (#52227)

* remove undo listener variable in cloudflare

* Update const.py

* Update __init__.py

* Update __init__.py
This commit is contained in:
Chris Talkington 2021-06-27 15:58:49 -05:00 committed by GitHub
parent 0d689eefd6
commit 8b47faa840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 15 deletions

View File

@ -19,13 +19,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval
from .const import (
CONF_RECORDS,
DATA_UNDO_UPDATE_INTERVAL,
DEFAULT_UPDATE_INTERVAL,
DOMAIN,
SERVICE_UPDATE_RECORDS,
)
from .const import CONF_RECORDS, DEFAULT_UPDATE_INTERVAL, DOMAIN, SERVICE_UPDATE_RECORDS
_LOGGER = logging.getLogger(__name__)
@ -64,12 +58,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.error("Error updating zone %s: %s", entry.data[CONF_ZONE], error)
update_interval = timedelta(minutes=DEFAULT_UPDATE_INTERVAL)
undo_interval = async_track_time_interval(hass, update_records, update_interval)
entry.async_on_unload(
async_track_time_interval(hass, update_records, update_interval)
)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
DATA_UNDO_UPDATE_INTERVAL: undo_interval,
}
hass.data[DOMAIN][entry.entry_id] = {}
hass.services.async_register(DOMAIN, SERVICE_UPDATE_RECORDS, update_records_service)
@ -78,7 +72,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Cloudflare config entry."""
hass.data[DOMAIN][entry.entry_id][DATA_UNDO_UPDATE_INTERVAL]()
hass.data[DOMAIN].pop(entry.entry_id)
return True

View File

@ -5,9 +5,6 @@ DOMAIN = "cloudflare"
# Config
CONF_RECORDS = "records"
# Data
DATA_UNDO_UPDATE_INTERVAL = "undo_update_interval"
# Defaults
DEFAULT_UPDATE_INTERVAL = 60 # in minutes