Good thinking, but when i duplicate and select edit with Yaml i don’t see the real automation but still the yaml for the blueprint. (still new to blue print so might be doing something wrong)
Oh, that’s interesting, you’re right, the Edit with YAML
button on the Automation shows the blueprint yaml, but only things that I’ve configured? But the Edit with UI still seems to be normal.
In your case, I’d just use Edit with UI and after duplicating the Automation just change the remote entity. You’ll end up with two Automations but maybe that’s just a limitation of the blueprint I wrote.
That would work, but currently looking in to the blueprint yaml and found a way to select multiple remotes, but still figuring out how to connect it to the trigger. Think it has something to do with the “sequence” option but can’t find any documentation on it.
To make brightness up/down work, the sequence needs an OR added to it to accept both remotes.
Here’s a Script I just wrote using the UI editor
alias: 1New Script
sequence:
- repeat:
until:
- condition: or
conditions:
- condition: state
entity_id: sensor.a_remote_action
state: brightness_up_release
- condition: state
entity_id: sensor.b_remote_action
state: brightness_up_release
sequence:
- service: light.turn_on
data:
brightness_step_pct: 10
transition: 1
entity_id: light.0x7ce52400000c15aa_light
- delay: '1'
mode: single
Then use that for brightness_up_hold and brightness_down_hold
Getting stuck for the moment and have to continue at a later time. Will post my results if i make more progress. Thanks again!
Thanks so much for this @starbuck93
I’ve recently switched over from Deconz to zigbee2mqtt due to broader device support (as is my understanding anyway), and previously used this blueprint for Ikea 5 button which worked amazing: deCONZ - IKEA five button remote for lights with color temp
I’m relatively new to HA and have been trying to follow along with the discussion on Color Temp changing with Left/Right buttons but havent been able to work it out Is there a simple way to make this work using your blueprint for zigbee2MQTT or, is it possible for you to update the blueprint to support functionality similar to the deconz version?
Thanks Again!
@BrisbaneGuy From what I could tell, deconz has some different commands than Z2M does, so I’m not exactly sure. Maybe try out --> 🎮 ZHA, deCONZ, Zigbee2MQTT - Ikea 5-button Remote Universal blueprint - all actions + double click events - control lights, media players and more with Hooks
I also tried to create a blueprint using devices instead of entity, I think currently it just isn’t possible as there is not only a device_id, there is also a discovery_id (when looking at automations using device triggers). Still not found any other blueprints or documentation using that.
So it seems “Home Assistant legacy triggers” is required for now?
Yes! It is quite annoying now - if you don’t use legacy triggers as is recommended in z2m as well as HA docs, blueprints cannot really work as mentioned/showed/discussed here: Device triggers from zigbee2mqtt vs mqtt listen, and sometimes a bit about blueprints - #15 by kotrfa
Edit: Add firt-class support for MQTT Device Triggers (to have feature parity with legacy triggers)
I’ve just imported the blueprint and set 3buttons of my 5button remote to control each gang of a Tuya 3gang switch when I run the automation and show the trace I get the following error. I should I set each of the 3buttons to toggle!
Error: UndefinedError: dict object has no attribute to_state
Have I missed something?
@starbuck93 thank you for this blueprint. So helpfully for a new HA user here!
How would I go about changing the bright/dim hold feature to be faster. The wife finds it to be too slow?
Thanks
Change the value of brightness_step_pct
(it’s currently 10 for increasing brightness and -10 for decreasing brightness).
Thanks for the prompt reply.
Does a higher numeral mean faster? Like 20 and - 20.
What’s the max allowed.
Sorry really don’t need to mess this up.
Edit: tried higher numerals but made no change. I remembered reading that the automations need to be reloaded. Once I figured out how to do that I am glad to say the changes work.
Changed to 40 and -40. Very happy with it now…
Thanks again
first off. thank you for your on this blueprint.
But i am getting the following error when i try to use it:
Error: UndefinedError: ‘dict object’ has no attribute ‘to_state’
any idea to what i doing wrong?
If you’re using Zigbee2MQTT, you have to choose sensor.%sensornamme%_action
, which is what I think may be your issue.
this is how my config looks like:
mode: restart
max_exceeded: silent
variables:
force_brightness: false
trigger:
- platform: state
entity_id: sensor.tradfri_remote_control_nr_2_action
attribute: action
action:
- variables:
command: '{{ trigger.to_state.state }}'
- choose:
- conditions:
- '{{ command == ''toggle'' }}'
sequence:
- choose:
- conditions: '{{ force_brightness }}'
sequence:
- service: light.toggle
target:
device_id: 7e8f8334942ee07fb9519fa697d948b2
data:
transition: 1
brightness_pct: 50
default:
- service: light.toggle
target:
device_id: 7e8f8334942ee07fb9519fa697d948b2
data:
transition: 1
- conditions:
- '{{ command == ''brightness_up_click'' }}'
sequence:
- service: light.turn_on
target:
device_id: 7e8f8334942ee07fb9519fa697d948b2
data:
brightness_step_pct: 10
transition: 1
That look like the blueprint code, not the automation code, correct?
Yes, that is correct.
Try importing the blueprint again:
And use the visual editor to create a new automation, instead of editing the blueprint code.
I think that blueprints shouldn’t be edited with the remote (in your case sensor.tradfri_remote_control_nr_2_action
) in the YAML.
i tried removeing the blueprint and the unit from z2m, and readding both.
But i still get the same error, no matter what i do.
{
"trace": {
"last_step": "action/0",
"run_id": "78c39bd728e4819d23faf0bd6061db9b",
"state": "stopped",
"script_execution": "error",
"timestamp": {
"start": "2022-04-25T18:14:36.018722+00:00",
"finish": "2022-04-25T18:14:36.026991+00:00"
},
"domain": "automation",
"item_id": "1650910437476",
"error": "UndefinedError: 'dict object' has no attribute 'to_state'",
"trigger": null,
"trace": {
"trigger": [
{
"path": "trigger",
"timestamp": "2022-04-25T18:14:36.018808+00:00",
"changed_variables": {
"force_brightness": false,
"this": {
"entity_id": "automation.z2m_ikea_five_button_remote_for_lights",
"state": "on",
"attributes": {
"last_triggered": "2022-04-24T16:03:23.951776+00:00",
"mode": "restart",
"current": 0,
"id": "1650910437476",
"friendly_name": "Z2M - IKEA five button remote for lights"
},
"last_changed": "2022-04-25T18:14:33.082940+00:00",
"last_updated": "2022-04-25T18:14:33.082940+00:00",
"context": {
"id": "25c1f24672a1ca44bdca848e09ce414a",
"parent_id": null,
"user_id": "5091a839e50c41c4894436f2365fe899"
}
},
"trigger": {
"platform": null
}
}
}
],
"action/0": [
{
"path": "action/0",
"timestamp": "2022-04-25T18:14:36.019878+00:00",
"changed_variables": {
"context": {
"id": "f29c33a70a2ed31e183802a8c95b36f1",
"parent_id": "14e3ff66aae7c942b9e3c20291ccad62",
"user_id": null
}
},
"error": "UndefinedError: 'dict object' has no attribute 'to_state'"
}
]
},
"config": {
"mode": "restart",
"max_exceeded": "silent",
"variables": {
"force_brightness": false
},
"trigger": [
{
"platform": "state",
"entity_id": "sensor.tradfri_rc_2_action",
"attribute": "action"
}
],
"action": [
{
"variables": {
"command": "{{ trigger.to_state.state }}"
}
},
{
"choose": [
{
"conditions": [
"{{ command == 'toggle' }}"
],
"sequence": [
{
"choose": [
{
"conditions": "{{ force_brightness }}",
"sequence": [
{
"service": "light.toggle",
"target": {
"entity_id": "light.lys_panel"
},
"data": {
"transition": 1,
"brightness_pct": 50
}
}
]
}
],
"default": [
{
"service": "light.toggle",
"target": {
"entity_id": "light.lys_panel"
},
"data": {
"transition": 1
}
}
]
}
]
},
{
"conditions": [
"{{ command == 'brightness_up_click' }}"
],
"sequence": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.lys_panel"
},
"data": {
"brightness_step_pct": 10,
"transition": 1
}
}
]
},
{
"conditions": [
"{{ command == 'brightness_up_hold' }}"
],
"sequence": [
{
"repeat": {
"until": [
{
"condition": "state",
"entity_id": "sensor.tradfri_rc_2_action",
"state": "brightness_up_release",
"attribute": "action"
}
],
"sequence": [
{
"service": "light.turn_on",
"data": {
"brightness_step_pct": 10,
"transition": 1
},
"target": {
"entity_id": "light.lys_panel"
}
},
{
"delay": "1"
}
]
}
}
]
},
{
"conditions": [
"{{ command == 'brightness_down_click' }}"
],
"sequence": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.lys_panel"
},
"data": {
"brightness_step_pct": -10,
"transition": 1
}
}
]
},
{
"conditions": [
"{{ command == 'brightness_down_hold' }}"
],
"sequence": [
{
"repeat": {
"until": [
{
"condition": "state",
"entity_id": "sensor.tradfri_rc_2_action",
"state": "brightness_down_release",
"attribute": "action"
}
],
"sequence": [
{
"service": "light.turn_on",
"data": {
"brightness_step_pct": -10,
"transition": 1
},
"target": {
"entity_id": "light.lys_panel"
}
},
{
"delay": "1"
}
]
}
}
]
},
{
"conditions": [
"{{ command == 'arrow_left_click' }}"
],
"sequence": []
},
{
"conditions": [
"{{ command == 'arrow_left_hold' }}"
],
"sequence": []
},
{
"conditions": [
"{{ command == 'arrow_right_click' }}"
],
"sequence": []
},
{
"conditions": [
"{{ command == 'arrow_right_hold' }}"
],
"sequence": []
}
]
}
],
"id": "1650910437476",
"alias": "Z2M - IKEA five button remote for lights",
"description": ""
},
"blueprint_inputs": {
"id": "1650910437476",
"alias": "Z2M - IKEA five button remote for lights",
"description": "",
"use_blueprint": {
"path": "starbuck93/zigbee2mqtt-ikea-five-button-remote.yaml",
"input": {
"remote": "sensor.tradfri_rc_2_action",
"light": {
"entity_id": "light.lys_panel"
}
}
}
},
"context": {
"id": "f29c33a70a2ed31e183802a8c95b36f1",
"parent_id": "14e3ff66aae7c942b9e3c20291ccad62",
"user_id": null
}
},
"logbookEntries": [
{
"name": "Z2M - IKEA five button remote for lights",
"message": "has been triggered",
"source": null,
"entity_id": "automation.z2m_ikea_five_button_remote_for_lights",
"context_id": "f29c33a70a2ed31e183802a8c95b36f1",
"when": "2022-04-25T18:14:36.018927+00:00",
"domain": "automation"
}
]
}