@baru ,
I’m finally back on HA ! Took a s*** ton of time sorry. I’ve added what you needed.
Haven’t had a chance to test it unfortunately
@baru ,
I’m finally back on HA ! Took a s*** ton of time sorry. I’ve added what you needed.
Haven’t had a chance to test it unfortunately
Hi all, and thank you for sharing.
I’ve a blueprint that is written in the same way but it has been developed for xiaomi clicker that works almost same way but with just one button.
I cannot manage the automation to work because of this:
Error: UndefinedError: ‘dict object’ has no attribute ‘to_state’
I tried also to change the variable definition in many ways solving the error, but the variable “command” seems to be always empty. Could you please advise?
I could well be doing something wrong but it seems like the state change isn’t triggering the automation for me. I’m using Zigbee2MQTT and HA running as docker containers.
I can see the following state change received:
"event_type": "state_changed",
...
"new_state": {
"entity_id": "sensor.0x54ef44100042b717_action",
"state": "button_2_single",
...
However the automation for “button_2_single” doesn’t run.
Is anyone else seeing issues like this?
Hi @hypnosis ,
Sorry I didn’t get back to you earlier. It’s hard to say with the information at hand.
I would advise you to open a thread (not in the Blueprints exchange though, to have better visibility by everyone), with all details about the integration and what you do exactly for testing.
Otherwise it will be hard to help you out.
Chris
Might very well be me mate !
I have installed one though some weeks ago at home and it’s working great.
I confirm this is the same kind of event I receive. As details this is what happens on my side:
Event 53 fired 9:37 AM:
{
"event_type": "state_changed",
"data": {
"entity_id": "sensor.kitchen_remote_action",
"old_state": {
"entity_id": "sensor.kitchen_remote_action",
"state": "button_2_single",
"attributes": {
"action": "",
"battery": 100,
"linkquality": 96,
"operation_mode": null,
"temperature": 25,
"voltage": 3059,
"icon": "mdi:gesture-double-tap",
"friendly_name": "Kitchen Remote action"
},
"last_changed": "2022-04-28T07:37:03.316789+00:00",
"last_updated": "2022-04-28T07:37:03.332157+00:00",
"context": {
"id": "dcfa88aac6349889fc4b96928b1823c5",
"parent_id": null,
"user_id": null
}
},
"new_state": {
"entity_id": "sensor.kitchen_remote_action",
"state": "",
"attributes": {
"action": "",
"battery": 100,
"linkquality": 96,
"operation_mode": null,
"temperature": 25,
"voltage": 3059,
"icon": "mdi:gesture-double-tap",
"friendly_name": "Kitchen Remote action"
}...
This is then followed automatically by:
Event 54 fired 9:37 AM:
{
"event_type": "automation_triggered",
"data": {
"name": "Kitchen Remote",
"entity_id": "automation.z2m_aqara_opple_switch_2_bands",
"source": "state of sensor.kitchen_remote_action"
},
"origin": "LOCAL",
"time_fired": "2022-04-28T07:37:03.352382+00:00",
"context": {
"id": "5492a98e9f94642fa06d38eaad92c6ab",
"parent_id": "dcfa88aac6349889fc4b96928b1823c5",
"user_id": null
}
}
Maybe you can send me the details of your automation configuration?
Thanks
Chris
Wow, thanks, I didn’t expect such quick responses!
In working on the issue, I stumbled upon the following thread which mentions that the problem is likely that the state "button_1_single” is being set and then immediately being set back to an empty string.
This correlates with the events that I’m seeing when debugging.
To workaround it, I implemented code similar to the last post in that thread, making a separate automation for each button press.
I had never noticed that but yes you are right ! Fortunately for me it doesn’t seem to bother my automation. It sill triggers all right every time I press the button. And it makes sense because what triggers the rule, is the state_change. So whether it goes back to NULL shouldn’t impact the automation execution…
Are you running the blueprint as the automation directly? Or something else?
Cheers
That is what I thought initially too.
Yes, I created an automation directly from the blueprint.
Are you running Z2M and HA dockerized? I’m wondering whether that makes any difference.
One other thing to note (and I’m not sure if it matters or not) is that my Z2M configuration.yaml file has “homeassistant_legacy_entity_attributes” disabled.
Unfortunately I’m only relatively new to HA so my debugging abilities there are fairly limited.
Cheers,
Brent
Hey @brash,
Not anymore. Right now am running HA OS on an Intel Nuc.
I was looking at your setting that I didn’t know and I stumbled on another setting called legacy_triggers. The documentation says:
# Optional: Home Assistant legacy triggers (default: shown below), when enabled:
# - Zigbee2mqt will send an empty 'action' or 'click' after one has been send
# - A 'sensor_action' and 'sensor_click' will be discoverd
legacy_triggers: true
Maybe you can set that option to false (default is ON). That would prevent the empty value from being sent?
I checked my settings and indeed… it’s enabled. Careful that changing this setting requires an HA restart
See you!
Interesting…
I come across with exactly same problem: Z2M, the blueprint and WXCJKG12LM… and HA on docker (moving slowly from Hassos)
Somehow this one particular blueprint don’t want to work.
So I made simple automation test:
alias: test1b
description: ''
trigger:
- platform: state
entity_id:
- sensor.aqara4button_action
to: button_1_single
condition: []
action:
- service: switch.toggle
data: {}
target:
device_id: d875be96231967c96acaac5930395d10
mode: single
and this works perfectly well.
I wonder what is the difference between the blueprint and this simple auto?
I love the blueprint, simplifies configuration a lot.
Hey @marekorok ,
That’s interesting !
To be fair i’ve no idea what the difference between the two are…
I just opened the blueprint and everything looks allright
Something just caught my interest though, can you check your Z2M logs and press on one of the remotes buttons?
Mine shows this:
Info <small>2022-05-10 22:03:28</small>`MQTT publish: topic 'zigbee2mqtt/Kitchen Remote', payload '{"action":"","battery":100,"linkquality":96,"operation_mode":null,"temperature":25,"voltage":3075}'`
Info <small>2022-05-10 22:03:28</small>`MQTT publish: topic 'zigbee2mqtt/Kitchen Remote/action', payload 'button_4_single'`
What is bothering me is the “operation_mode” of the remote as null. Are you seing something else yourselves?
@Brash did you get any luck on this?
I might need to rework this blueprint all together, but since it is working at home, I don’t really have the will power to do so
yes, I see the same operation_mode: null
If I get it right, it is used when you want to change binding and control directly something (like bulb) not using coordinator, from z2m doc:
https://www.zigbee2mqtt.io/devices/WXCJKG13LM.html#binding
by default it works in event mode.
I have even forced ‘event’ setting following the documentation but no change for blueprint, still does not work.
Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button', payload '{"action":"button_1_single","battery":100,"linkquality":174,"operation_mode":"event","voltage":3037}'`
Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button', payload '{"action":"","battery":100,"linkquality":174,"operation_mode":"event","voltage":3037}'`
Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button/action', payload 'button_1_single'`
I guess it’s irrelevant in our case
I agree, not relevant in this situation.
Can you check your automation using the blueprint traces to see if the event of pressing the button is actually even recorded there and why the action is not being triggered?
I’ve had the same problem as people above - and I discovered the problem. The automation has this as a trigger:
trigger:
- platform: state
entity_id: !input "switch"
attribute: action
But (and I’m not sure if this is a change in zigbee2mqtt or HA since this blueprint was written), but the sensor attribute which changes state to mark the MQTT even doesn’t have and attribute called ‘action’; it only has a state. Therefore, the automation is watching a non-existent attribute and never fires.
Removing the attribute: action
line makes the automation work.
Hello @thecowan ,
Thanks a lot for pitching in in this.
That doesn’t explain why it works like a charm on my end. I’ll try to do the change on my side when I get out of work and test it. Then I’ll publish the template edited if everything works all right.
Hello again @thecowan ,
If I remove attribute:action
on my end, the automation stops working all together.
It makes sense, since my sensor does have an action attribute.
From playing around more, I think this depends on whether you have “Home Assistant legacy entity attributes” set in the zigbee2mqtt config. If you do, you have an action attribute; if not, it’s kept purely in the state. I think.
If you want to eliminate the null triggers from firing the automation thus causing errors in the log, add a condition to only allow the ‘good’ triggers to get into the blueprint guts and screen out the nulls and everything else in the condition…
I explained that to someone else here:
Hi all,
this might be a really dumb newbie question but I hope you don’t throw tomatoes at me now:
I imported this blueprint. I have an Opple WXCJKG12LM joined over deCONZ and showing up under “devices” and I can actually use it to trigger stuff (but without a blueprint of course rather unstructured).
But if I want to create an automation with this blueprint here, I can not select the Opple switch - the dropdown shows “no matching entities found”.
How can that be - the device is visible under “devices”?
I have the same thing also with another Aqara Switch (WXKG11LM) and it’s respective blueprint…
It seems my HA doesn’t recognize those devices as being what the blueprints are for.
Am I missing something here?
Thanks for your help!
Jan
I will look into this! Whenever I have some free time… doesn’t come that often lately.
Thanks