Last active
July 11, 2024 14:35
-
-
Save tldev-de/80b7ad1b20117e3c58cbb78226a7cd10 to your computer and use it in GitHub Desktop.
blueprint without dependencies! props to https://github.com/10der/homeassistant-custom_components-awtrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: AWTRIX3 Blueprint | |
description: Show any entity on awtrix 3 (e.g. ulanzi tc001) | |
domain: automation | |
input: | |
app_name: | |
name: (Required) Application name | |
description: "Application name" | |
default: "awtrix_app" | |
selector: | |
text: | |
multiline: false | |
multiple: false | |
app_icon: | |
name: Application Icon | |
description: "Application icon" | |
default: "" | |
selector: | |
text: | |
multiline: false | |
multiple: false | |
awtrix_device: | |
name: AWTRIX device | |
description: The AWTRIX device for show app. | |
default: [] | |
selector: | |
device: | |
integration: mqtt | |
manufacturer: Blueforcer | |
model: AWTRIX 3 | |
multiple: true | |
retain: | |
name: Retain | |
description: retain means that mqtt sends the same value again and again, until a new one is provided | |
default: false | |
selector: | |
boolean: | |
entity: | |
name: Entity | |
description: Entity | |
selector: | |
entity: | |
multiple: false | |
prefix_text: | |
name: Text prefix | |
description: "Text prefix" | |
default: "" | |
suffix_text: | |
name: Text suffix | |
description: "Text suffix" | |
default: "" | |
extra_trigger: | |
name: Extra trigger | |
description: Additional trigger to actions. | |
selector: | |
object: | |
default: | |
False | |
pre_actions: | |
name: Actions | |
description: Actions when starting... | |
selector: | |
action: | |
default: | |
additional_options: | |
name: Additional options | |
description: Extra options | |
selector: | |
object: | |
default: {} | |
user_options: | |
name: AWTRIX application options | |
description: AWTRIX application useroptions, goes directly to mqtt | |
selector: | |
object: | |
default: | |
duration: 5 | |
additional_conditions: | |
name: Additional conditions | |
description: | | |
Extra conditions you may want to add to this automation | |
(Example: Home occupied, TV on, etc) | |
default: [] | |
selector: | |
condition: | |
trigger: | |
- platform: state | |
entity_id: !input entity | |
- platform: homeassistant | |
event: start | |
- platform: event | |
event_type: automation_reloaded | |
- platform: template | |
value_template: !input extra_trigger | |
condition: [] | |
variables: | |
entity_id: !input entity | |
app_name: !input app_name | |
app_icon: !input app_icon | |
additional_conditions: !input additional_conditions | |
retain: !input retain | |
action: | |
- choose: [] | |
default: !input pre_actions | |
- &variable_entity | |
alias: Variable Entity | |
variables: | |
!input additional_options | |
- variables: | |
<<: *variable_entity | |
device_ids: !input awtrix_device | |
# deprecated ! | |
user_data: !input additional_options | |
value_template: "{{ user_data.get('value_template', states(entity_id)) }}" | |
icon_template: "{{ user_data.get('icon_template', app_icon) }}" | |
prefix_text: !input prefix_text | |
suffix_text: !input suffix_text | |
user_options: !input user_options | |
retain: !input retain | |
payload: |- | |
{ | |
{{('"icon"' if icon_template) ~ (":" if icon_template) ~ ('"' ~ icon_template ~ '"' if icon_template) }} | |
{{"," if icon_template}} "text":"{{prefix_text~value_template~suffix_text}}" | |
} | |
- repeat: | |
for_each: "{{ device_ids }}" | |
sequence: | |
- variables: | |
awtrix_device_name: "{{ iif( device_attr(repeat.item, 'name_by_user') != none, device_attr(repeat.item, 'name_by_user'), device_attr(repeat.item, 'name') ) }}" | |
- if: !input additional_conditions | |
then: | |
- service: mqtt.publish | |
data: | |
qos: 0 | |
retain: "{{ retain }}" | |
topic: "{{awtrix_device_name}}/custom/{{app_name}}" | |
payload: > | |
{{ dict(payload, **user_options) }} | |
else: | |
- service: mqtt.publish | |
data: | |
qos: 0 | |
retain: "{{ retain }}" | |
topic: "{{awtrix_device_name}}/custom/{{app_name}}" | |
payload: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment