-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvehicle-tracker-map.yaml
More file actions
118 lines (108 loc) · 3.89 KB
/
vehicle-tracker-map.yaml
File metadata and controls
118 lines (108 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Itinerary tab to let you display drivers' ETAs, disable Automatic Gate and view people's locations
# Please search for "EDIT" comments and modify each corresponding line
title: Itinerary
path: vehicle-tracker-map
icon: mdi:map
subview: false
type: sections
max_columns: 4
cards: []
sections:
- type: grid
column_span: 1
cards:
# Let users disable Automatic Gate
- type: entities
entities:
- entity: automation.automatic_gate # EDIT
secondary_info: none
name: Automatic Gate
icon: mdi:car-connected
# EDIT: Duplicate this card as many times as you have drivers set in Automatic Gate
- type: custom:mushroom-template-card
# Show the ETA only if someone is driving
visibility:
- condition: state
entity: sensor.user0_driving_sensor # EDIT
state: on
# Estimated time remaining
primary: >-
{# EDIT #}
{% set travel_time_sensor = 'sensor.user0_travel_time_duration' %}
Time remaining :
{% if travel_time_sensor | has_value %}
{% if state_attr(travel_time_sensor, 'unit_of_measurement') in ['min', 's'] %}
{% set value = states(travel_time_sensor) | float %}
{% if state_attr(travel_time_sensor, 'unit_of_measurement') == 'min' %}
{% set value = value * 60 %}
{% endif %}
{% set remaining = (
states[travel_time_sensor].last_updated | as_timestamp
- now() | as_timestamp
+ value
)
%}
{% if remaining >= 60 %}
{{ (remaining / 60) | round(0) }}min
{% elif remaining > 0 %}
{{ remaining | round(0) }}s
{% elif remaining > 120 %}
Soon
{% else %}
Time passed
{% endif %}
{% else %}
Unsupported sensor
{% endif %}
{% else %}
Unknown
{% endif %}
# Estimated time of arrival
secondary: >-
{# EDIT #}
{% set travel_time_sensor = 'sensor.user0_travel_time_duration' %}
Arrival :
{% if travel_time_sensor | has_value %}
{% if state_attr(travel_time_sensor, 'unit_of_measurement') in ['min', 's'] %}
{% set value = states(travel_time_sensor) | float %}
{% if state_attr(travel_time_sensor, 'unit_of_measurement') == 'min' %}
{% set value = value * 60 %}
{% endif %}
{% set eta = states[travel_time_sensor].last_updated | as_timestamp + value %}
{{ eta | timestamp_custom('%R') }}
{% set eta_date = eta | timestamp_custom('%D') %}
{% set now_date = now() | as_timestamp | timestamp_custom('%D') %}
{{ eta_date if eta_date != now_date }}
{% else %}
Unsupported sensor
{% endif %}
{% else %}
Unknown
{% endif %}
icon: mdi:map-clock
entity: sensor.user0_travel_time_duration # EDIT
color: blue
# Refresh travel time sensor on tap
tap_action:
action: call-service
service: homeassistant.update_entity
target:
entity_id: sensor.user0_travel_time_duration # EDIT
hold_action:
action: more-info
double_tap_action:
action: none
features_position: bottom
layout_options:
grid_columns: 4
grid_rows: 1
# Display users' position history for the last 1 hour
- type: map
entities:
- entity: person.user0 # EDIT
- entity: person.user1 # EDIT
- entity: person.user2 # EDIT
hours_to_show: 1
layout_options:
grid_columns: 4
grid_rows: 8