Advertisement
JLindvig

Rejseplanen HTML kort

Mar 19th, 2021 (edited)
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.33 KB | None | 0 0
  1. {% set travel_sensor = "sensor.busser_fra_marsk_billesvej" %}
  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>{{ 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>om {{ states(travel_sensor) }} minut{{ "ter" if states(travel_sensor) | int > 1 }}</span></td>
  17.    <td><span>{{ strptime(state_attr(travel_sensor, "due_at"), "%d.%m.%y %H:%M").timestamp() | timestamp_custom(ts_format) }}{% if state_attr(travel_sensor, "real_time_at") is not none %}({{ 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>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) }}</span></td>
  26.  </tr>
  27.  {%- endif %}
  28. {%- endfor %}
  29. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement