Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 35 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,29 @@
[![Coverage][coverage-shield]][coverage]
[![License][license-shield]](LICENSE)
[![hacs][hacsbadge]][hacs]
[![Community Forum][community-forum-shield]](community-forum)

_Component to integrate with OpenStreetMap Reverse Geocode and create a sensor with numerous address and place attributes from a device_tracker, person, or sensor_

## Installation
### HACS *(recommended)*
1. Ensure that [HACS](https://hacs.xyz/) is installed
1. [Click Here](https://my.home-assistant.io/redirect/hacs_repository/?owner=custom-components&repository=places) to directly open `places` in HACS **or**<br/>
  a. Navigate to HACS<br/>
  b. Click `+ Explore & Download Repositories`<br/>
  c. Find the `places` integration <br/>
1. Click `Download`
1. Restart Home Assistant
1. See [Configuration](#configuration) below

<details>
<summary><h3>Manual</h3></summary>
## Installation via HACS

You probably <u>do not</u> want to do this! Use the HACS method above unless you know what you are doing and have a good reason as to why you are installing manually
Ensure that [HACS](https://hacs.xyz/) is installed

1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`)
1. If you do not have a `custom_components` directory there, you need to create it
1. In the `custom_components` directory create a new folder called `places`
1. Download _all_ the files from the `custom_components/places/` directory in this repository
1. Place the files you downloaded in the new directory you created
1. Restart Home Assistant
1. See [Configuration](#configuration) below
<a href="https://my.home-assistant.io/redirect/hacs_repository/?owner=custom-components&repository=places" target="_blank" rel="noreferrer noopener"><img src="https://my.home-assistant.io/badges/hacs_repository.svg" alt="Open your Home Assistant instance to download the places integration." /></a>

Using your HA configuration directory as a starting point you should now also have this:
```text
custom_components/places/__init__.py
custom_components/places/config_flow.py
custom_components/places/const.py
custom_components/places/manifest.json
custom_components/places/sensor.py
custom_components/places/strings.json
custom_components/places/translations
custom_components/places/translations/en.json
```
</details>
Download the `places` integration

Restart Home Assistant

## Configuration
**Configuration is done in the Integrations section of Home Assistant.**
1. [Click Here](https://my.home-assistant.io/redirect/config_flow_start/?domain=places) to directly add a `places` sensor **or**<br/>
  a. In Home Assistant, go to Settings -> [Integrations](https://my.home-assistant.io/redirect/integrations/)<br/>
  b. Click `+ Add Integrations` and select `places`<br/>
1. Add your configuration ([see Configuration Options below](#configuration-options))
1. Click `Submit`
* Repeat as needed to create additional `places` sensors
* Options can be changed for existing `places` sensors in Home Assistant Integrations by selecting `Configure` under the desired `places` sensor.

<a href="https://my.home-assistant.io/redirect/config_flow_start/?domain=places" target="_blank" rel="noreferrer noopener"><img src="https://my.home-assistant.io/badges/config_flow_start.svg" alt="Open your Home Assistant instance to create a places entry." /></a>

[See Configuration Options below](#configuration-options)

Repeat as needed to create additional `places` entries

Options for existing places entries can be changed by clicking the gear icon next to the desired entry under Settings > Devices & services > `places` integration.

## Configuration Options

Expand All @@ -87,13 +60,16 @@ To use, simply enter your advanced options into the `display_options` text area.
__Tip:__ _Build your advanced display options string in a text editor and copy/paste it into display_options field as it is pretty small._

### __Brackets [ ]:__ Fields to show if initial field is blank or empty<br />

These can be nested.

#### Examples

* `name[type]` will show the name, but if name is blank, will show the type instead. If type is also blank, nothing will show for that field
* `name[type[category]]` will show the name, but if name is blank, will show the type instead, but if type is blank, will show the category. If category is also blank, nothing will show for that field.

### __Parenthesis ( ):__ Inclusion/Exclusion Logic to filter the field<br />

#### To include/exclude based on the main field

* __Include:__ Set the first item inside the parenthesis to + to only show the field if it equals one of the states listed
Expand Down Expand Up @@ -129,11 +105,14 @@ These can be nested.
### Brackets and Parenthesis can also be combined

* To recreate `place`:
```

```text
name_no_dupe, category(-, place), type(-, yes), neighborhood, house_number, street
```

* To recreate `formatted_place`:
```

```text
zone_name[driving, name_no_dupe[type(-, unclassified, category(-, highway))[category(-, highway)], house_number, route_number(type(+, motorway, trunk))[street[route_number]], neighborhood(type(house))], city_clean[county], state_abbr]
```

Expand Down Expand Up @@ -174,7 +153,7 @@ __Note:__ `place` and `formatted_place` are not valid fields in the advanced dis

```json
{
"formatted_address": "Richmond Hill GO Station, 6, Newkirk Road, Beverley Acres, Richmond Hill, York Region, Ontario, L4C 1B3, Canada",
"formatted_address": "Richmond Hill GO Station, 6, Cherry Road, Beverley Acres, Richmond Hill, York Region, Ontario, L4C 1B3, Canada",
"friendly_name": "sharon",
"current_latitude": "43.874149009154095",
"distance_from_home_km": 7.24,
Expand All @@ -201,17 +180,19 @@ __Note:__ `place` and `formatted_place` are not valid fields in the advanced dis
"place_type": "building",
"previous_latitude": "43.86684124904056",
"place_name": "Richmond Hill GO Station",
"street": "Newkirk Road",
"street": "Cherry Road",
"city": "Richmond Hill",
"home_zone": "zone.sharon_home"
}
```

</details>

<details>
<summary>Sample generic `automations.yaml` snippet to send an iOS notify on any device state change</summary>

(the only difference is the second one uses a condition to only trigger for a specific user)

```yaml
- alias: ReverseLocateEveryone
initial_state: 'on'
Expand All @@ -232,14 +213,14 @@ __Note:__ `place` and `formatted_place` are not valid fields in the advanced dis
url: '{{ trigger.event.data.map_link }}'
hide_thumbnail: false

- alias: ReverseLocateAidan
- alias: ReverseLocateFred
initial_state: 'on'
trigger:
platform: event
event_type: places_state_update
condition:
condition: template
value_template: '{{ trigger.event.data.entity == "aidan" }}'
value_template: '{{ trigger.event.data.entity == "fred" }}'
action:
- service: notify.ios_jim_iphone8
data_template:
Expand All @@ -254,16 +235,19 @@ __Note:__ `place` and `formatted_place` are not valid fields in the advanced dis
url: '{{ trigger.event.data.map_link }}'
hide_thumbnail: false
```

</details>

## Notes

* This component is only useful to those who have device tracking enabled via a mechanism that provides latitude and longitude coordinates (such as the [Home Assistant Mobile App](https://www.home-assistant.io/integrations/mobile_app/), [OwnTracks](https://www.home-assistant.io/integrations/owntracks/), or [iCloud3](https://github.com/gcobb321/icloud3)).
* The OpenStreetMap database is very flexible with regards to tag_names in their database schema. If you come across a set of coordinates that do not parse properly, you can enable debug logging (see below) to see the actual JSON that is returned from the query.
* The OpenStreetMap API requests that you include your valid e-mail address in each API call if you are making a large numbers of requests. They say that this information will be kept confidential and only used to contact you in the event of a problem, see their Usage Policy for more details.
* The map link that gets generated for Google, Apple or OpenStreetMaps has a push pin marking the users location. Note that when opening the Apple link on a non-Apple device, it will open in Google Maps.
* When no `language` value is given, default language will be in the location's local language. When a comma separated list of languages is provided - the component will attempt to fill each address field in desired languages by order.
* The map link that gets generated for Google, Apple or OpenStreetMaps has a push pin marking the users location.
* When no `language` value is given, default language will be in the location's local language. When a comma-separated list of languages is provided - the component will attempt to fill each address field in desired languages by order.
* Translations are partial in OpenStreetMap database. For each field, if a translation is missing in first requested language it will be resolved with a language following in the provided list, defaulting to local language if no matching translations were found for the list.
* To enable debug logging for this component, add the following to your `configuration.yaml` file

```yaml
logger:
  default: warning
Expand All @@ -281,10 +265,12 @@ python -m pip install --group dev -e .
```

## Prior Contributions:

* Previous Authors: [Jim Thompson](https://github.com/tenly2000) & [Ian Richardson](https://github.com/iantrich)
* Current Author: [Snuffy2](https://github.com/Snuffy2)

## Contributions are welcome!

If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)
***

Expand All @@ -299,7 +285,5 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
[license-shield]: https://img.shields.io/github/license/custom-components/places?color=blue&style=for-the-badge
[hacsbadge]: https://img.shields.io/badge/HACS-Default-blue.svg?style=for-the-badge
[hacs]: https://hacs.xyz
[community-forum-shield]: https://img.shields.io/badge/community-forum-orange.svg?label=HA%20Community&style=for-the-badge
[community-forum]: https://community.home-assistant.io/t/reverse-geocode-sensor-places-using-openstreetmap-custom-component
[coverage]: https://htmlpreview.github.io/?https://github.com/custom-components/places/blob/python-coverage-comment-action-data/htmlcov/index.html
[coverage-shield]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcustom-components%2Fplaces%2Fpython-coverage-comment-action-data%2Fendpoint.json&style=for-the-badge
55 changes: 55 additions & 0 deletions cspell.config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
language = "en"
allowCompoundWords = false
caseSensitive = false
import = [
"@cspell/dict-cs-cz/cspell-ext.json",
"@cspell/dict-it-it/cspell-ext.json",
"@cspell/dict-ru_ru/cspell-ext.json",
"@cspell/dict-sk-sk/cspell-ext.json",
"@cspell/dict-uk-ua/cspell-ext.json",
]

words = [
"aiohttp",
"automations",
"conftest",
"devicetracker",
"docstrings",
"entityid",
"hacs",
"hass",
"homeassistant",
"licence",
"mypy",
"neighbourhood",
"nbsp",
"parameterizing",
"prek",
"pyproject",
"pytest",
"venv",
]

[[overrides]]
filename = "**/custom_components/places/translations/cs.json"
language = "cs,en"

[[overrides]]
filename = "**/custom_components/places/translations/en.json"
language = "en"

[[overrides]]
filename = "**/custom_components/places/translations/it.json"
language = "it,en"

[[overrides]]
filename = "**/custom_components/places/translations/ru.json"
language = "ru,en"

[[overrides]]
filename = "**/custom_components/places/translations/sk.json"
language = "sk,en"

[[overrides]]
filename = "**/custom_components/places/translations/uk.json"
language = "uk,en"
24 changes: 12 additions & 12 deletions custom_components/places/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"options": "Možnosti zobrazení",
"map_provider": "Poskytovatel mapy",
"map_zoom": "Přiblížení mapy",
"api_key": "E-mail na použití jako OpenStreetMap API Key (volitelné)",
"api_key": "E-mail použitý jako klíč OpenStreetMap API (volitelné)",
"language": "Jazyk (volitelné)",
"extended_attr": "Povolit rozšířené atributy",
"show_time": "Zobrazit čas poslední aktualizace na konci stavu '(od xx:yy)'",
"date_format": "Formát datumu, který se zobrazí na konci stavu, když se nezmení za 24 hodin",
"date_format": "Formát data, který se zobrazí na konci stavu, když se nezmění za 24 hodin",
"use_gps_accuracy": "Použití přesnosti GPS"
},
"description": "Vytvořte nový senzor\nPodrobnosti najdete v [Možnosti konfigurace] ({component_config_url}) na GitHub",
"description": "Vytvořte nový senzor\nPodrobnosti najdete v [Možnosti konfigurace]({component_config_url}) na GitHub",
"data_description": {
"options": "Podrobnosti najdete v [Možnosti konfigurace] ({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": "Nastavte toto na False, pokud má váš nástroj pro sledování zařízení atribut Přesnost GPS (gps_accuracy), ale vždy zobrazuje 0, i když jsou zeměpisná šířka a délka správné."
"options": "Podrobnosti najdete v [Možnosti konfigurace]({component_config_url}) na GitHub",
"extended_attr": "Zobrazit rozšířené atributy: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (pokud existují). Poskytuje mnoho dalších atributů pro pokročilou logiku. Upozornění: atributy budou velmi dlouhé!",
"use_gps_accuracy": "Tuto možnost vypněte, pokud má váš nástroj pro sledování zařízení atribut přesnosti GPS (gps_accuracy), ale vždy zobrazuje 0, i když jsou zeměpisná šířka a délka správné."
}
}
}
Expand All @@ -51,18 +51,18 @@
"options": "Možnosti zobrazení",
"map_provider": "Poskytovatel mapy",
"map_zoom": "Přiblížení mapy",
"api_key": "E-mail na použití jako OpenStreetMap API Key (volitelné)",
"api_key": "E-mail použitý jako klíč OpenStreetMap API (volitelné)",
"language": "Jazyk (volitelné)",
"extended_attr": "Povolit rozšírené atributy",
"extended_attr": "Povolit rozšířené atributy",
"show_time": "Zobrazit čas poslední aktualizace na konci stavu '(od xx:yy)'",
"date_format": "Formát datumu, který se zobrazí na konci stavu, když se nezmení za 24 hodín",
"date_format": "Formát data, který se zobrazí na konci stavu, když se nezmění za 24 hodin",
"use_gps_accuracy": "Použití přesnosti GPS"
},
"description": "**Aktualizuje se senzor:&nbsp;{sensor_name}**\nPodrobnosti najdete v [Možnosti konfigurace]({component_config_url}) na GitHub",
"data_description": {
"options": "Podrobnosti najdete v [Možnosti konfigurace] ({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": "Nastavte toto na False, pokud má váš nástroj pro sledování zařízení atribut Přesnost GPS (gps_accuracy), ale vždy zobrazuje 0, i když jsou zeměpisná šířka a délka správné."
"options": "Podrobnosti najdete v [Možnosti konfigurace]({component_config_url}) na GitHub",
"extended_attr": "Zobrazit rozšířené atributy: wikidata_id, osm_dict, osm_details_dict, wikidata_dict (pokud existují). Poskytuje mnoho dalších atributů pro pokročilou logiku. Upozornění: atributy budou velmi dlouhé!",
"use_gps_accuracy": "Tuto možnost vypněte, pokud má váš nástroj pro sledování zařízení atribut přesnosti GPS (gps_accuracy), ale vždy zobrazuje 0, i když jsou zeměpisná šířka a délka správné."
}
}
}
Expand Down
Loading
Loading