Hi,
I don’t have the exact same setup anymore, but here is what I have now:
In configuration.yaml I am creating new sensors with reference to the original sensor, to be able to sort the cards according departure time (including delay). Here example of sensor oebb0, I created another with oebb1 too, as I want to display just the next 2 connections.
- sensor:
- name: "oebb0"
state: >
{{ strptime(state_attr('sensor.oebb_journey_0', 'startDate') + " " + state_attr('sensor.oebb_journey_0', 'startTime'), '%d.%m.%Y %H:%M') }}
attributes:
actualDeparture: >
{% if state_attr('sensor.oebb_journey_0', 'rt') == false %}
{{ strptime(state_attr('sensor.oebb_journey_0', 'startDate') + " " + state_attr('sensor.oebb_journey_0', 'startTime'), '%d.%m.%Y %H:%M') }}
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] == 'Ausfall' %}
{{ strptime(state_attr('sensor.oebb_journey_0', 'startDate') + " " + state_attr('sensor.oebb_journey_0', 'startTime'), '%d.%m.%Y %H:%M') }}
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] is none %}
{{ strptime(state_attr('sensor.oebb_journey_0', 'startDate') + " " + state_attr('sensor.oebb_journey_0', 'rt')['dlt'], '%d.%m.%Y %H:%M') }}
{% endif %}
scheduledTime: >
{{ state_attr('sensor.oebb_journey_0', 'startTime') }}
actualTime: >
{% if state_attr('sensor.oebb_journey_0', 'rt') == false %}
{{ state_attr('sensor.oebb_journey_0', 'startTime') }}
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] is none %}
{{ state_attr('sensor.oebb_journey_0', 'rt')['dlt'] }}
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] == 'Ausfall' %}
{{ state_attr('sensor.oebb_journey_0', 'startTime') }}
{% endif %}
lastStop: >
{{ ((state_attr('sensor.oebb_journey_0', 'lastStop'))) | replace('Bahnhof', '') | replace('Hbf', '') | replace('.', '. ') | replace('ö', 'ö') }}
line: >
{{ ((state_attr('sensor.oebb_journey_0', 'line'))) | replace(' ', '') }}
status: >
{% if state_attr('sensor.oebb_journey_0', 'rt') == false %}
PĂĽnktlich
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] is none %}
Verspätet
{% elif state_attr('sensor.oebb_journey_0', 'rt')['status'] == 'Ausfall' %}
Ausfall
{% endif %}
And then I made the cards with the mushroom template card and auto-entities to sort it:
- type: custom:auto-entities
card:
type: grid
columns: 2
square: false
card_param: cards
filter:
include:
- entity_id: sensor.oebb0
options:
type: custom:mushroom-template-card
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
icon: mdi:tram
icon_color: >
{% if state_attr('sensor.oebb0', 'status') == 'PĂĽnktlich' %} green
{% elif state_attr('sensor.oebb0', 'status') == 'Verspätet' %}
orange {% elif state_attr('sensor.oebb0', 'status') == 'Ausfall'
%} red {% endif %}
primary: |
{{ state_attr('sensor.oebb0', 'actualTime') }}
secondary: |
{{ state_attr('sensor.oebb0', 'line') }}
layout: vertical
- entity_id: sensor.oebb1
options:
type: custom:mushroom-template-card
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
icon: mdi:tram
icon_color: >
{% if state_attr('sensor.oebb1', 'status') == 'PĂĽnktlich' %} green
{% elif state_attr('sensor.oebb1', 'status') == 'Verspätet' %}
orange {% elif state_attr('sensor.oebb1', 'status') == 'Ausfall'
%} red {% endif %}
primary: |
{{ state_attr('sensor.oebb1', 'actualTime') }}
secondary: |
{{ state_attr('sensor.oebb1', 'line') }}
layout: vertical
sort:
method: attribute
attribute: actualDeparture