Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a NumberSelector and make the interval required, we need a number… #489

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/myenergi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def _async_update_data(self):
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
utc_today = dt_util.as_utc(today)
_LOGGER.debug(
f"Refresh histoy local start of day in UTC {utc_today} {utc_today.tzinfo}"
f"Refresh history local start of day in UTC {utc_today} {utc_today.tzinfo}"
)
try:
await self.client.refresh()
Expand Down
24 changes: 16 additions & 8 deletions custom_components/myenergi/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@
from homeassistant.core import callback
from pymyenergi.client import MyenergiClient
from pymyenergi.connection import Connection
from pymyenergi.exceptions import TimeoutException
from pymyenergi.exceptions import WrongCredentials
from pymyenergi.exceptions import (
TimeoutException,
WrongCredentials
)

from . import SCAN_INTERVAL
from .const import CONF_PASSWORD
from .const import CONF_SCAN_INTERVAL
from .const import CONF_USERNAME
from .const import DOMAIN

from .const import (
CONF_PASSWORD,
CONF_SCAN_INTERVAL,
CONF_USERNAME,
DOMAIN
)

from homeassistant.helpers.selector import (
NumberSelector,
NumberSelectorConfig,
)

_LOGGER: logging.Logger = logging.getLogger(__package__)

Expand Down Expand Up @@ -111,7 +119,7 @@ async def async_step_user(self, user_input=None):
step_id="user",
data_schema=vol.Schema(
{
vol.Optional(CONF_SCAN_INTERVAL, default=scan_interval): int,
vol.Required(CONF_SCAN_INTERVAL, default=scan_interval): NumberSelector(NumberSelectorConfig(min=1, max=300, step=1),),
}
),
)
Expand Down
Loading