From 2ed6a70f8e50c6ed2e2aef7f4b96fe65d6c4632c Mon Sep 17 00:00:00 2001 From: Dan Raper Date: Thu, 24 Oct 2024 10:21:20 +0100 Subject: [PATCH] Bugfixes (#65) * Schedule refresh fix attempt * en.json: Make it explicit that imperial means miles * Disable imperial distance units toggle in options flow --------- Co-authored-by: Sam Reed --- custom_components/nissan_connect/config_flow.py | 5 +++-- custom_components/nissan_connect/coordinator.py | 3 +++ custom_components/nissan_connect/translations/en.json | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/custom_components/nissan_connect/config_flow.py b/custom_components/nissan_connect/config_flow.py index 006c9c5..f5897c7 100644 --- a/custom_components/nissan_connect/config_flow.py +++ b/custom_components/nissan_connect/config_flow.py @@ -121,7 +121,8 @@ async def async_step_init(self, options): vol.Required( "interval_statistics", default=self._config_entry.data.get("interval_statistics", DEFAULT_INTERVAL_STATISTICS) ): int, - vol.Required( - "imperial_distance", default=self._config_entry.data.get("imperial_distance", False)): bool + # Excluded from config flow under #61 + # vol.Required( + # "imperial_distance", default=self._config_entry.data.get("imperial_distance", False)): bool }), errors=errors ) diff --git a/custom_components/nissan_connect/coordinator.py b/custom_components/nissan_connect/coordinator.py index aabaa0c..2afc36e 100644 --- a/custom_components/nissan_connect/coordinator.py +++ b/custom_components/nissan_connect/coordinator.py @@ -77,6 +77,9 @@ def set_next_interval(self): if interval != (self.update_interval.seconds / 60): _LOGGER.debug(f"Changing next update interval to {interval} minutes") self.update_interval = timedelta(minutes=interval) + self._async_unsub_refresh() + if self._listeners: + self._schedule_refresh() async def _async_update_data(self): """Fetch data from API.""" diff --git a/custom_components/nissan_connect/translations/en.json b/custom_components/nissan_connect/translations/en.json index 5ab62a1..6c7f2c6 100644 --- a/custom_components/nissan_connect/translations/en.json +++ b/custom_components/nissan_connect/translations/en.json @@ -12,7 +12,7 @@ "interval_statistics": "Update interval for daily/monthly statistics (minutes)", "interval_fetch": "Update interval (minutes)", "region": "Region (EU, US)", - "imperial_distance": "Use imperial distance units" + "imperial_distance": "Use imperial distance units (miles)" }, "data_description": { "interval_charging": "The car will be woken up and new data requested at every polling interval.", @@ -37,7 +37,7 @@ "interval_charging": "Polling interval while charging (minutes)", "interval_statistics": "Update interval for daily/monthly statistics (minutes)", "interval_fetch": "Update interval (minutes)", - "imperial_distance": "Use imperial distance units" + "imperial_distance": "Use imperial distance units (miles)" }, "data_description": { "password": "If you are not changing your credentials, leave the password field empty.",