Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Epaper Busy Tag - Free/Busy with Weather
- description: >-
- Updates an epaper tag with busy or available based on calendar events (5 min
- before/after), add weather to available time, skips events marked "free time"
- triggers:
- - entity_id: calendar.CALENDAR_NAME
- event: start
- offset: "-0:5:0"
- id: PRE_START
- trigger: calendar
- - entity_id: calendar.CALENDAR_NAME
- event: start
- offset: "0:0:0"
- id: ACTUAL_START
- trigger: calendar
- - entity_id: calendar.CALENDAR_NAME
- event: end
- offset: "0:5:0"
- id: POST_END
- trigger: calendar
- - hours: "*"
- minutes: /30
- id: REGULAR_CHECK
- enabled: true
- trigger: time_pattern
- conditions: []
- actions:
- - choose:
- - conditions:
- - condition: trigger
- id:
- - PRE_START
- - ACTUAL_START
- - condition: template
- value_template: >-
- {% set show_as = trigger.calendar_event.get('show_as', 'busy') %}
- {% set transparency = trigger.calendar_event.get('transparency',
- 'opaque') %} {{ show_as != 'free' and transparency !=
- 'transparent' }}
- sequence:
- - variables:
- back_color: red
- text_color: white
- status_message: BUSY
- weather_info: ""
- - conditions:
- - condition: trigger
- id:
- - POST_END
- sequence:
- - delay:
- seconds: 5
- - if:
- - condition: template
- value_template: >-
- {% set now = now() %} {% set next_start =
- state_attr('calendar.CALENDAR_NAME', 'start_time') %} {% if
- next_start %}
- {% set next_event_time = as_timestamp(next_start) %}
- {% set current_time = as_timestamp(now) %}
- {{ (next_event_time - current_time) <= 300 }}
- {% else %}
- false
- {% endif %}
- then:
- - variables:
- back_color: red
- text_color: white
- status_message: BUSY
- weather_info: ""
- else:
- - variables:
- back_color: white
- text_color: black
- status_message: AVAILABLE
- weather_info: >-
- {%- set temp = state_attr('weather.forecast_home',
- 'temperature') -%} {%- set condition =
- states('weather.forecast_home') -%} {%- if temp and
- condition -%} {{ temp }}°F, {{ condition | title }} {%- else
- -%} Weather unavailable {%- endif -%}
- - conditions:
- - condition: trigger
- id:
- - REGULAR_CHECK
- - condition: state
- entity_id: calendar.CALENDAR_NAME
- state: "off"
- sequence:
- - variables:
- back_color: white
- text_color: black
- status_message: AVAILABLE
- weather_info: >-
- {%- set temp = state_attr('weather.forecast_home',
- 'temperature') -%} {%- set condition =
- states('weather.forecast_home') -%} {%- if temp and condition
- -%} {{ temp }}°F, {{ condition | title }} {%- else -%} Weather
- unavailable {%- endif -%}
- default:
- - if:
- - condition: and
- conditions:
- - condition: state
- entity_id: calendar.CALENDAR_NAME
- state: "on"
- - condition: template
- value_template: >-
- {% set show_as = state_attr('calendar.CALENDAR_NAME', 'show_as')
- %} {% set transparency = state_attr('calendar.CALENDAR_NAME',
- 'transparency') %} {{ show_as != 'free' and transparency !=
- 'transparent' }}
- then:
- - variables:
- back_color: red
- text_color: white
- status_message: BUSY
- weather_info: ""
- else:
- - variables:
- back_color: white
- text_color: black
- status_message: AVAILABLE
- weather_info: >-
- {%- set temp = state_attr('weather.forecast_home',
- 'temperature') -%} {%- set condition =
- states('weather.forecast_home') -%} {%- if temp and condition
- -%} {{ temp }}°F, {{ condition | title }} {%- else -%} Weather
- unavailable {%- endif -%}
- - metadata: {}
- data:
- rotate: 0
- dither: "0"
- ttl: 60
- dry-run: false
- background: "{{ back_color }}"
- payload:
- - type: text
- value: "{{ status_message }}"
- x: 50%
- "y": 35%
- font: ppb.ttf
- size: 36
- color: "{{ text_color }}"
- anchor: mm
- - type: text
- value: "{{ weather_info }}"
- x: 50%
- "y": 65%
- font: ppb.ttf
- size: 20
- color: "{{ text_color }}"
- anchor: mm
- target:
- device_id: ##FILL IN YOUR OWN##
- action: open_epaper_link.drawcustom
- mode: restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement