Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Added missing localizations, changed configuration defaults, fixed is…
Browse files Browse the repository at this point in the history
…sues in reconfiguration of integration.
  • Loading branch information
jesmak committed Oct 25, 2023
1 parent 680e500 commit 06c8250
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ A custom component that integrates with Finnish Meteorological Institute to wate
| Name | Type | Requirement | Description | Default |
|----------------|---------| ------------ |-------------------------------------------------|---------|
| location | string | **Required** | Target location from a predefined list | Föglö |
| hours | int | **Required** | Number of hours of observations to retrieve | 48 |
| forecast_hours | int | **Required** | Number of hours of forecasts to retrieve | 48 |
| step | int | **Required** | Time step between two values in minutes | 15 |
| hours | int | **Required** | Number of hours of observations to retrieve | 36 |
| forecast_hours | int | **Required** | Number of hours of forecasts to retrieve | 36 |
| step | int | **Required** | Time step between two values in minutes | 20 |
| overlap | int | **Required** | Overlap of forecast and observations in minutes | 120 |

### State attributes
Expand Down
13 changes: 8 additions & 5 deletions config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
CONFIGURE_SCHEMA = vol.Schema(
{
vol.Required(CONF_LOCATION): vol.All(cv.string, vol.In(FMISID_LOCATIONS)),
vol.Required(CONF_HOURS, default=48): cv.positive_int,
vol.Required(CONF_FORECAST_HOURS, default=48): cv.positive_int,
vol.Required(CONF_STEP, default=15): cv.positive_int,
vol.Required(CONF_HOURS, default=36): cv.positive_int,
vol.Required(CONF_FORECAST_HOURS, default=36): cv.positive_int,
vol.Required(CONF_STEP, default=20): cv.positive_int,
vol.Required(CONF_OVERLAP, default=120): cv.positive_int,
}
)
Expand All @@ -50,7 +50,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, any]) -> str:
except FMIWaterLevelException:
raise ConnectionProblem

return fmisid
return data[CONF_LOCATION]


class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down Expand Up @@ -93,14 +93,17 @@ async def async_step_init(self, user_input: dict[str, any] = None) -> FlowResult
if user_input is None:
return self.async_show_form(step_id="init", data_schema=vol.Schema(
{
vol.Required(CONF_LOCATION, default=self._config_entry.data.get(CONF_LOCATION)): cv.positive_int
vol.Required(CONF_OVERLAP, default=self._config_entry.data.get(CONF_OVERLAP)): cv.positive_int,
vol.Required(CONF_STEP, default=self._config_entry.data.get(CONF_STEP)): cv.positive_int,
})
)

errors = {}

try:
user_input[CONF_LOCATION] = self._config_entry.data[CONF_LOCATION]
user_input[CONF_HOURS] = self._config_entry.data[CONF_HOURS]
user_input[CONF_FORECAST_HOURS] = self._config_entry.data[CONF_FORECAST_HOURS]
await validate_input(self.hass, user_input)
except ConnectionProblem:
errors["base"] = "connection_problem"
Expand Down
6 changes: 4 additions & 2 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"hours": "Hours of observation data to retrieve",
"forecast_hours": "Hours of forecast data to retrieve",
"location": "Mareograph location",
"step": "Time step between two values in minutes"
"step": "Time step between two values in minutes",
"overlap": "Overlap between forecast and observations in minutes"
}
}
}
Expand All @@ -33,7 +34,8 @@
"days": "Days to retrieve",
"maturity": "Maturity",
"location": "Mareograph location",
"step": "Time step between two values in minutes"
"step": "Time step between two values in minutes",
"overlap": "Overlap between forecast and observations in minutes"
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions translations/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"hours": "Moneltako tunnilta mittausdata haetaan",
"forecast_hours": "Moneltako tunnilta ennustedata haetaan",
"location": "Mareografin sijainti",
"step": "Aikaväli kahden mitta-arvon välillä (minuuteissa)"
"step": "Aikaväli kahden mitta-arvon välillä minuuteissa",
"overlap": "Ennusteen ja mittausten päällekkäisyys minuuteissa"
}
}
}
Expand All @@ -33,7 +34,8 @@
"hours": "Moneltako tunnilta mittausdata haetaan",
"forecast_hours": "Moneltako tunnilta ennustedata haetaan",
"location": "Mareografin sijainti",
"step": "Aikaväli kahden mitta-arvon välillä (minuuteissa)"
"step": "Aikaväli kahden mitta-arvon välillä minuuteissa",
"overlap": "Ennusteen ja mittausten päällekkäisyys minuuteissa"
}
}
}
Expand Down

0 comments on commit 06c8250

Please sign in to comment.