View difference between Paste ID: 438uQxWD and 4hcSFU2g
SHOW: | | - or go back to the newest paste.
1
{% set travel_sensor = "sensor.busmodaalborg" %}
2
{% set ts_format = "kl. %R" %}
3
{% set max_listings = 5 %}
4
{% set headers = ["", "Rute", "Afgang", "Planlagt afgang"] %}
5
{% set icon = "mdi:bus" %}
6
7
<table width="100%">
8
  <tr>
9
{%- for header in headers %}
10
    <th align="left">{{ header }}</th>
11
{%- endfor %}
12
  </tr>
13
  <tr>
14
    <td><ha-icon icon="{{ icon }}"></ha-icon></td>
15
    <td>{{ state_attr(travel_sensor, "route") }}</td>
16-
    <td><span>{{ "nu" if states(travel_sensor) | int == 0 }}{{ "om " + states(travel_sensor) + " minut" if states(travel_sensor) | int > 0 }}{{ "ter" if states(travel_sensor) | int > 1 }}{{ "er kørt" if states(travel_sensor) | int < 0 }}</span></td>
16+
    <td><span>{{ "nu" if states(travel_sensor) | int == 0 else "om "~states(travel_sensor)~" minut"~("ter" if states(travel_sensor) | int > 1)}}</span></td>
17
    <td><span>{{ strptime(state_attr(travel_sensor, "scheduled_at"), "%d.%m.%y %H:%M").timestamp() | timestamp_custom(ts_format) }}{% if state_attr(travel_sensor, "real_time_at") is not none %} (ny tid: {{ strptime(state_attr(travel_sensor, "real_time_at"), "%d.%m.%y %H:%M").timestamp() | timestamp_custom("%R")}}){% endif %}</span></td>
18
  </tr>
19
20
{%- for departure in state_attr(travel_sensor, "next_departures") %}
21
  {%- if loop.index < max_listings %}
22
  <tr>
23
    <td><ha-icon icon="{{ icon }}"></ha-icon></td>
24
    <td>{{ departure.route }}</td>
25-
    <td><span>{{ "nu" if departure.due_in | int == 0 }}{{ "om " if departure.due_in | int > 0 }}{{ departure.due_in if departure.due_in | int > 0 }}{{ " minut" if departure.due_in | int > 0 }}{{ "ter" if departure.due_in | int > 1 }}{{ "er kørt" if departure.due_in | int < 0 }}</span></td>
25+
    <td><span>{{ "nu" if departure.due_in | int == 0 else "om "~departure.due_in~" minut"~("ter" if departure.due_in | int > 1)}}</span></td>
26
    <td><span>{{ strptime(departure.due_at, "%d.%m.%y %H:%M").timestamp() | timestamp_custom(ts_format) }}{% if state_attr(travel_sensor, "real_time_at") is not none %} (ny tid: {{ strptime(state_attr(travel_sensor, "real_time_at"), "%d.%m.%y %H:%M").timestamp() | timestamp_custom("%R")}}){% endif %}</span></td>
27
  </tr>
28
  {%- endif %}
29
{%- endfor %}
30
</table>