Custom data filtering
I am new in Home Assistant world so maybe I am missing something but I was unable to find a way how to filter data displayed by flex-table-card. And by filtering I mean for example filtering by trip_headsign.
What I want to achieve is to display trains departing from Praha-Smíchov but I am only interested in direction out of the city, not to Praha hl.n..
I had expected to be able to filter either in flex-table-card entities or somewhere in between PID integration and the dashboard but found nothing :-)
Am I missing something or is the only way to add a custom filtering feature to PID integration itself?
@zdeseb Apologies for not responding earlier. Did you manage to find the solution? In case of buses and trams, this is handled on the integration level due to the fact that different directions have different platforms. In case of trains, unfortunately, there is only 1 platform for both directions. So it cannot be handled in the integration level, but it has to be handled on the dashboard (card) level. I believe such filtering should be possible with flex-table-card, I will have a look over the weekend.
@dvejsada I hoped flex-table-card had such an possibility but haven't found any. Eventually I tried entity-filter combined with flex-table-card inside but there are some problems while rendering dashboard (it works fine while I am adding the card but after refreshing dashboard there is a JS error - didn't have time to investigate further).
My idea how to implement the feature into PID integration was to add new editable parameter (similar way user selects the stop but without the dropdown, just text box) when adding new device. This value would be optional containing some filter expression. Question is if it could be done in some flexible way, unfortunately Python is not my cup of tea.
Yeah, I tried today, I also haven't found a way how to do that via flex-table-card.
Hi, first of all, thanks @dvejsada fort this excellent integration. I've been trying to solve a similar problem with filtering trains. I've managed to find a working solution using another hacs component auto-entitites.
My card now looks something like this:
type: custom:auto-entities
filter:
include:
- entity_id: sensor.praha_liben_next_route_*
attributes:
trip_headsign: "Praha*"
card:
type: custom:flex-table-card
title: Odjezdy
columns:
- data: icon
name: []
- data: departure_time_sched
name: TIME
modify: x.match(/[0-9]{2}:[0-9]{2}/);
- data: state
name: LINE
- data: trip_headsign
name: DESTINATION
- data: is_delay_avail
name: DELAY
modify: |-
if (x){
Math.floor(this.entity.attributes.delay_sec/60) + " min."
} else {
"-"
};
Lovely, thanks for the tip. I filtered lines specifically which works for my case (but might not for others):
title: Odjezdy z Bořislavky
type: custom:auto-entities
filter:
include:
- entity_id: sensor.borislavka_g_next_route_name_*
state: "161"
- entity_id: sensor.borislavka_g_next_route_name_*
state: "312"
- entity_id: sensor.borislavka_g_next_route_name_*
state: "907"
card:
type: custom:flex-table-card
title: Odjezdy
columns:
- data: icon
name: []
- data: departure_time_sched
name: TIME
modify: x.match(/[0-9]{2}:[0-9]{2}/);
- data: state
name: LINE
- data: trip_headsign
name: DESTINATION
- data: is_delay_avail
name: DELAY
modify: |-
if (x){
Math.floor(this.entity.attributes.delay_sec/60) + " min."
} else {
"-"
};