Skip to content

Commit

Permalink
fix(config): Fixed loading binary sensor when start/end is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Oct 2, 2022
1 parent 4267375 commit 3979644
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions custom_components/carbon_intensity/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,21 @@ async def __async_setup_target_rate_schema(self, config, errors):
is_rolling_target = True
if (CONFIG_TARGET_ROLLING_TARGET in config):
is_rolling_target = config[CONFIG_TARGET_ROLLING_TARGET]

start_time = None
if (CONFIG_TARGET_START_TIME in config):
start_time = config[CONFIG_TARGET_START_TIME]

end_time = None
if (CONFIG_TARGET_END_TIME in config):
end_time = config[CONFIG_TARGET_END_TIME]

return self.async_show_form(
step_id="target_rate",
data_schema=vol.Schema({
vol.Required(CONFIG_TARGET_HOURS, default=f'{config[CONFIG_TARGET_HOURS]}'): str,
vol.Optional(CONFIG_TARGET_START_TIME, default=config[CONFIG_TARGET_START_TIME]): str,
vol.Optional(CONFIG_TARGET_END_TIME, default=config[CONFIG_TARGET_END_TIME]): str,
vol.Optional(CONFIG_TARGET_START_TIME, default=start_time): str,
vol.Optional(CONFIG_TARGET_END_TIME, default=end_time): str,
vol.Optional(CONFIG_TARGET_OFFSET, default=offset): str,
vol.Optional(CONFIG_TARGET_ROLLING_TARGET, default=is_rolling_target): bool,
}),
Expand Down

0 comments on commit 3979644

Please sign in to comment.