Advertisement
The_Holocron

ePaper Tag v2.15

Jun 9th, 2025 (edited)
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.31 KB | None | 0 0
  1. alias: Epaper Busy Tag - Free/Busy with Weather
  2. description: >-
  3.   Updates an epaper tag with busy or available based on calendar events (5 min
  4.   before/after), add weather to available time, skips events marked "free time"
  5. triggers:
  6.   - entity_id: calendar.CALENDAR_NAME
  7.     event: start
  8.     offset: "-0:5:0"
  9.     id: PRE_START
  10.     trigger: calendar
  11.   - entity_id: calendar.CALENDAR_NAME
  12.     event: start
  13.     offset: "0:0:0"
  14.     id: ACTUAL_START
  15.     trigger: calendar
  16.   - entity_id: calendar.CALENDAR_NAME
  17.     event: end
  18.     offset: "0:5:0"
  19.     id: POST_END
  20.     trigger: calendar
  21.   - hours: "*"
  22.     minutes: /30
  23.     id: REGULAR_CHECK
  24.     enabled: true
  25.     trigger: time_pattern
  26. conditions: []
  27. actions:
  28.   - choose:
  29.       - conditions:
  30.           - condition: trigger
  31.             id:
  32.              - PRE_START
  33.               - ACTUAL_START
  34.           - condition: template
  35.             value_template: >-
  36.               {% set show_as = trigger.calendar_event.get('show_as', 'busy') %}
  37.               {% set transparency = trigger.calendar_event.get('transparency',
  38.               'opaque') %} {{ show_as != 'free' and transparency !=
  39.               'transparent' }}
  40.         sequence:
  41.           - variables:
  42.               back_color: red
  43.               text_color: white
  44.               status_message: BUSY
  45.               weather_info: ""
  46.       - conditions:
  47.           - condition: trigger
  48.             id:
  49.              - POST_END
  50.         sequence:
  51.           - delay:
  52.               seconds: 5
  53.           - if:
  54.               - condition: template
  55.                 value_template: >-
  56.                   {% set now = now() %} {% set next_start =
  57.                   state_attr('calendar.CALENDAR_NAME', 'start_time') %} {% if
  58.                   next_start %}
  59.                     {% set next_event_time = as_timestamp(next_start) %}
  60.                     {% set current_time = as_timestamp(now) %}
  61.                     {{ (next_event_time - current_time) <= 300 }}
  62.                   {% else %}
  63.                     false
  64.                   {% endif %}
  65.             then:
  66.               - variables:
  67.                   back_color: red
  68.                   text_color: white
  69.                   status_message: BUSY
  70.                   weather_info: ""
  71.             else:
  72.               - variables:
  73.                   back_color: white
  74.                   text_color: black
  75.                   status_message: AVAILABLE
  76.                   weather_info: >-
  77.                     {%- set temp = state_attr('weather.forecast_home',
  78.                     'temperature') -%} {%- set condition =
  79.                     states('weather.forecast_home') -%} {%- if temp and
  80.                     condition -%} {{ temp }}°F, {{ condition | title }} {%- else
  81.                     -%} Weather unavailable {%- endif -%}
  82.       - conditions:
  83.           - condition: trigger
  84.             id:
  85.              - REGULAR_CHECK
  86.           - condition: state
  87.             entity_id: calendar.CALENDAR_NAME
  88.             state: "off"
  89.         sequence:
  90.           - variables:
  91.               back_color: white
  92.               text_color: black
  93.               status_message: AVAILABLE
  94.               weather_info: >-
  95.                 {%- set temp = state_attr('weather.forecast_home',
  96.                 'temperature') -%} {%- set condition =
  97.                 states('weather.forecast_home') -%} {%- if temp and condition
  98.                 -%} {{ temp }}°F, {{ condition | title }} {%- else -%} Weather
  99.                 unavailable {%- endif -%}
  100.     default:
  101.       - if:
  102.           - condition: and
  103.             conditions:
  104.               - condition: state
  105.                 entity_id: calendar.CALENDAR_NAME
  106.                 state: "on"
  107.               - condition: template
  108.                 value_template: >-
  109.                   {% set show_as = state_attr('calendar.CALENDAR_NAME', 'show_as')
  110.                   %} {% set transparency = state_attr('calendar.CALENDAR_NAME',
  111.                   'transparency') %} {{ show_as != 'free' and transparency !=
  112.                   'transparent' }}
  113.         then:
  114.           - variables:
  115.               back_color: red
  116.               text_color: white
  117.               status_message: BUSY
  118.               weather_info: ""
  119.         else:
  120.           - variables:
  121.               back_color: white
  122.               text_color: black
  123.               status_message: AVAILABLE
  124.               weather_info: >-
  125.                 {%- set temp = state_attr('weather.forecast_home',
  126.                 'temperature') -%} {%- set condition =
  127.                 states('weather.forecast_home') -%} {%- if temp and condition
  128.                 -%} {{ temp }}°F, {{ condition | title }} {%- else -%} Weather
  129.                 unavailable {%- endif -%}
  130.   - metadata: {}
  131.     data:
  132.       rotate: 0
  133.       dither: "0"
  134.       ttl: 60
  135.       dry-run: false
  136.       background: "{{ back_color }}"
  137.       payload:
  138.         - type: text
  139.           value: "{{ status_message }}"
  140.           x: 50%
  141.           "y": 35%
  142.           font: ppb.ttf
  143.           size: 36
  144.           color: "{{ text_color }}"
  145.           anchor: mm
  146.         - type: text
  147.           value: "{{ weather_info }}"
  148.           x: 50%
  149.           "y": 65%
  150.           font: ppb.ttf
  151.           size: 20
  152.           color: "{{ text_color }}"
  153.           anchor: mm
  154.     target:
  155.       device_id: ##FILL IN YOUR OWN##
  156.     action: open_epaper_link.drawcustom
  157. mode: restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement