Initial commit with existing blueprints

This commit is contained in:
2026-01-22 01:46:04 +03:00
commit 35f11d7e30
17 changed files with 5760 additions and 0 deletions

View File

@@ -0,0 +1,216 @@
blueprint:
name: "Custom: MQTT Button Control"
description: Control a Zigbee2MQTT device with multiple actions, that allows to toggle lights and switches and store entity identifier of last interructed switch/light.
domain: automation
input:
mqtt_group:
name: "MQTT"
collapsed: false
input:
mqtt_topic:
name: MQTT Topic
description: The MQTT topic for your Zigbee button (e.g., zigbee2mqtt/my_button1).
selector:
text:
mqtt_topic2:
name: MQTT Topic 2
description: The MQTT topic for your Zigbee button (e.g., zigbee2mqtt/my_button2).
default: fake
selector:
text:
devices:
name: "Primary"
collapsed: false
input:
action_ids:
name: Action IDs
description: The action IDs that must map to lights (action → light)
default: []
selector:
text:
multiple: true
switches:
name: Switches
description: "The list of switches to control. Next types are supported: `light`, `switch`, `input_boolean`"
default: []
selector:
entity:
domain:
- light
- switch
- input_boolean
multiple: true
outputs:
name: "Outputs"
collapsed: false
input:
last_interacted_text:
name: Last Interacted Entity Text Helper (optional)
description: "`input_text` entity that will store last enabled entity"
default: ""
selector:
entity:
domain: input_text
common:
name: "Common"
collapsed: false
input:
timeout_for_indication_blink:
name: "Timeout for indicator blink"
description: If not zero does blink when button with already enabled light is pressed to indicate that the light is active now if elapsed time from last action is greater then the specified value
default: 10
selector:
number:
min: 0
max: 100
step: 1
unit_of_measurement: "s"
blink_count:
name: Count of blinks
description: "Count of blinks to indicate active light"
default: 3
selector:
number:
min: 0
max: 5
step: 1
blink_interval:
name: Interval between blinks
description: "Interval between indicator blinks (in ms)"
default: 250
selector:
number:
min: 0
max: 1000
step: 50
unit_of_measurement: "ms"
trigger:
- platform: mqtt
topic: !input mqtt_topic
- platform: mqtt
topic: !input mqtt_topic2
enabled: "{{ mqtt_topic2 != '' }}"
mode: restart
condition:
- condition: template
value_template: "{{ 'action' in trigger.payload_json }}"
action:
- variables:
action_id: "{{ trigger.payload_json.action }}"
switches: !input switches
action_ids: !input action_ids
target_index: >
{% if action_id in action_ids %}
{{ action_ids.index(action_id) }}
{% else %}
-1
{% endif %}
target_entity: "{{ switches[target_index] if target_index != -1 else none }}"
last_interacted_text: !input last_interacted_text
is_debug: false
- choose:
- conditions:
- condition: template
value_template: "{{ target_entity is not none }}"
sequence:
- variables:
entity_type: "{{ target_entity.split('.')[0] }}"
- service: input_text.set_value
data:
entity_id: "{{ last_interacted_text }}"
value: "{{ target_entity }}"
- choose:
# Light
- conditions:
- condition: template
value_template: "{{ entity_type == 'light' }}"
sequence:
- variables:
timeout_for_indication_blink: !input timeout_for_indication_blink
seconds_elapsed: >
{{ (as_timestamp(now()) - as_timestamp(states[target_entity].last_changed)) | int }}
should_blink: "{{ timeout_for_indication_blink != 0 and seconds_elapsed > timeout_for_indication_blink }}"
blink_count: !input blink_count
blink_timeout: !input blink_interval
is_light_on: "{{ is_state(target_entity, 'on') }}"
# Debug
- choose:
- conditions:
- condition: template
value_template: "{{ is_debug }}"
sequence:
- service: persistent_notification.create
data:
title: "Debug Info"
message: >
seconds_elapsed = {{ seconds_elapsed }},
should_blink = {{ should_blink }}
- choose:
# Blink
- conditions:
- condition: template
value_template: "{{ should_blink and is_light_on }}"
sequence:
- repeat:
count: "{{ blink_count }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ target_entity }}"
data:
transition: 0
- delay:
milliseconds: "{{ blink_timeout }}"
- service: light.turn_on
target:
entity_id: "{{ target_entity }}"
data:
transition: 0
- delay:
milliseconds: "{{ blink_timeout }}"
# Actually toggle
default:
- service: light.toggle
target:
entity_id: "{{ target_entity }}"
# Switch
- conditions:
- condition: template
value_template: "{{ entity_type == 'switch' }}"
sequence:
- service: switch.toggle
target:
entity_id: "{{ target_entity }}"
# Input Boolean
- conditions:
- condition: template
value_template: "{{ entity_type == 'input_boolean' }}"
sequence:
- service: input_boolean.toggle
target:
entity_id: "{{ target_entity }}"

View File

@@ -0,0 +1,213 @@
blueprint:
name: "Custom: MQTT Generic Control"
description: >
Triggered by MQTT messages. Supports up to 8 custom action IDs with optional callbacks.
domain: automation
input:
mqtt_group:
name: "MQTT"
collapsed: false
input:
mqtt_topic:
name: MQTT Topic 1
description: The MQTT topic to listen to
selector:
text: {}
mqtt_topic2:
name: MQTT Topic 2
description: The MQTT topic to listen to
default: 'fake'
selector:
text: {}
mqtt_topic3:
name: MQTT Topic 3
description: The MQTT topic to listen to
default: 'fake'
selector:
text: {}
mqtt_topic4:
name: MQTT Topic 4
description: The MQTT topic to listen to
default: 'fake'
selector:
text: {}
actions_group:
name: "Actions"
collapsed: false
input:
action_id_1:
name: Action ID 1
description: Value of `payload_json.action` that triggers callback 1
default: ""
selector:
text: {}
action_callback_1:
name: Action Callback 1
description: Actions to run when Action ID 1 is received
default: []
selector:
action: {}
action_id_2:
name: Action ID 2
default: ""
selector:
text: {}
action_callback_2:
name: Action Callback 2
default: []
selector:
action: {}
action_id_3:
name: Action ID 3
default: ""
selector:
text: {}
action_callback_3:
name: Action Callback 3
default: []
selector:
action: {}
action_id_4:
name: Action ID 4
default: ""
selector:
text: {}
action_callback_4:
name: Action Callback 4
default: []
selector:
action: {}
action_id_5:
name: Action ID 5
default: ""
selector:
text: {}
action_callback_5:
name: Action Callback 5
default: []
selector:
action: {}
action_id_6:
name: Action ID 6
default: ""
selector:
text: {}
action_callback_6:
name: Action Callback 6
default: []
selector:
action: {}
action_id_7:
name: Action ID 7
default: ""
selector:
text: {}
action_callback_7:
name: Action Callback 7
default: []
selector:
action: {}
action_id_8:
name: Action ID 8
default: ""
selector:
text: {}
action_callback_8:
name: Action Callback 8
default: []
selector:
action: {}
mode: restart
trigger:
- platform: mqtt
topic: !input mqtt_topic
- platform: mqtt
topic: !input mqtt_topic2
enabled: "{{ mqtt_topic2 != '' }}"
- platform: mqtt
topic: !input mqtt_topic3
enabled: "{{ mqtt_topic3 != '' }}"
- platform: mqtt
topic: !input mqtt_topic4
enabled: "{{ mqtt_topic4 != '' }}"
variables:
action_id: "{{ trigger.payload_json.action }}"
action_id_1: !input action_id_1
action_id_2: !input action_id_2
action_id_3: !input action_id_3
action_id_4: !input action_id_4
action_id_5: !input action_id_5
action_id_6: !input action_id_6
action_id_7: !input action_id_7
action_id_8: !input action_id_8
is_debug: false
action:
# Debug info (log if required)
- choose:
- conditions:
- condition: template
value_template: "{{ is_debug }}"
sequence:
- service: persistent_notification.create
data:
title: "Debug Info"
message: >
action = {{ action_id }},
1 = {{ action_id_1 }}
- choose:
- conditions:
- condition: template
value_template: "{{ action_id_1 != '' and action_id == action_id_1 }}"
sequence: !input action_callback_1
- conditions:
- condition: template
value_template: "{{ action_id_2 != '' and action_id == action_id_2 }}"
sequence: !input action_callback_2
- conditions:
- condition: template
value_template: "{{ action_id_3 != '' and action_id == action_id_3 }}"
sequence: !input action_callback_3
- conditions:
- condition: template
value_template: "{{ action_id_4 != '' and action_id == action_id_4 }}"
sequence: !input action_callback_4
- conditions:
- condition: template
value_template: "{{ action_id_5 != '' and action_id == action_id_5 }}"
sequence: !input action_callback_5
- conditions:
- condition: template
value_template: "{{ action_id_6 != '' and action_id == action_id_6 }}"
sequence: !input action_callback_6
- conditions:
- condition: template
value_template: "{{ action_id_7 != '' and action_id == action_id_7 }}"
sequence: !input action_callback_7
- conditions:
- condition: template
value_template: "{{ action_id_8 != '' and action_id == action_id_8 }}"
sequence: !input action_callback_8

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,372 @@
blueprint:
name: "Custom: MQTT Light Selector"
description: >
Cycle through a list of lights using MQTT button events (up/down).
Selected light is stored in an input_text helper and flashes N times
with Z interval when selected.
domain: automation
input:
devices:
name: "Devices"
collapsed: false
input:
mqtt_topic:
name: MQTT Topic
description: Topic where button events are published
selector:
text: {}
mqtt_topic2:
name: MQTT Topic
description: Topic where button events are published
default: 'fake'
selector:
text: {}
lights:
name: "Lights"
collapsed: false
input:
lights:
name: Lights
description: List of lights to cycle through
selector:
entity:
domain: light
multiple: true
persistent_state:
name: "Persiatent State"
collapsed: false
input:
selected_light_helper:
name: Selected Light Helper
description: Input_text entity to store the selected light
selector:
entity:
domain: input_text
automation_state_entity:
name: Automation state entity
description: The `input_text` entity will store state of the automation in JSON format. `Doesn't require any initial state, can be empty. For now each automation must have it's personal entity.`
default: null
selector:
entity:
domain:
- input_text
action_ids:
name: "Action IDs"
collapsed: false
input:
action_up:
name: Up Action Identifier
description: Payload string for "next light"
default: ''
selector:
text: {}
action_down:
name: Down Action Identifier
description: Payload string for "previous light"
default: ''
selector:
text: {}
action_remind:
name: Remind Action Identifier
description: Payload string for "current light"
default: ''
selector:
text: {}
params:
name: "Parameters"
collapsed: false
input:
transition:
name: Transition Time (ms)
description: Duration of brightness transition
default: 0
selector:
number:
min: 0
max: 500
step: 10
unit_of_measurement: ms
remind_using_up_down_delay:
name: Force Remind Using Up/Down Delay
description: "If specified then `Up`/`Down` action will work like `Remind` in case if duration from the last action was greater then this value"
default: 0
selector:
number:
min: 0
max: 100
step: 1
unit_of_measurement: s
flash_count:
name: Flash Count
description: Number of times to flash selected light
default: 2
selector:
number:
min: 1
max: 10
step: 1
flash_interval_ms:
name: Flash Interval (ms)
description: Interval between flashes in milliseconds
default: 500
selector:
number:
min: 100
max: 2000
step: 100
unit_of_measurement: ms
actions_group:
name: "Actions"
collapsed: false
input:
condition_action:
name: Extra Condition
description: Optional condition to check before running actions
default: []
selector:
condition: {}
callback_action:
name: Callback Action
description: Optional action to run after main sequence
default: []
selector:
action: {}
trigger:
- platform: mqtt
topic: !input mqtt_topic
id: "mqtt"
- platform: mqtt
topic: !input mqtt_topic2
id: "mqtt"
condition: !input condition_action
mode: restart
variables:
# Constants.
is_debug: false
# Defines.
lights: !input lights
helper: !input selected_light_helper
action_up: !input action_up
action_down: !input action_down
action_remind: !input action_remind
flash_count: !input flash_count
flash_interval_ms: !input flash_interval_ms
transition: !input transition
remind_using_up_down_delay: !input remind_using_up_down_delay
mqtt_topic: !input mqtt_topic
# JSON global state.
state_key_last_was_on: 'lwo'
state_key_last_light: 'll'
state_key_last_select_action_datetime: 'lsadt'
automation_state_entity: !input automation_state_entity
automation_state_global: >
{% if automation_state_entity is not none %}
{% set text = states(automation_state_entity) | string %}
{% if text in ['unknown','unavailable','none',''] %}
{{ dict() }}
{% else %}
{{ text | from_json }}
{% endif %}
{% else %}
{{ dict() }}
{% endif %}
current_datetime: "{{ now() }}"
# TODO alexeid: it's better to use mqtt_topic as key, but cyrilic characters require use of tranliteration
automation_state_key: "mqtt_light_selector:{{ lights[0] }}"
automation_state: "{{ automation_state_global.get(automation_state_key, dict()) if automation_state_key != '' else dict() }}"
state_last_was_on: "{{ automation_state.get(state_key_last_was_on, false) | bool }}"
state_last_light: "{{ automation_state.get(state_key_last_light, '') | string }}"
state_last_select_action_datetime: "{{ as_datetime(automation_state.get(state_key_last_select_action_datetime, current_datetime)) }}"
# Current index from helper (fallback to 0 if empty)
current_light: >
{% set entity_id = states(helper) %}
{{ entity_id if entity_id in lights else none }}
current_index: >
{% set idx = lights.index(current_light) if current_light in lights else 0 %}
{{ idx }}
action:
# Debug info (log if required)
- choose:
- conditions:
- condition: template
value_template: "{{ is_debug }}"
sequence:
- service: persistent_notification.create
data:
title: "Debug Info"
message: "automation_state_key = {{ automation_state_key }}"
- choose:
# MQTT -> handle the message
- conditions:
- condition: template
value_template: "{{ trigger.id == 'mqtt' }}"
sequence:
- variables:
action_id: "{{ trigger.payload_json.action }}"
# Don't forget to restore last light state
- choose:
- conditions:
- condition: template
value_template: "{{ state_last_light != '' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ state_last_was_on }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ state_last_light }}"
data:
transition: "{{ transition }}"
- conditions:
- condition: template
value_template: "{{ not state_last_was_on }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ state_last_light }}"
data:
transition: "{{ transition }}"
# Save persistent state.
- choose:
- conditions:
- condition: template
value_template: "{{ automation_state_entity is not none }}"
sequence:
- service: input_text.set_value
target:
entity_id: "{{ automation_state_entity }}"
data:
value: >
{% set new_automation_state = (automation_state | combine({ state_key_last_light: '' })) %}
{% set new_automation_state = (new_automation_state | combine({ state_key_last_was_on: new_on })) %}
{% set new_automation_state = (new_automation_state | combine({ state_key_last_select_action_datetime: current_datetime })) %}
{{ automation_state_global | combine({ automation_state_key: new_automation_state }) | tojson }}
# Do actual selection
- choose:
- conditions:
- condition: template
value_template: "{{ (action_id != '') and (action_id == action_up or action_id == action_down or action_id == action_remind) }}"
sequence:
- variables:
datetime_diff_seconds: >
{% set diff = current_datetime - state_last_select_action_datetime %}
{{ diff.total_seconds() }}
step: >
{% if remind_using_up_down_delay != 0 and datetime_diff_seconds < remind_using_up_down_delay %}
0
{% elif action_up != '' and action_id == action_up %}
1
{% elif action_down != '' and action_id == action_down %}
-1
{% else %}
0
{% endif %}
new_index: "{{ (current_index + step) % lights|length }}"
new_light: "{{ lights[new_index] }}"
new_on: "{{ is_state(new_light, 'on') }}"
# Save persistent state.
- choose:
- conditions:
- condition: template
value_template: "{{ automation_state_entity is not none }}"
sequence:
- service: input_text.set_value
target:
entity_id: "{{ automation_state_entity }}"
data:
value: >
{% set new_automation_state = (automation_state | combine({ state_key_last_light: new_light })) %}
{% set new_automation_state = (new_automation_state | combine({ state_key_last_was_on: new_on })) %}
{{ automation_state_global | combine({ automation_state_key: new_automation_state }) | tojson }}
# Run callback only if user provided it: think if we need to invoke callback here
- choose:
- conditions:
- condition: template
value_template: "{{ callback_action is defined and (callback_action|length > 0) }}"
sequence: !input callback_action
# Assign new light entity id to helper value
- service: input_text.set_value
target:
entity_id: "{{ helper }}"
data:
value: "{{ new_light }}"
- repeat:
count: "{{ flash_count }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ new_light }}"
data:
transition: "{{ transition }}"
- delay:
milliseconds: "{{ flash_interval_ms }}"
- service: light.turn_on
target:
entity_id: "{{ new_light }}"
data:
transition: "{{ transition }}"
- delay:
milliseconds: "{{ flash_interval_ms }}"
# Optionally turn off the light.
- choose:
- conditions:
- condition: template
value_template: "{{ not new_on }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ new_light }}"
data:
transition: "{{ transition }}"
# Save persistent state.
- choose:
- conditions:
- condition: template
value_template: "{{ automation_state_entity is not none }}"
sequence:
- service: input_text.set_value
target:
entity_id: "{{ automation_state_entity }}"
data:
value: >
{% set new_automation_state = (automation_state | combine({ state_key_last_light: '' })) %}
{% set new_automation_state = (new_automation_state | combine({ state_key_last_was_on: new_on })) %}
{{ automation_state_global | combine({ automation_state_key: new_automation_state }) | tojson }}

View File

@@ -0,0 +1,69 @@
blueprint:
name: "Custom: MQTT Knob Media Controller (Dynamic Step)"
description: >
Control a media player using a knob switch via MQTT.
- `toggle` pauses/unpauses
- `rotate_left` decreases volume
- `rotate_right` increases volume
- Volume step is taken from `action_step` in the MQTT payload
domain: automation
input:
mqtt_topic:
name: MQTT Topic
description: The topic your knob publishes to (e.g., zigbee2mqtt/knob1/action)
selector:
text:
media_player:
name: Media Player
selector:
entity:
domain: media_player
trigger:
- platform: mqtt
topic: !input mqtt_topic
variables:
media: !input media_player
action: "{{ trigger.payload_json.action }}"
step: >-
{% set key = 'action_step_size' %}
{% if key in trigger.payload_json %}
{{ (trigger.payload_json[key] | float(0)) / 500 }}
{% else %}
0
{% endif %}
action:
- choose:
- conditions:
- condition: template
value_template: "{{ action == 'toggle' }}"
sequence:
- service: media_player.media_play_pause
target:
entity_id: "{{ media }}"
- conditions:
- condition: template
value_template: "{{ action == 'brightness_step_down' }}"
sequence:
- variables:
current: "{{ state_attr(media, 'volume_level') | float(0) }}"
new: "{{ [0, current - step] | max }}"
- service: media_player.volume_set
target:
entity_id: "{{ media }}"
data:
volume_level: "{{ new }}"
- conditions:
- condition: template
value_template: "{{ action == 'brightness_step_up' }}"
sequence:
- variables:
current: "{{ state_attr(media, 'volume_level') | float(0) }}"
new: "{{ [current + step, 1] | min }}"
- service: media_player.volume_set
target:
entity_id: "{{ media }}"
data:
volume_level: "{{ new }}"