Perhaps what I am doing is not possible. For clarity, I have a template device that stores different information including things like the media_player and microphone device associated with this template device.
What I am trying to do with the blueprint is to set a trigger that checks if the microphone and/or the media_player gets muted and then to do something. I have this working in a proof of concept automation. The template sensor device is hard coded. For example:
- id: mediaplayerchange
trigger: template
value_template: >
{% set ent = state_attr('sensor.viewassist_masterbedroom', 'mediaplayer_device') %}
{{ not state_attr(ent, 'is_volume_muted') | bool }}
Works great. I have a blueprint that does various things. The user is required to install this blueprint on a per device basis. So device âsensor.viewassist_masterbedroomâ would have this blueprint and the satellite name is one of the input fields. I am trying my hardest to get that input satellite name in to replace the âsensor.viewassist_masterbedroomâ in the example above so that this blueprint can be used for each device and add the additional functionality.
What I am unsure of, besides if it is possible, is how the blueprint works. Does it do what I hope and substitute those inputs into the automation where they are defined? If so, this should work right?
When I take control and look at yaml, I am seeing this (pulling out relevant parts):
trigger_variables:
trigger_satellite: sensor.viewassist_masterbedroom
triggers:
- alias: Mic muted
id: micchange
value_template: |-
{% set target_device = state_attr(trigger_satellite, 'mic_device') %}
{% if '_stt' in target_device %}
{% set target_device = target_device | replace('sensor', 'switch') | replace('_stt', '_mic') %}
{% endif %}
{{ not states(target_device) | bool }}
trigger: template
- alias: Mic unmuted
id: micchange
value_template: |-
{% set target_device = state_attr(trigger_satellite, 'mic_device') %}
{% if '_stt' in target_device %}
{% set target_device = target_device | replace('sensor', 'switch') | replace('_stt', '_mic') %}
{% endif %}
{{ states(target_device) | bool }}
trigger: template
To me this should work just like the proof of concept automation where I am hardcoding the sensor name. I am not seeing the blueprint version triggering when the mic changes to mute.
This works fine in dev tools â template
{% set trigger_satellite = "sensor.viewassist_masterbedroom" %}
{% set target_device = state_attr(trigger_satellite, 'mic_device') %}
{% if '_stt' in target_device %}
{% set target_device = target_device | replace('sensor', 'switch') | replace('_stt', '_mic') %}
{% endif %}
{{ not states(target_device) | bool }}
Full blueprint as it stands is here:
https://dpaste.org/JvBMq