Advertisement
JLindvig

Untitled

Mar 19th, 2021
1,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 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. {%- for departure in state_attr(travel_sensor, "next_departures") %}
  20.   {%- if loop.index < max_listings %}
  21.   <tr>
  22.    <td><ha-icon icon="{{ icon }}"></ha-icon></td>
  23.    <td>{{ departure.route }}</td>
  24.    <td><span>{{ "nu" if departure.due_in | int == 0 else "om "~departure.due_in~" minut"~("ter" if departure.due_in | int > 1)}}</span></td>
  25.    <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>
  26.   </tr>
  27.  {%- endif %}
  28. {%- endfor %}
  29. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement