Repository navigation
feat(wall): commute, Shabbat, trash, packages and to-do context cards #1583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
stacks/sensitive/home-assistant/packages/wall_commute.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| --- | ||
| # The drive to the next event that has an address, for the office wall | ||
| # (ADR-0119): how long it takes now and when to leave. The wall shows it in | ||
| # its context card from an hour before it is time to leave until the event | ||
| # starts. | ||
| # | ||
| # The household has no fixed commute, so the destination is the calendar's: | ||
| # the next timed event that starts within three hours and whose location looks | ||
| # like a place, with a digit or a comma in it. "Teams", "Zoom" or a meeting | ||
| # link are not driven to, and are skipped. Waze is asked only while there is | ||
| # such an event, every five minutes, through | ||
| # `waze_travel_time.get_travel_times` with live traffic. That action is loaded | ||
| # by the core `waze_travel_time` integration, which has to be added once in the | ||
| # UI (its own sensor's polling can be switched off; this does not read it). | ||
| # | ||
| # Which calendars: only those labelled `wall_commute` in the UI, and none when | ||
| # none is. This is its own label, not the wall's `wall_calendar`, because the | ||
| # wall falls back to every calendar when none is labelled, and sending a | ||
| # calendar's locations out of the house needs a choice, not a default. The | ||
| # events are asked of `calendar.get_events` here, not read from | ||
| # sensor.wall_today, so Waze gets the whole location rather than the wall's | ||
| # shortened one. | ||
| # | ||
| # What leaves the house: that event's location, sent to Waze to be routed from | ||
| # the home zone. Nothing from a calendar without the label. | ||
| # | ||
| # The state is the minutes of the quickest route, or `none` when there is | ||
| # nothing to drive to or Waze did not answer, which hides the card. | ||
|
|
||
| template: | ||
| - triggers: | ||
| - trigger: time_pattern | ||
| minutes: /5 | ||
| - trigger: homeassistant | ||
| event: start | ||
| - trigger: event | ||
| event_type: event_template_reloaded | ||
| actions: | ||
| - variables: | ||
| wall_calendars: >- | ||
| {{ label_entities('wall_commute') | select('match', 'calendar\.') | sort | list }} | ||
| - if: "{{ wall_calendars | count > 0 }}" | ||
| then: | ||
| - action: calendar.get_events | ||
| target: | ||
| entity_id: "{{ wall_calendars }}" | ||
| data: | ||
| start_date_time: "{{ now() }}" | ||
| end_date_time: "{{ now() + timedelta(hours=3) }}" | ||
| response_variable: agenda | ||
| continue_on_error: true | ||
| - variables: | ||
| wall_next: >- | ||
| {% set ns = namespace(e=none) %} | ||
| {% if agenda is defined and agenda is mapping %} | ||
| {% for cal in wall_calendars %} | ||
| {% for e in agenda.get(cal, {}).get('events', []) %} | ||
| {% set place = (e.get('location') or '') | lower %} | ||
| {% if 'T' in e.start and place | ||
| and (place is search('[0-9]') or ',' in place) | ||
| and not (place is search('https?:|teams|zoom|meet\.google|webex')) %} | ||
| {% set start = as_datetime(e.start) %} | ||
| {% if start > now() and (ns.e is none or start < as_datetime(ns.e.start)) %} | ||
| {% set ns.e = { | ||
| 'title': (e.get('summary') or 'Busy')[:80], | ||
| 'start': as_local(start).isoformat(), | ||
| 'location': e.location, | ||
| } %} | ||
| {% endif %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {% endif %} | ||
| {{ ns.e if ns.e is not none else {} }} | ||
| - if: "{{ wall_next.location is defined }}" | ||
| then: | ||
| - action: waze_travel_time.get_travel_times | ||
| data: | ||
| origin: zone.home | ||
| destination: "{{ wall_next.location }}" | ||
| region: us | ||
| units: imperial | ||
| realtime: true | ||
| response_variable: wall_answer | ||
| continue_on_error: true | ||
| - variables: | ||
| wall_route: >- | ||
| {% if wall_next.location is defined and wall_answer is defined and wall_answer is mapping | ||
| and (wall_answer.routes | default([]) | count) > 0 %} | ||
| {{ wall_answer.routes | sort(attribute='duration') | first }} | ||
| {% else %} | ||
| {{ {} }} | ||
| {% endif %} | ||
| # A second block, so this can read wall_route above. | ||
| - variables: | ||
| # Five minutes to get out of the door. | ||
| wall_leave_by: >- | ||
| {% if wall_route.duration is defined %} | ||
| {{ (as_datetime(wall_next.start) - timedelta(minutes=(wall_route.duration | float(0)) + 5)).isoformat() }} | ||
| {% else %} | ||
| {{ '' }} | ||
| {% endif %} | ||
| sensor: | ||
| - name: Wall commute | ||
| unique_id: wall_commute | ||
| icon: mdi:car-clock | ||
| state: "{{ wall_route.duration | float(0) | round(0) | int if wall_route.duration is defined else 'none' }}" | ||
| attributes: | ||
| title: "{{ wall_next.title | default('') if wall_route.duration is defined else '' }}" | ||
| start: "{{ wall_next.start | default('') if wall_route.duration is defined else '' }}" | ||
| route: "{{ wall_route.name | default('') }}" | ||
| leave_by: "{{ wall_leave_by }}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.