Skip to content

Commit

Permalink
choose stop action on tag removed (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
luka6000 authored Nov 5, 2024
1 parent 944b2f7 commit 8b8198d
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions blueprints/TagTuner4HAss.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
blueprint:
name: TagTuner for HAss
description: TagTuner music player automation for NFC tags
description: TagTuner music player for NFC tags automation
domain: automation
input:
reader_id:
tuner_id:
name: TagTuner for ESPHome
description: This is your NFC reader device
description: This is your NFC tuner device
selector:
device:
filter:
- integration: esphome
model: TagTuner
player:
name: Media Player
description: This is your media player for this reader
description: This is your media player for this tuner
selector:
entity:
filter:
- domain: media_player
stop_on_tagremoved:
name: Stop music
description: on tag removed
selector:
boolean:
default: true

variables:
device_id: !input reader_id
device_id: !input tuner_id
stop_on_tagremoved: !input stop_on_tagremoved
action: >-
{%if trigger.event.event_type == 'tag_scanned' %}
tag_scanned
Expand Down Expand Up @@ -67,14 +73,16 @@ actions:
- choose:
- conditions:
- condition: template
value_template: "{{ action == 'tag_removed' }}"
value_template: '{{ action == "tag_removed" }}'
sequence:
- condition: template
value_template: "{{ stop_on_tagremoved == true }}"
- action: media_player.media_stop
target:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'tag_scanned' and source == 'sonos' and trigger.event.data.playlist != '' }}"
value_template: '{{ action == "tag_scanned" and source == "sonos" and trigger.event.data.playlist != "" }}'
sequence:
- action: media_player.media_stop
target:
Expand All @@ -86,7 +94,7 @@ actions:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'tag_scanned' and source not in ('sonos', '') }}"
value_template: '{{ action == "tag_scanned" and source not in ("sonos", "") }}'
sequence:
- action: media_player.play_media
data:
Expand All @@ -96,21 +104,21 @@ actions:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'play_pause' }}"
value_template: '{{ action == "play_pause" }}'
sequence:
- action: media_player.media_play_pause
target:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'next' }}"
value_template: '{{ action == "next" }}'
sequence:
- action: media_player.media_next_track
target:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'mute' }}"
value_template: '{{ action == "mute" }}'
sequence:
- if:
- condition: state
Expand All @@ -137,18 +145,20 @@ actions:
- choose:
- conditions:
- condition: template
value_template: "{{ action == 'volume_up' }}"
value_template: '{{ action == "volume_up" }}'
sequence:
- action: media_player.volume_up
target:
entity_id: !input player
- conditions:
- condition: template
value_template: "{{ action == 'volume_down' }}"
value_template: '{{ action == "volume_down" }}'
sequence:
- action: media_player.volume_down
target:
entity_id: !input player

mode: queued
max: 10
trace:
stored_traces: 30

0 comments on commit 8b8198d

Please sign in to comment.