Skip to content

Commit

Permalink
Change option from Ignore GPS to Use GPS
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 committed Oct 14, 2022
1 parent 29a028a commit 095b227
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Key | Type | Required | Description | Default |
`api_key` | `string` | `False` | OpenStreetMap API key (your email address). | None
`map_provider` | `string` | `False` | `google`, `apple`, `osm` | `apple`
`map_zoom` | `number` | `False` | Level of zoom for the generated map link <1-20> | `18`
`language` | `string` | `False` | Requested<sup>\*</sup> language(s) for state and attributes. Two-Letter language code(s), separated by commas.<br><sup>\*</sup>Refer to [Notes](#notes) | location's local language
`language` | `string` | `False` | Requested<sup>\*</sup> language(s) for state and attributes. Two-Letter language code(s), separated by commas.<br /><sup>\*</sup>Refer to [Notes](#notes) | location's local language
`extended_attr` | `boolean` | `False` | Show extended attributes: wikidata_id, osm_dict, osm_details_dict, wikidata_dict *(if they exist)*. Provides many additional attributes for advanced logic. **Warning, will make the attributes very long!** | `False`
`show_time` | `boolean` | `False` | Show last updated time at end of state `(since xx:yy)` | `False`
`ignore_gps_accuracy` | `boolean` | `False` | Ignore GPS Accuracy even if the devicetracker_id reports it.<br />_Set this to true if your devicetracker_id has a GPS Accuracy (`gps_accuracy`) attribute, but it always shows 0 even if the latitude and longitude are correct._ | `False`
`use_gps_accuracy` | `boolean` | `False` | Use GPS Accuracy when determining whether to update the places sensor (if 0, don't update the places sensor). By not updaing when GPS Accuracy is 0, should prevent inaccurate locations from being set in the places sensors.<br />_Set this to `False` if your devicetracker_id has a GPS Accuracy (`gps_accuracy`) attribute, but it always shows 0 even if the latitude and longitude are correct._ | `True`
`options` | `string` | `False` | Display options: `formatted_place` *(exclusive option)*, `driving` *(can be used with formatted_place or other options)*, `zone` or `zone_name`, `place`, `place_name`, `street_number`, `street`, `city`, `county`, `state`, `postal_code`, `country`, `formatted_address`, `do_not_show_not_home` | `zone`, `place`

Sample attributes that can be used in notifications, alerts, automations, etc:
Expand Down
14 changes: 7 additions & 7 deletions custom_components/places/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
CONF_DEVICETRACKER_ID,
CONF_EXTENDED_ATTR,
CONF_HOME_ZONE,
CONF_IGNORE_GPS,
CONF_LANGUAGE,
CONF_MAP_PROVIDER,
CONF_MAP_ZOOM,
CONF_OPTIONS,
CONF_SHOW_TIME,
CONF_USE_GPS,
DEFAULT_EXTENDED_ATTR,
DEFAULT_HOME_ZONE,
DEFAULT_IGNORE_GPS,
DEFAULT_MAP_PROVIDER,
DEFAULT_MAP_ZOOM,
DEFAULT_OPTION,
DEFAULT_SHOW_TIME,
DEFAULT_USE_GPS,
DOMAIN,
HOME_LOCATION_DOMAINS,
TRACKING_DOMAINS,
Expand Down Expand Up @@ -243,7 +243,7 @@ async def async_step_user(self, user_input=None) -> FlowResult:
CONF_SHOW_TIME, default=DEFAULT_SHOW_TIME
): selector.BooleanSelector(selector.BooleanSelectorConfig()),
vol.Optional(
CONF_IGNORE_GPS, default=DEFAULT_IGNORE_GPS
CONF_USE_GPS, default=DEFAULT_USE_GPS
): selector.BooleanSelector(selector.BooleanSelectorConfig()),
}
)
Expand Down Expand Up @@ -437,11 +437,11 @@ async def async_step_init(self, user_input=None):
),
): selector.BooleanSelector(selector.BooleanSelectorConfig()),
vol.Optional(
CONF_IGNORE_GPS,
CONF_USE_GPS,
default=(
self.config_entry.data[CONF_IGNORE_GPS]
if CONF_IGNORE_GPS in self.config_entry.data
else DEFAULT_IGNORE_GPS
self.config_entry.data[CONF_USE_GPS]
if CONF_USE_GPS in self.config_entry.data
else DEFAULT_USE_GPS
),
): selector.BooleanSelector(selector.BooleanSelectorConfig()),
}
Expand Down
6 changes: 3 additions & 3 deletions custom_components/places/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
DEFAULT_MAP_ZOOM = 18
DEFAULT_OPTION = "zone_name, place"
DEFAULT_SHOW_TIME = False
DEFAULT_IGNORE_GPS = False
DEFAULT_USE_GPS = True

# Settings

Expand All @@ -44,7 +44,7 @@
CONF_NATIVE_VALUE = "native_value"
CONF_OPTIONS = "options"
CONF_SHOW_TIME = "show_time"
CONF_IGNORE_GPS = "ignore_gps"
CONF_USE_GPS = "use_gps_accuracy"
CONF_YAML_HASH = "yaml_hash"

# Attributes
Expand Down Expand Up @@ -117,7 +117,7 @@
CONF_NAME,
CONF_OPTIONS,
CONF_SHOW_TIME,
CONF_IGNORE_GPS,
CONF_USE_GPS,
CONF_UNIQUE_ID,
]
RESET_ATTRIBUTE_LIST = [
Expand Down
13 changes: 4 additions & 9 deletions custom_components/places/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@
CONF_DEVICETRACKER_ID,
CONF_EXTENDED_ATTR,
CONF_HOME_ZONE,
CONF_IGNORE_GPS,
CONF_LANGUAGE,
CONF_MAP_PROVIDER,
CONF_MAP_ZOOM,
CONF_OPTIONS,
CONF_SHOW_TIME,
CONF_USE_GPS,
CONF_YAML_HASH,
CONFIG_ATTRIBUTES_LIST,
DEFAULT_EXTENDED_ATTR,
DEFAULT_HOME_ZONE,
DEFAULT_ICON,
DEFAULT_IGNORE_GPS,
DEFAULT_MAP_PROVIDER,
DEFAULT_MAP_ZOOM,
DEFAULT_OPTION,
DEFAULT_SHOW_TIME,
DEFAULT_USE_GPS,
DOMAIN,
EVENT_ATTRIBUTE_LIST,
EXTENDED_ATTRIBUTE_LIST,
Expand Down Expand Up @@ -439,9 +439,7 @@ def __init__(self, hass, config, config_entry, name, unique_id):
self.set_attr(
CONF_SHOW_TIME, config.setdefault(CONF_SHOW_TIME, DEFAULT_SHOW_TIME)
)
self.set_attr(
CONF_IGNORE_GPS, config.setdefault(CONF_IGNORE_GPS, DEFAULT_IGNORE_GPS)
)
self.set_attr(CONF_USE_GPS, config.setdefault(CONF_USE_GPS, DEFAULT_USE_GPS))
self.set_attr(
ATTR_JSON_FILENAME,
(DOMAIN + "-" + slugify(str(self.get_attr(CONF_UNIQUE_ID))) + ".json"),
Expand Down Expand Up @@ -1146,10 +1144,7 @@ def get_gps_accuracy(self):
)
proceed_with_update = True
if not self.is_attr_blank(ATTR_GPS_ACCURACY):
if (
not self.get_attr(CONF_IGNORE_GPS)
and self.get_attr(ATTR_GPS_ACCURACY) == 0
):
if self.get_attr(CONF_USE_GPS) and self.get_attr(ATTR_GPS_ACCURACY) == 0:
proceed_with_update = False
_LOGGER.info(
"("
Expand Down
4 changes: 2 additions & 2 deletions custom_components/places/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"language": "Language (optional)",
"extended_attr": "Extended Attributes",
"show_time": "Show last updated time at end of state '(since xx:yy)'",
"ignore_gps": "Ignore GPS Accuracy"
"use_gps_accuracy": "Use GPS Accuracy"
},
"description": "Create a new sensor"
}
Expand All @@ -35,7 +35,7 @@
"language": "Language (optional)",
"extended_attr": "Enable Extended Attributes",
"show_time": "Show last updated time at end of state '(since xx:yy)'",
"ignore_gps": "Ignore GPS Accuracy"
"use_gps_accuracy": "Use GPS Accuracy"
},
"description": "Update existing sensor"
}
Expand Down
4 changes: 2 additions & 2 deletions custom_components/places/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"language": "Language (optional)",
"extended_attr": "Enable Extended Attributes",
"show_time": "Show last updated time at end of state '(since xx:yy)'",
"ignore_gps": "Ignore GPS Accuracy"
"use_gps_accuracy": "Use GPS Accuracy"
},
"description": "Create a new sensor\nSee [Configuration Options]({component_config_url}) on GitHub for details"
}
Expand All @@ -35,7 +35,7 @@
"language": "Language (optional)",
"extended_attr": "Enable Extended Attributes",
"show_time": "Show last updated time at end of state '(since xx:yy)'",
"ignore_gps": "Ignore GPS Accuracy"
"use_gps_accuracy": "Use GPS Accuracy"
},
"description": "**Updating sensor:&nbsp;{sensor_name}**\nSee [Configuration Options]({component_config_url}) on GitHub for details"
}
Expand Down

0 comments on commit 095b227

Please sign in to comment.