Skip to content

Commit

Permalink
Brining the indicator blueprint up to par with modern stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeftor committed Jan 8, 2024
1 parent 7175524 commit a8c0ff2
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions blueprints/automation/awtrix_indicator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ blueprint:
selector:
boolean:
default: false
show_current_meeting:
name: Display current meeting countdown
description: >-
Show how much time reamining in current meeting
selector:
boolean:
default: false

next_meeting_time_color:
name: Next Meeting - Time Color
description: Select the color for the time text for next-meeting notifications
Expand Down Expand Up @@ -266,9 +274,23 @@ blueprint:
mode: slider
default: 0

min_suffix:
name: Min Suffix
description: What shoudl we use to show Mins. Prepend a space if you want a space between number and text.
selector:
text:
default: " m"
hour_suffix:
name: Hour Suffix
description: What shoudl we use to show Hours. Prepend a space if you want a space between number and text.
selector:
text:
default: " hr"

mode: queued
variables:
show_next_meeting: !input show_next_meeting
show_current_meeting: !input show_current_meeting

color_active: !input color_active
color_1_min_warning: !input color_1_min_warning
Expand All @@ -288,10 +310,13 @@ variables:
next_meeting_time_color: !input next_meeting_time_color
next_meeting_text_color: !input next_meeting_text_color
next_meeting_separator_color: !input next_meeting_separator_color
min_suffix: !input min_suffix
hour_suffix: !input hour_suffix

calendar: !input calendar
cal_state: "{{states(calendar)}}"

device_ids: !input awtrix
light_suffix: !input indicator
lights: >-
{%- set ns = namespace(lights=[]) %}
Expand All @@ -300,7 +325,7 @@ variables:
{% set ns.lights = ns.lights + [light] %}
{% endfor %}
{{ ns.lights}}
device_ids: !input awtrix
devices_topics: >-
{%- macro get_device_topic(device_id) %}
{{- states((device_entities(device_id) | select('search','device_topic') | list)[0]) }}
Expand All @@ -313,8 +338,7 @@ variables:
{%- endfor %}
{{ ns.devices | reject('match','unavailable') | list}}
next_meeting_base_topic: jeef_next_meeting

next_meeting_base_topic: "{{calendar | replace('.','_') ~ '_next_meeting' }}"
next_meeting_topics: >-
{{devices_topics | regex_replace(find='indicator.', replace='custom/' ~ next_meeting_base_topic, ignorecase=False) }}
sound_topics: >-
Expand Down Expand Up @@ -359,7 +383,7 @@ trigger:
id: 0_min

action:
- service: calendar.list_events
- service: calendar.get_events
data:
duration:
hours: 8
Expand Down Expand Up @@ -492,15 +516,15 @@ action:
}
{%- endmacro %}
{%- set ns = namespace(parsed_events=[]) %}
{%- for event in cal_events.events %}
{%- for event in cal_events[calendar].events %}
{%- set e_dict = event_to_dict(event) %}
{%- set ns.parsed_events = ns.parsed_events + [ (e_dict | from_json )] %}
{%- endfor -%}
{{ns.parsed_events | sort(attribute='start_ts')}}
locations: >-
{%- set ns = namespace(locations=[]) %}
{%- for event in cal_events.events %}
{%- for event in cal_events[calendar].events %}
{% set loc = {"locations": ((event.location | replace('\n', ' ')) | to_json) } %}
{%- set ns.locations = ns.locations + [loc] + [loc] %}
{%- endfor -%}
Expand Down Expand Up @@ -551,9 +575,9 @@ action:
{%- set min = (next_events[0].start_min | float) -%}
{%- set hr = (min / 60) | float | round(1) -%}
{%- if min > 60 -%}
{{hr | replace('.0','')}} hr
{{hr | replace('.0','')}}{{hour_suffix}}
{%- else -%}
{{min | replace('.0','')}} min
{{min | replace('.0','')}}{{min_suffix}}
{%- endif -%}
{%- endif -%}
next_events_payload: >-
Expand Down Expand Up @@ -596,6 +620,8 @@ action:
{% endmacro -%}
{{ get_color_blink(event_payload)}}
sound_payload_dev: >-
{{trigger.id}}
sound_payload: >-
{%- if trigger.id != 'temporal' %}
{{sound_dict[trigger.id]}}
Expand Down Expand Up @@ -644,10 +670,14 @@ action:
payload: >-
{{sound_payload}}
- service: mqtt.publish
data:
qos: 0
topic: dev-test
payload: >-
{%- set idx = trigger.id %}
{{sound_dict[idx]}} {{sound_dict}}
- if:
- condition: template
value_template: "{{trigger.id != 'temporal'}}"
then:
- service: mqtt.publish
data:
qos: 0
topic: dev-test
payload: >-
{%- set idx = trigger.id %}
{{sound_dict[idx]}} {{sound_dict}}

0 comments on commit a8c0ff2

Please sign in to comment.