SirGoodenough/Home-Assistant-Config

Aqara cube blueprint not passing first if statement

enzodesena opened this issue · 2 comments

Any action on the cube does not pass the first test:

condition: template
value_template: >-
{{ trigger.to_state.attributes.action in ('rotate_right', 'rotate_left',
'flip90', 'flip180', 'slide', 'tap', 'shake', 'fall') }}

which I believe checks that the to_state attribute action is one of the approved actions.
I believe this is due to the fact that the cube actually passes information through the from_state. See e.g. the "changed variables" log in the root node, further below for a shake action. The same happens for other types of actions. I tried to modify the blueprint by blindly replacing all occurrences of to_state to from_state but to no avail.

Any help is appreciated! (Btw, thanks a lot for the work on the blueprint!)

this:
entity_id: automation.aqara_magic_cube_zigbee2mqtt_2022_05_05
state: 'on'
attributes:
last_triggered: null
mode: single
current: 0
id: '1657501384162'
friendly_name: Aqara Magic Cube Zigbee2MQTT - 2022-05-05
last_changed: '2022-07-11T01:03:05.832864+00:00'
last_updated: '2022-07-11T01:03:05.832864+00:00'
context:
id: 01G7NCG1387YT17DZAVCT3BZMR
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
platform: state
entity_id: sensor.sofa_cube_action
from_state:
entity_id: sensor.sofa_cube_action
state: shake
attributes:
icon: mdi:gesture-double-tap
friendly_name: Sofa cube action
last_changed: '2022-07-11T01:03:34.619307+00:00'
last_updated: '2022-07-11T01:03:34.619307+00:00'
context:
id: 01G7NCGX6V87GM9S0283VGZWSF
parent_id: null
user_id: null
to_state:
entity_id: sensor.sofa_cube_action
state: ''
attributes:
icon: mdi:gesture-double-tap
friendly_name: Sofa cube action
last_changed: '2022-07-11T01:03:34.645898+00:00'
last_updated: '2022-07-11T01:03:34.645898+00:00'
context:
id: 01G7NCGX7NKHZY642H9CGWS8T0
parent_id: null
user_id: null
for: null
attribute: null
description: state of sensor.sofa_cube_action

The to_state is what the action changed to The from_state is what the action changed from. 2 different things.
Zigbee controls like this go to sleep, so if you activate it, the first action is sends a wake-up action, then a null action, then maybe another null action or maybe the to_state action, then another null action to shut the switch off, then sometimes a sleep action. It's never just 1. That condition filters out the actions that are not actions that the blueprint cares about and ignores them. Generally the 4th trigger or so is the one that sends the actual command.

I suspect if you are not getting triggers you have not read the description file that goes with it and you may not have the HA Legacy and general Legacy stuff set up correctly.

Look at other traces from activations of the cube. If you can't see what you want, there is a hint in the readme for the blueprint to help you store more traces.

No response, also Issues are meant for code problems, not integration support.
Please see the read me and other places for further places to ask for integration support.