Skip to content

Instantly share code, notes, and snippets.

@g4bri3lDev
Last active January 29, 2025 13:02
Show Gist options
  • Save g4bri3lDev/a85fa92d15647153cc135a6f2c8aa1b0 to your computer and use it in GitHub Desktop.
Save g4bri3lDev/a85fa92d15647153cc135a6f2c8aa1b0 to your computer and use it in GitHub Desktop.
blueprint:
name: MVV Departure Board (Best for 2.9" or 2.66" Displays)
description: >
Update a ESL with MVV departure information every 5 minutes.
Optionally only run if a specified person is home.
domain: automation
source_url: https://gist.github.com/g4bri3lDev/a85fa92d15647153cc135a6f2c8aa1b0
author: g4bri3lDev
input:
departure_sensor:
name: Departure Sensor
description: "Sensor containing the MVV departure info (and attributes)."
selector:
entity:
filter:
domain: sensor
integration: "munich_public_transport"
displays:
name: E-Paper Displays
description: "One or more ESLs."
selector:
device:
filter:
integration: open_epaper_link
multiple: true
person:
name: Person (Optional)
description: >
If set, updates only when this person is home.
Leave blank to run unconditionally.
selector:
entity:
filter:
domain: person
default: ""
mode: single
trigger:
- trigger: time_pattern
minutes: "/5"
variables:
# Entities
departure_sensor_entity: !input "departure_sensor"
person_entity: !input "person"
departures: >
{{ state_attr(departure_sensor_entity, 'departures') }}
station_name: >-
{% set friendly_name = state_attr(departure_sensor_entity, 'friendly_name') %}
{{ friendly_name.replace(' All Departures','') if friendly_name else '' }}
condition:
- condition: template
value_template: >-
{% if person_entity != '' %}
{{ is_state(person_entity, 'home') }}
{% else %}
true
{% endif %}
action:
- action: open_epaper_link.drawcustom
target:
device_id: !input "displays"
data:
background: white
rotate: 0
payload:
#- type: debug_grid
# 1) Heading text
- type: text
value: "{{ station_name }}"
x: "50%"
y: 15
align: center
anchor: mm
size: 20
# font: "{{ heading_font }}"
# A line under heading
- type: line
x_start: 0
x_end: 296
y_start: 25
fill: black
width: 1
# Rectangle pattern
- type: rectangle_pattern
x_start: 5
y_start: 28
x_offset: 0
y_offset: 2
x_size: 35
y_size: 18
fill: accent
outline: accent
width: 1
x_repeat: 1
y_repeat: "{{ departures | length }}"
# Occupancy Icons
- type: icon_sequence
x: 238
y: 38
anchor: rm
direction: down
size: 18
spacing: 2
fill: black
icons: >-
[
{% for d in departures if not d.cancelled %}
{% if d.occupancy == 'HIGH' %}
"mdi:account-group"
{% elif d.occupancy == 'MEDIUM' %}
"mdi:account-multiple"
{% elif d.occupancy == 'LOW' %}
"mdi:account"
{% elif d.occupancy == 'UNKNOWN' %}
"mdi:help-circle-outline"
{% else %}
"mdi:help"
{% endif %}
{%- if not loop.last %}, {% endif -%}
{% endfor %}
]
# 2) Multiline for lines (white text on accent colored rectangles)
- type: multiline
delimiter: ;
x: 23
# font: "{{ line_font }}"
size: 20
start_y: 38
offset_y: 20
color: white
anchor: mm
value: |-
{% for departure in departures if not departure.cancelled %}
{{- departure.line -}}
{%- if not loop.last %};{% endif -%}
{% endfor %}
# 3) Multiline for destinations
- type: multiline
delimiter: ";"
x: 45
# font: "{{ destination_font }}"
size: 20
start_y: 38
offset_y: 20
color: black
value: |-
{% for departure in departures if not departure.cancelled %}
{{- departure.destination[:15] -}}
{%- if not loop.last %};{% endif -%}
{% endfor %}
# 4) Multiline for times
- type: multiline
delimiter: ";"
x: 294
# font: "{{ time_font }}"
size: 20
start_y: 38
offset_y: 20
anchor: rm
color: black
value: |-
{% for departure in departures if not departure.cancelled %}
{{- departure.realtime_departure }}
{%- if not loop.last %};{% endif -%}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment