From 06b3a0e45d4312451276740466c085a129d06000 Mon Sep 17 00:00:00 2001 From: Snuffy2 Date: Fri, 10 Jan 2025 19:52:33 -0500 Subject: [PATCH] Rearrange and add details to config_flow (#310) * Rearrange and add details to config_flow * Update README.md --- README.md | 2 +- custom_components/places/config_flow.py | 14 ++++++------ custom_components/places/translations/en.json | 22 ++++++++++++++----- custom_components/places/translations/ru.json | 14 ++++++++++-- custom_components/places/translations/sk.json | 16 +++++++++++--- custom_components/places/translations/uk.json | 14 ++++++++++-- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 30ea2587..54669386 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,9 @@ Key | Required | Default | Description | `Map Provider` | `No` | `apple` | `google`, `apple`, `osm` `Map Zoom` | `No` | `18` | Level of zoom for the generated map link <1-20> `Language` | `No` |location's local language | Requested\* language(s) for state and attributes. Two-Letter language code(s), separated by commas.
\*Refer to [Notes](#notes) +`Use GPS Accuracy` | `No` | `True` | Use GPS Accuracy when determining whether to update the places sensor (if 0, don't update the places sensor). By not updating when GPS Accuracy is 0, should prevent inaccurate locations from being set in the places sensors.

**Set this to `False` if your Device Tracker has a GPS Accuracy (`gps_accuracy`) attribute, but it always shows 0 even if the latitude and longitude are correct.** `Extended Attributes` | `No` | `False` | Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict *(if they exist)*. Provides many additional attributes for advanced logic. **Warning, this will make the attributes very long!** `Show Last Updated` | `No` | `False` | Show last updated time at end of state `(since xx:yy)` -`Use GPS Accuracy` | `No` | `True` | Use GPS Accuracy when determining whether to update the places sensor (if 0, don't update the places sensor). By not updating when GPS Accuracy is 0, should prevent inaccurate locations from being set in the places sensors.

**Set this to `False` if your Device Tracker has a GPS Accuracy (`gps_accuracy`) attribute, but it always shows 0 even if the latitude and longitude are correct.**

Advanced Display Options

diff --git a/custom_components/places/config_flow.py b/custom_components/places/config_flow.py index b6ed7ebb..f5698e14 100644 --- a/custom_components/places/config_flow.py +++ b/custom_components/places/config_flow.py @@ -232,6 +232,9 @@ async def async_step_user( ) ), vol.Optional(CONF_LANGUAGE): str, + vol.Optional(CONF_USE_GPS, default=DEFAULT_USE_GPS): selector.BooleanSelector( + selector.BooleanSelectorConfig() + ), vol.Optional( CONF_EXTENDED_ATTR, default=DEFAULT_EXTENDED_ATTR ): selector.BooleanSelector(selector.BooleanSelectorConfig()), @@ -248,9 +251,6 @@ async def async_step_user( mode=selector.SelectSelectorMode.DROPDOWN, ) ), - vol.Optional(CONF_USE_GPS, default=DEFAULT_USE_GPS): selector.BooleanSelector( - selector.BooleanSelectorConfig() - ), } ) # If there is no user input or there were errors, show the form again, including any errors that were found with the input. @@ -393,6 +393,10 @@ async def async_step_init( "suggested_value": self.config_entry.data.get(CONF_LANGUAGE, None) }, ): str, + vol.Optional( + CONF_USE_GPS, + default=(self.config_entry.data.get(CONF_USE_GPS, DEFAULT_USE_GPS)), + ): selector.BooleanSelector(selector.BooleanSelectorConfig()), vol.Optional( CONF_EXTENDED_ATTR, default=(self.config_entry.data.get(CONF_EXTENDED_ATTR, DEFAULT_EXTENDED_ATTR)), @@ -417,10 +421,6 @@ async def async_step_init( mode=selector.SelectSelectorMode.DROPDOWN, ) ), - vol.Optional( - CONF_USE_GPS, - default=(self.config_entry.data.get(CONF_USE_GPS, DEFAULT_USE_GPS)), - ): selector.BooleanSelector(selector.BooleanSelectorConfig()), } ) diff --git a/custom_components/places/translations/en.json b/custom_components/places/translations/en.json index 13b8a718..d57de68d 100644 --- a/custom_components/places/translations/en.json +++ b/custom_components/places/translations/en.json @@ -13,12 +13,17 @@ "map_zoom": "Map Zoom", "api_key": "Email to use as OpenStreetMap API Key (optional)", "language": "Language (optional)", + "use_gps_accuracy": "Use GPS Accuracy", "extended_attr": "Enable Extended Attributes", "show_time": "Show last updated time at end of state '(since xx:yy)'", - "date_format": "Date format to show at end of state when not changed >24h", - "use_gps_accuracy": "Use GPS Accuracy" + "date_format": "Date format to show at end of state when not changed >24h" }, - "description": "Create a new sensor\nSee [Configuration Options]({component_config_url}) on GitHub for details" + "description": "Create a new sensor\nSee [Configuration Options]({component_config_url}) on GitHub for details", + "data_description": { + "options": "See [Configuration Options]({component_config_url}) on GitHub for details", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } }, @@ -34,12 +39,17 @@ "map_zoom": "Map Zoom", "api_key": "Email to use as OpenStreetMap API Key (optional)", "language": "Language (optional)", + "use_gps_accuracy": "Use GPS Accuracy", "extended_attr": "Enable Extended Attributes", "show_time": "Show last updated time at end of state '(since xx:yy)'", - "date_format": "Date format to show at end of state when not changed >24h", - "use_gps_accuracy": "Use GPS Accuracy" + "date_format": "Date format to show at end of state when not changed >24h" }, - "description": "**Updating sensor: {sensor_name}**\nSee [Configuration Options]({component_config_url}) on GitHub for details" + "description": "**Updating sensor: {sensor_name}**\nSee [Configuration Options]({component_config_url}) on GitHub for details", + "data_description": { + "options": "See [Configuration Options]({component_config_url}) on GitHub for details", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } } diff --git a/custom_components/places/translations/ru.json b/custom_components/places/translations/ru.json index 058b0d3c..1577be02 100644 --- a/custom_components/places/translations/ru.json +++ b/custom_components/places/translations/ru.json @@ -17,7 +17,12 @@ "show_time": "Показать время последнего обновления в конце состояния '(начиная с xx:yy)'", "use_gps_accuracy": "Используйте точность GPS" }, - "description": "Создайте новый датчик\nПодробнее см. [Параметры конфигурации]({component_config_url}) на GitHub." + "description": "Создайте новый датчик\nПодробнее см. [Параметры конфигурации]({component_config_url}) на GitHub.", + "data_description": { + "options": "Подробнее см. [Параметры конфигурации]({component_config_url}) на GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } }, @@ -37,7 +42,12 @@ "show_time": "Показать время последнего обновления в конце состояния '(начиная с xx:yy)'", "use_gps_accuracy": "Используйте точность GPS" }, - "description": "**Обновление сенсора: {sensor_name}**\nПодробности см. в [Параметры конфигурации]({component_config_url}) на GitHub." + "description": "**Обновление сенсора: {sensor_name}**\nПодробности см. в [Параметры конфигурации]({component_config_url}) на GitHub.", + "data_description": { + "options": "Подробнее см. [Параметры конфигурации]({component_config_url}) на GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } } diff --git a/custom_components/places/translations/sk.json b/custom_components/places/translations/sk.json index f9ffcddc..dbad4f34 100644 --- a/custom_components/places/translations/sk.json +++ b/custom_components/places/translations/sk.json @@ -18,7 +18,12 @@ "date_format": "Formát dátumu, ktorý sa zobrazí na konci stavu, keď sa nezmení >24 hodín", "use_gps_accuracy": "Použite presnosť GPS" }, - "description": "Vytvorte nový senzor\nPodrobnosti nájdete v [Možnosti konfigurácie] ({component_config_url}) na GitHub" + "description": "Vytvorte nový senzor\nPodrobnosti nájdete v [Možnosti konfigurácie] ({component_config_url}) na GitHub", + "data_description": { + "options": "Podrobnosti nájdete v [Možnosti konfigurácie] ({component_config_url}) na GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } }, @@ -27,7 +32,7 @@ "init": { "title": "Miesta: OpenStreetMap snímač", "data": { - "devicetracker_id": "Tracked Entity ID", + "devicetracker_id": "ID sledovanej entity", "home_zone": "Domáca zóna", "options": "Možnosti zobrazenia", "map_provider": "Poskytovateľ mapy", @@ -39,7 +44,12 @@ "date_format": "Formát dátumu, ktorý sa zobrazí na konci stavu, keď sa nezmení >24 hodín", "use_gps_accuracy": "Použite presnosť GPS" }, - "description": "**Aktualizuje sa senzor: {sensor_name}**\nPodrobnosti nájdete v [Možnosti konfigurácie]({component_config_url}) na GitHub" + "description": "**Aktualizuje sa senzor: {sensor_name}**\nPodrobnosti nájdete v [Možnosti konfigurácie]({component_config_url}) na GitHub", + "data_description": { + "options": "Podrobnosti nájdete v [Možnosti konfigurácie] ({component_config_url}) na GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } } diff --git a/custom_components/places/translations/uk.json b/custom_components/places/translations/uk.json index dc7e086a..64dab7f6 100644 --- a/custom_components/places/translations/uk.json +++ b/custom_components/places/translations/uk.json @@ -17,7 +17,12 @@ "show_time": "Показати час останнього оновлення в кінці стану '(з xx:yy)'", "use_gps_accuracy": "Використовуйте точність GPS" }, - "description": "Create a new sensor\nSee [Configuration Options]({component_config_url}) on GitHub for details" + "description": "Create a new sensor\nДетальніше див. [Параметри конфігурації]({component_config_url}) на GitHub", + "data_description": { + "options": "Детальніше див. [Параметри конфігурації]({component_config_url}) на GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } }, @@ -37,7 +42,12 @@ "show_time": "Показати час останнього оновлення в кінці стану '(з xx:yy)'", "use_gps_accuracy": "Використовуйте точність GPS" }, - "description": "**Оновлення датчика: {sensor_name}**\nДетальніше див. [Параметри конфігурації]({component_config_url}) на GitHub" + "description": "**Оновлення датчика: {sensor_name}**\nДетальніше див. [Параметри конфігурації]({component_config_url}) на GitHub", + "data_description": { + "options": "Детальніше див. [Параметри конфігурації]({component_config_url}) на GitHub", + "extended_attr": "Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (if they exist). Provides many additional attributes for advanced logic. Warning, this will make the attributes very long!", + "use_gps_accuracy": "Set this to False if your Device Tracker has a GPS Accuracy (gps_accuracy) attribute, but it always shows 0 even if the latitude and longitude are correct." + } } } }