Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95314

Extract City from Address Returned by Google Maps

$
0
0

@mouthpiec wrote:

I have the following sensors which return the address among other attributes

# Travel time from Dist Location to Home
  - platform: google_travel_time
    name: Dist To Home
    api_key: abcdefghijklmnopqrstuvwxyz
    origin:  device_tracker.life360_mobile
    destination: zone.home

The above returns a string with the address in the attribute origin_addresses.
Now I am using the following sensor to extract the address, but I would like to extract only the Town/City, which is the string between commas, e.g. [‘8 Big Street, Valletta, Malta’] .
Is there a way to extract only the string Valletta instead of the whole string?

# Mobile Current Location
  - platform: template
    sensors:
      mobile_current_location:
        value_template: '{{ states.sensor.dist_to_home.attributes.origin_addresses|default(0) }}'
        friendly_name: Mobile Current Location
        icon_template: mdi:crosshairs-gps

thanks in advance

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>