Skip to content

Add template extension coordinates#11482

Closed
eifinger wants to merge 1 commit into
home-assistant:nextfrom
eifinger:add_template_get_coords
Closed

Add template extension coordinates#11482
eifinger wants to merge 1 commit into
home-assistant:nextfrom
eifinger:add_template_get_coords

Conversation

@eifinger
Copy link
Copy Markdown
Contributor

Description:

This template extension will allow for a clean and reusable way to enable dynamic travel_time sensors. The issue was discussed several times in the forum here and here as well as in the PRs #27237 #28716.

Using this template the following config is possible:

input_select:
  here_destination_preset:
    options:
      - zone.home
      - zone.office
      - zone.somewheredefault

sensor:
  - platform: here_travel_time
    api_key: my_api_key
    name: Reistijd
    origin_template: {{ coordinates('device_tracker.myphone') }}
    destination_template: {{ coordinates('input_select.here_destination_preset') }}

automation:    
  - alias: 'set'
    trigger:
      - platform: homeassistant
        event: start
      - platform: time
        at: 00:00
    action:
       service: input_select.select_option
       data_template:
        entity_id: input_select.here_destination_preset
        option: "{% if is_state('device_tracker.myphone','home') %}zone.office{% elif is_state('device_tracker.myphone','office') %}zone.home{% else %}zone.somewheredefault{% endif %}"

The simple case {{ coordinates('device_tracker.myphone') }} can already be accomplished with existing methods but now the user does not have to know that a device_tracker stores latitude and longitude as attributes.

The nested case {{ coordinates('input_select.here_destination_preset') }} is currently only possible by creating a complex structure of dependent template_sensors using complex templates.

Pull request in home-assistant (if applicable): home-assistant/core#30019

Checklist:

  • Branch: next is for changes and new documentation that will go public with the next Home Assistant release. Fixes, changes and adjustments for the current release should be created against current.
  • The documentation follows the standards.

@probot-home-assistant probot-home-assistant Bot added has-parent This PR has a parent PR in another repo next This PR goes into the next branch labels Dec 17, 2019
@frenck frenck added the new-feature This PR adds documentation for a new Home Assistant feature to an existing integration label Dec 17, 2019
Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved. Can be merged as soon as the parent PR gets merged.

@frenck frenck added the awaits-parent Awaits the merge of an parent PR label Dec 17, 2019
@probot-home-assistant probot-home-assistant Bot removed the awaits-parent Awaits the merge of an parent PR label Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-parent This PR has a parent PR in another repo new-feature This PR adds documentation for a new Home Assistant feature to an existing integration next This PR goes into the next branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants