Skip to content

Commit

Permalink
Adding changeable interval
Browse files Browse the repository at this point in the history
Fixing #112
  • Loading branch information
kloknibor committed Apr 19, 2022
1 parent 3c622d2 commit 3264b6c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/miele/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
SERVICE_ACTION = "action"
SCOPE = "code"
DEFAULT_LANG = "en"
DEFAULT_INTERVAL = 5
AUTH_CALLBACK_PATH = "/api/miele/callback"
AUTH_CALLBACK_NAME = "api:miele:callback"
CONF_CLIENT_ID = "client_id"
CONF_CLIENT_SECRET = "client_secret"
CONF_LANG = "lang"
CONF_CACHE_PATH = "cache_path"
CONF_INTERVAL = "interval"
CONFIGURATOR_LINK_NAME = "Link Miele account"
CONFIGURATOR_SUBMIT_CAPTION = "I have authorized Miele@home."
CONFIGURATOR_DESCRIPTION = (
Expand All @@ -62,6 +64,7 @@
vol.Required(CONF_CLIENT_SECRET): cv.string,
vol.Optional(CONF_LANG): cv.string,
vol.Optional(CONF_CACHE_PATH): cv.string,
vol.Optional(CONF_INTERVAL): cv.positive_int,
}
),
},
Expand Down Expand Up @@ -333,7 +336,6 @@
],
}


def request_configuration(hass, config, oauth):
"""Request Miele authorization."""

Expand Down Expand Up @@ -446,8 +448,9 @@ async def refresh_devices(event_time):
platform.update_device_state()

register_services(hass)
interval = timedelta(seconds=config[DOMAIN].get(CONF_INTERVAL, DEFAULT_INTERVAL))

interval = timedelta(seconds=5)

async_track_time_interval(hass, refresh_devices, interval)

return True
Expand Down

0 comments on commit 3264b6c

Please sign in to comment.