Display sensor only under certain conditions

I currently use the London Underground sensor to show the status of the 12 London underground lines. Obviously, this takes up a fair amount of space on the view. Since (fingers crossed) they show ‘good service’ most of the time, I’d like to be able to display only those lines which are not showing ‘good service’. I.e. Only the lines that are currently having issues would show up on the view, rather than every single line.

The only way I figured out how to do this was working with groups and setting their visibility to true or false by using automations (https://home-assistant.io/docs/configuration/group_visibility/).

Unless you can template this sensor somehow to do it for each and every line you will need 1 group and 2 automations for each line. One automation for each line that turns the group’s visibility off when the line shows ‘good service’ and one that turns it back on if it doesn’t.

Here’s an example for my garage door cover that I only want to be visible if I consciously decide to do so and manually switch it on in order to avoid me opening the garage door by accident while I’m away.

# Show Garage Door Switch only when activated
- alias: Visibility Garage Door Switch On
  trigger:
    platform: state
    entity_id: input_boolean.garage_door_cover_visible
    to: 'on'
  action:
    service: group.set_visibility
    entity_id: group.garage_door
    data:
      visible: True
- alias: Visibility Garage Door Switch Off
  trigger:
    platform: state
    entity_id: input_boolean.garage_door_cover_visible
    to: 'off'
  action:
    service: group.set_visibility
    entity_id: group.garage_door
    data:
      visible: False

I came across this example yesterday but haven’t had the time yet to try it out to see if I can make this work for the individual sensor rather than having to put it into a group and change the properties of the group:

customize:
    binary_sensor.espeasy_01_pool_water_level_low:
      hidden: true
    binary_sensor.espeasy_01_pool_water_level_critical:
      hidden: true

From https://neon.subspace.de/2017/11/smarter-swimming-pool-3-water-level/

Would be interested to see if you can make it work.