- trigger: - platform: time_pattern minutes: /3 variables: # This will be used as a filter in text sensors so that characters not present in the font will not be printed # Copy and paste your list from glyphs in the fonts section of your ESPHome YAML and escape certain characters # so backslash \ becomes \\ and double-quote " becomes \" but single-quote ' needs to be doubled '' # Make sure your list has "[^ at the front and ]" at the end (this is a regular expression, with quotes around it) allowed_characters: "[^! \"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz°]" action: - service: todo.get_items data: status: needs_action target: entity_id: - todo.to_do - todo.car response_variable: mylist - service: calendar.get_events data: start_date_time: "{{today_at().strftime('%Y-%m-%d %H:%M')}}" end_date_time: "{{now().date() + timedelta(days=29)}}" target: entity_id: - calendar.family - calendar.holidays_in_south_korea - calendar.bills response_variable: mycalendar sensor: - name: eInk TasksBoard Data unique_id: eink_tasksboard_data state: "OK" attributes: today: > {%- set counter = namespace(total = 0) -%} {%- set list = namespace(todo = []) -%} {# -- search todo lists and calendars below this point -- #} {# search calendar #} {%- for events in mycalendar["calendar.family"]["events"] -%} {%- if "start" in events and (now().date()|string) in events.start -%} {%- set list.todo = list.todo + [(events.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# search calendar and add a note#} {%- for events in mycalendar["calendar.holidays_in_south_korea"]["events"] -%} {%- if "start" in events and (now().date()|string) in events.start -%} {%- set list.todo = list.todo + ["Korea: " + (events.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# search todo list #} {%- for items in mylist["todo.to_do"]["items"] -%} {%- if "due" in items and items.due <= states('sensor.date') -%} {%- set list.todo = list.todo + [(items.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# search todo list and add a note #} {%- for items in mylist["todo.car"]["items"] -%} {%- if "due" in items and items.due <= states('sensor.date') -%} {%- set list.todo = list.todo + ["Car: " + (items.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# search calendar and add a note #} {%- for events in mycalendar["calendar.bills"]["events"] -%} {%- if "start" in events and (now().date()|string) in events.start -%} {%- set list.todo = list.todo + ["Bills: " + (events.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# -- end searching -- #} {{list.todo | default('') }} upcoming: > {%- set latest_date = 64 -%} {%- set counter = namespace(total = 0) -%} {%- set list = namespace(todo = []) -%} {%- for v in range(latest_date) -%} {# -- search todo lists and calendars below this point -- #} {# search calendar #} {%- for events in mycalendar["calendar.family"]["events"] -%} {%- if "start" in events and ((now().date() + timedelta(days=v+1))|string) in events.start -%} {%- set list.todo = list.todo + [(as_datetime(events.start).strftime('%A %B %-d'))] -%} {%- set list.todo = list.todo + [(events.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# search todo list #} {%- for items in mylist["todo.to_do"]["items"] -%} {%- if "due" in items and ((now().date() + timedelta(days=v+1))|string) in items.due -%} {%- set list.todo = list.todo + [(as_datetime(items.due).strftime('%A %B %-d'))] -%} {%- set list.todo = list.todo + [(items.summary)] -%} {%- set counter.total = counter.total + 1 -%} {%- endif -%} {%- endfor -%} {# -- end searching -- #} {%- if counter.total >= 20 -%} {%- break -%} {%- endif -%} {%- endfor -%} {{list.todo | default('') }} today_0: > {{ state_attr(this.entity_id, 'today')[0] | default('') | regex_replace(allowed_characters, "") }} today_1: > {{ state_attr(this.entity_id, 'today')[1] | default('') | regex_replace(allowed_characters, "") }} today_2: > {{ state_attr(this.entity_id, 'today')[2] | default('') | regex_replace(allowed_characters, "") }} today_3: > {{ state_attr(this.entity_id, 'today')[3] | default('') | regex_replace(allowed_characters, "") }} today_4: > {{ state_attr(this.entity_id, 'today')[4] | default('') | regex_replace(allowed_characters, "") }} today_5: > {{ state_attr(this.entity_id, 'today')[5] | default('') | regex_replace(allowed_characters, "") }} today_6: > {{ state_attr(this.entity_id, 'today')[6] | default('') | regex_replace(allowed_characters, "") }} today_7: > {{ state_attr(this.entity_id, 'today')[7] | default('') | regex_replace(allowed_characters, "") }} today_8: > {{ state_attr(this.entity_id, 'today')[8] | default('') | regex_replace(allowed_characters, "") }} today_9: > {{ state_attr(this.entity_id, 'today')[9] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_0: > {{ state_attr(this.entity_id, 'upcoming')[0] | default('') }} upcoming_item_0: > {{ state_attr(this.entity_id, 'upcoming')[1] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_1: > {{ state_attr(this.entity_id, 'upcoming')[2] | default('') }} upcoming_item_1: > {{ state_attr(this.entity_id, 'upcoming')[3] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_2: > {{ state_attr(this.entity_id, 'upcoming')[4] | default('') }} upcoming_item_2: > {{ state_attr(this.entity_id, 'upcoming')[5] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_3: > {{ state_attr(this.entity_id, 'upcoming')[6] | default('') }} upcoming_item_3: > {{ state_attr(this.entity_id, 'upcoming')[7] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_4: > {{ state_attr(this.entity_id, 'upcoming')[8] | default('') }} upcoming_item_4: > {{ state_attr(this.entity_id, 'upcoming')[9] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_5: > {{ state_attr(this.entity_id, 'upcoming')[10] | default('') }} upcoming_item_5: > {{ state_attr(this.entity_id, 'upcoming')[11] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_6: > {{ state_attr(this.entity_id, 'upcoming')[12] | default('') }} upcoming_item_6: > {{ state_attr(this.entity_id, 'upcoming')[13] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_7: > {{ state_attr(this.entity_id, 'upcoming')[14] | default('') }} upcoming_item_7: > {{ state_attr(this.entity_id, 'upcoming')[15] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_8: > {{ state_attr(this.entity_id, 'upcoming')[16] | default('') }} upcoming_item_8: > {{ state_attr(this.entity_id, 'upcoming')[17] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_9: > {{ state_attr(this.entity_id, 'upcoming')[18] | default('') }} upcoming_item_9: > {{ state_attr(this.entity_id, 'upcoming')[19] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_10: > {{ state_attr(this.entity_id, 'upcoming')[20] | default('') }} upcoming_item_10: > {{ state_attr(this.entity_id, 'upcoming')[21] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_11: > {{ state_attr(this.entity_id, 'upcoming')[22] | default('') }} upcoming_item_11: > {{ state_attr(this.entity_id, 'upcoming')[23] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_12: > {{ state_attr(this.entity_id, 'upcoming')[24] | default('') }} upcoming_item_12: > {{ state_attr(this.entity_id, 'upcoming')[25] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_13: > {{ state_attr(this.entity_id, 'upcoming')[26] | default('') }} upcoming_item_13: > {{ state_attr(this.entity_id, 'upcoming')[27] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_14: > {{ state_attr(this.entity_id, 'upcoming')[28] | default('') }} upcoming_item_14: > {{ state_attr(this.entity_id, 'upcoming')[29] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_15: > {{ state_attr(this.entity_id, 'upcoming')[30] | default('') }} upcoming_item_15: > {{ state_attr(this.entity_id, 'upcoming')[31] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_16: > {{ state_attr(this.entity_id, 'upcoming')[32] | default('') }} upcoming_item_16: > {{ state_attr(this.entity_id, 'upcoming')[33] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_17: > {{ state_attr(this.entity_id, 'upcoming')[34] | default('') }} upcoming_item_17: > {{ state_attr(this.entity_id, 'upcoming')[35] | default('') | regex_replace(allowed_characters, "") }} upcoming_date_18: > {{ state_attr(this.entity_id, 'upcoming')[36] | default('') }} upcoming_item_18: > {{ state_attr(this.entity_id, 'upcoming')[37] | default('') | regex_replace(allowed_characters, "") }} - trigger: - platform: time_pattern minutes: /1 variables: waketime: > {# Edit and order the schedule from midnight 00:00 to 23:59 as needed #} {%- set waketimes = [] %} {%- set waketimes = waketimes + ["01:01"] %} {%- set waketimes = waketimes + ["10:01"] %} {%- set waketimes = waketimes + ["14:01"] %} {%- set waketimes = waketimes + ["18:01"] %} {%- set waketime = namespace(next = "") %} {%- set waketime_all = [] %} {%- for test in waketimes %} {%- set waketime.next = (now().strftime('%Y-%m-%d')|string) + " " + (test|string) %} {%- if (now().strftime('%Y-%m-%d %H:%M:%S')|string|as_datetime) < (waketime.next|as_datetime) %} {%- break %} {%- endif %} {%- endfor %} {%- if (now().strftime('%Y-%m-%d %H:%M:%S')|string|as_datetime) > (waketime.next|as_datetime) %} {%- set waketime.next = (now().strftime('%Y-%m-%d')|string) + " " + (waketimes[0]|string) %} {%- set waketime_helper = ((as_timestamp(waketime.next|as_datetime + timedelta(days=1)) - as_timestamp(now()|as_datetime))|int(0)) %} {%- else %} {%- set waketime_helper = ((as_timestamp(waketime.next|as_datetime) - as_timestamp(now()|as_datetime))|int(0)) %} {%- endif %} {%- set waketime_all = [waketime.next] + [waketime_helper] + [waketimes] %} {{waketime_all}} sensor: - name: eInk TasksBoard Wake Times unique_id: eink_tasksboard_wake_times state: "{{ this.attributes.next_wake_time | default('Not Available') }}" attributes: wake_times: "{{ waketime[2] | default('Not Available') }}" next_wake_time: "{{ waketime[0] | default(999999) }}" wake_time_helper: "{{ waketime[1] | default('Not Available') }}"