I asked this on the blueprints topic and it was suggested that I post here. Sir_Goodenough explained that blueprints use limited templates and he didn’t think I could pull attributes within the trigger variables like I am attempting below. That would explain the problem, at least, however I’d still like to figure out how to accomplish this, as it seems exactly like the use-case blueprints should be good for? Any suggestions from the template experts on how to accomplish this type of trigger (preferably in a blueprint)?
Original Post:
I am trying to create a blueprint for ZEN32 scene controllers via mqtt. I’m aware that there is a blueprint for this already here, but I am trying to do it without individually selecting the scene sensor (similar to this blueprint). I should be able to use the device input selector to get a device_id, and use that id to get an entity_name, which I can then insert into the mqtt trigger topics. However, it’s not working, though I have confirmed via a notification that in the action:
portion of the template it is correctly getting an entity_name.
blueprint:
name: ZEN32 (zwavejs2mqtt)
description: Zooz ZEN32 via zigbeejs2matt
domain: automation
input:
zooz_switch:
name: Zooz Switch
description: List of available Zooz ZEN32 switches.
selector:
device:
integration: mqtt
manufacturer: Zooz
model: Scene Controller (ZEN32)
multiple: false
This works perfectly, allows me to select the scene controller, and ultimately gives me a device_id
. Omitting a bunch of the irrelevant code, the portion I’m struggling with is:
variables:
device_id: !input zooz_switch
entity_name: "{{ device_attr( device_id, 'name') }}"
trigger:
- platform: mqtt
topic: "{{ 'zwavejs2mqtt/' ~ entity_name ~ '/91/0/scene/005' }}"
id: mainbutton
- platform: mqtt
topic: "{{ 'zwavejs2mqtt/' ~ entity_name ~ '/91/0/scene/001' }}"
id: topleftbutton
- platform: mqtt
topic: "{{ 'zwavejs2mqtt/' ~ entity_name ~ '/91/0/scene/002' }}"
id: toprightbutton
- platform: mqtt
topic: "{{ 'zwavejs2mqtt/' ~ entity_name ~ '/91/0/scene/003' }}"
id: bottomleftbutton
- platform: mqtt
topic: "{{ 'zwavejs2mqtt/' ~ entity_name ~ '/91/0/scene/004' }}"
id: bottomrightbutton
condition: []
However, the triggers don’t work, and I can’t figure out how to get any usable debugging information. I have confirmed that the device_id
and entity_name
are what I expect by adding a default notification to the blueprint which I can activate by running the automation directly via the UI.
I currently have several of the ZEN32s set up without blueprints, working as expected, but it’s a pain to make any changes. As I purchased about a dozen of them for my house, I’d like to get a working blueprint with as few inputs as possible.
Since I’ve looked at a couple other implementations of the ZEN32 as well as a multitude of other mqtt blueprints, I know there’s probably another way to skin the cat, but I think the blueprint creating a mqtt trigger topic is a worthwhile solution which can be streamlined even more (by using wildcards, which is my next step once I get this working), so I’d like to try to do it this way if it’s possible.
If it’s not possible, can someone explain why? Thanks.