Skip to content

Instantly share code, notes, and snippets.

@g4bri3lDev
Last active January 20, 2025 03:47
Show Gist options
  • Save g4bri3lDev/44f41d89ed94ed7d5c385c0a8d9540fe to your computer and use it in GitHub Desktop.
Save g4bri3lDev/44f41d89ed94ed7d5c385c0a8d9540fe to your computer and use it in GitHub Desktop.
blueprint:
name: Lines4
description: >
### Legacy lines4 fields using drawcustom
Format Syntax:
* First character (alignment): 'l'/'m'/'r' → sets x position and anchor
* Second character (background): 'w'/'b'/'r' → rectangle fill
* Third character (border): 'w'/'b'/'r' → rectangle outline
* Fourth character (text): 'w'/'b'/'r' → text color
Templating is supported, for example:
`{{ state_attr("weather.forecast_home", "temperature") }}°C`
domain: automation
source_url: https://gist.github.com/g4bri3lDev/44f41d89ed94ed7d5c385c0a8d9540fe
author: g4bri3lDev
input:
trigger_id:
name: Trigger
description: Select the trigger(s) that should activate this automation
default: []
selector:
trigger:
condition_id:
name: Condition
description: Additional conditions to evaluate
default: []
selector:
condition:
device_id:
name: E-Paper Display(s)
description: Select the ESL device(s) to display text on
selector:
device:
filter:
integration: open_epaper_link
multiple: true
line1:
name: Line 1
description: Content for line 1
default: ""
selector:
text:
line2:
name: Line 2
description: Content for line 2
default: ""
selector:
text:
line3:
name: Line 3
description: Content for line 3
default: ""
selector:
text:
line4:
name: Line 4
description: Content for line 4
default: ""
selector:
text:
format1:
name: Format Line 1
description: "Format code for line 1 (e.g., mwwb, mbbw)"
default: "mwwb"
selector:
text:
format2:
name: Format Line 2
description: "Format code for line 2 (e.g., mwwb, mbbw)"
default: "mwwb"
selector:
text:
format3:
name: Format Line 3
description: "Format code for line 3 (e.g., mwwb, mbbw)"
default: "mwwb"
selector:
text:
format4:
name: Format Line 4
description: "Format code for line 4 (e.g., mwwb, mbbw)"
default: "mwwb"
selector:
text:
border:
name: Border Color
default: w
selector:
select:
options:
- value: w
label: White
- value: b
label: Black
- value: r
label: Accent (Red/Yellow)
trigger: !input trigger_id
condition: !input condition_id
variables:
line1: !input "line1"
line2: !input "line2"
line3: !input "line3"
line4: !input "line4"
format1: !input "format1"
format2: !input "format2"
format3: !input "format3"
format4: !input "format4"
border: !input "border"
action:
- action: open_epaper_link.drawcustom
target:
device_id: !input device_id
data:
background: white
rotate: 0
payload:
# Main border
- type: rectangle
x_start: 0
y_start: 0
x_end: 295
y_end: 127
outline: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[border] }}
width: 1
# Line 1 background
- type: rectangle
x_start: 2
y_start: 2
x_end: 292
y_end: 32
fill: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format1[1]] }}
outline: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format1[2]] }}
# Line 1 text
- type: text
value: !input line1
x: >-
{% if format1[0] == 'l' %}5
{% elif format1[0] == 'r' %}290
{% else %}148{% endif %}
y: 17
size: 23
font: ppb.ttf
color: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format1[3]] }}
anchor: >-
{{ format1[0] }}m
max_width: 280
# Line 2 background
- type: rectangle
x_start: 2
y_start: 33
x_end: 292
y_end: 63
fill: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format2[1]] }}
outline: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format2[2]] }}
# Line 2 text
- type: text
value: !input line2
x: >-
{% if format2[0] == 'l' %}5
{% elif format2[0] == 'r' %}290
{% else %}148{% endif %}
y: 48
size: 23
font: ppb.ttf
color: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format2[3]] }}
anchor: >-
{{ format2[0] }}m
max_width: 280
# Line 3 background
- type: rectangle
x_start: 2
y_start: 64
x_end: 292
y_end: 94
fill: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format3[1]] }}
outline: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format3[2]] }}
# Line 3 text
- type: text
value: !input line3
x: >-
{% if format3[0] == 'l' %}5
{% elif format3[0] == 'r' %}290
{% else %}148{% endif %}
y: 79
size: 23
font: ppb.ttf
color: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format3[3]] }}
anchor: >-
{{ format3[0] }}m
max_width: 280
# Line 4 background
- type: rectangle
x_start: 2
y_start: 95
x_end: 292
y_end: 124
fill: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format4[1]] }}
outline: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format4[2]] }}
# Line 4 text
- type: text
value: !input line4
x: >-
{% if format4[0] == 'l' %}5
{% elif format4[0] == 'r' %}290
{% else %}148{% endif %}
y: 110
size: 23
font: ppb.ttf
color: >-
{% set colors = {'w':'white', 'b':'black', 'r':'accent'} %}
{{ colors[format4[3]] }}
anchor: >-
{{ format4[0] }}m
max_width: 280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment