-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented state change and make scan interval configurable (#5)
- Loading branch information
1 parent
ad25981
commit f733348
Showing
6 changed files
with
159 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Options flow for Sagemcom integration.""" | ||
|
||
from homeassistant import config_entries | ||
from homeassistant.const import CONF_SCAN_INTERVAL | ||
import homeassistant.helpers.config_validation as cv | ||
import voluptuous as vol | ||
|
||
from .const import DEFAULT_SCAN_INTERVAL, MIN_SCAN_INTERVAL | ||
|
||
|
||
class OptionsFlow(config_entries.OptionsFlow): | ||
"""Handle a options flow for Sagemcom.""" | ||
|
||
def __init__(self, config_entry): | ||
"""Initialize Sagemcom options flow.""" | ||
self._options = dict(config_entry.options) | ||
|
||
async def async_step_init(self, user_input=None): | ||
"""Manage the options.""" | ||
if user_input is not None: | ||
return self.async_create_entry(title="", data=user_input) | ||
|
||
return self.async_show_form( | ||
step_id="init", | ||
data_schema=vol.Schema( | ||
{ | ||
vol.Optional( | ||
CONF_SCAN_INTERVAL, | ||
default=self._options.get( | ||
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL | ||
), | ||
): vol.All(cv.positive_int, vol.Clamp(min=MIN_SCAN_INTERVAL)) | ||
} | ||
), | ||
) |