Closed drublin closed 5 months ago
Hiya.
Before we can help, you’ll need to use the blueprint from this repository.
Please import the yaml file from this repository and switch your automation and let me know if the issue is resolved.
This issue should be resolved, but we do have an open ticket with this issue right now.
Cheers
Hiya.
Before we can help, you’ll need to use the blueprint from this repository.
Please import the yaml file from this repository and switch your automation and let me know if the issue is resolved.
This issue should be resolved, but we do have an open ticket with this issue right now.
Cheers
Thanks Lewis, I figured it was forked and has the same version of the blueprint as EPMatt. I'll change to this blueprint and feedback ASAP.
@LewisSpring , i've updated the OP, though it's the same behavior for this blueprint too: double press trigger is seen, but the action is not fired.
Cheers,
You’re not the only person using Z2M and having issues with double press.
I will do my best to have a look, maybe @lsismeiro may have a better idea as has more experience with the triggers
@LewisSpring ,I've made it work by adding the "off" command in the blueprint and commenting the nested check where "button_short" is checked whether it's a double press or not.
i also guess the helper text input, double press exposure and some other helpers are not needed anymore. But this is my first interaction with blueprints and scripts, so i didn't touch more than i needed. :/
UPD: I've commented-out some "obsolete" helpers related to "calculated double press". Still works :)
blueprint:
homeassistant:
min_version: 2023.6.0
name: Controller - IKEA E1812 TRÅDFRI Shortcut button [dru]
description:
"# Controller - IKEA E1812 TRÅDFRI Shortcut button\n\nController automation
for executing any kind of action triggered by the provided IKEA E1812 TRÅDFRI
Shortcut button. Allows to optionally loop an action on a button long press.\nSupports
deCONZ, ZHA, Zigbee2MQTT.\n\nAutomations created with this blueprint can be connected
with one or more [Hooks](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/hooks)
supported by this controller.\nHooks allow to easily create controller-based automations
for interacting with media players, lights, covers and more.\nSee the list of
[Hooks available for this controller](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/controllers/ikea_e1812#available-hooks)
for additional details.\n\n\U0001F4D5 Full documentation regarding this blueprint
is available [here](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/controllers/ikea_e1812).\n\n\U0001F680
This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints)
project**.\n\nℹ️ Version 2022.08.08\n"
source_url: https://github.com/lsismeiro/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1812/ikea_e1812.yaml
domain: automation
input:
integration:
name: (Required) Integration
description:
Integration used for connecting the remote with Home Assistant.
Select one of the available values.
selector:
select:
options:
- deCONZ
- ZHA
- Zigbee2MQTT
custom_value: false
sort: false
multiple: false
controller_device:
name: (deCONZ, ZHA) Controller Device
description:
The controller device to use for the automation. Choose a value
only if the remote is integrated with deCONZ, ZHA.
default: ""
selector:
device: {}
controller_entity:
name: (Zigbee2MQTT) Controller Entity
description:
The action sensor of the controller to use for the automation.
Choose a value only if the remote is integrated with Zigbee2MQTT.
default: ""
selector:
entity:
domain:
- sensor
multiple: false
# helper_last_controller_event:
# name: (Required) Helper - Last Controller Event
# description:
# Input Text used to store the last event fired by the controller.
# You will need to manually create a text input entity for this, please read
# the blueprint Additional Notes for more info.
# default: ""
# selector:
# entity:
# domain:
# - input_text
# multiple: false
action_button_short:
name: (Optional) Button short press
description: Action to run on short button press.
default: []
selector:
action: {}
action_button_long:
name: (Optional) Button long press
description: Action to run on long button press.
default: []
selector:
action: {}
action_button_release:
name: (Optional) Button release
description: Action to run on button release after long press.
default: []
selector:
action: {}
action_button_double:
name: (Optional) Button double press
description: Action to run on double button press.
default: []
selector:
action: {}
button_long_loop:
name: (Optional) Button long press - loop until release
description: Loop the button action until the button is released.
default: false
selector:
boolean: {}
button_long_max_loop_repeats:
name: (Optional) Button long press - Maximum loop repeats
description:
Maximum number of repeats for the custom action, when looping is
enabled. Use it as a safety limit to prevent an endless loop in case the corresponding
stop event is not received.
default: 500
selector:
number:
min: 1.0
max: 5000.0
mode: slider
step: 1.0
# button_double_press:
# name: (Optional) Expose button double press event
# description:
# Choose whether or not to expose the virtual double press event
# for the button. Turn this on if you are providing an action for the button
# double press event.
# default: false
# selector:
# boolean: {}
# helper_double_press_delay:
# name: (Optional) Helper - Double Press delay
# description:
# Max delay between the first and the second button press for the
# double press event. Provide a value only if you are using a double press action.
# Increase this value if you notice that the double press action is not triggered
# properly.
# default: 500
# selector:
# number:
# min: 100.0
# max: 5000.0
# unit_of_measurement: milliseconds
# mode: box
# step: 10.0
helper_debounce_delay:
name: (Optional) Helper - Debounce delay
description:
Delay used for debouncing RAW controller events, by default set
to 0. A value of 0 disables the debouncing feature. Increase this value if
you notice custom actions or linked Hooks running multiple times when interacting
with the device. When the controller needs to be debounced, usually a value
of 100 is enough to remove all duplicate events.
default: 0
selector:
number:
min: 0.0
max: 1000.0
unit_of_measurement: milliseconds
mode: box
step: 10.0
variables:
integration: !input integration
button_long_loop: !input button_long_loop
button_long_max_loop_repeats: !input button_long_max_loop_repeats
# button_double_press: !input button_double_press
# helper_last_controller_event: !input helper_last_controller_event
# helper_double_press_delay: !input helper_double_press_delay
helper_debounce_delay: !input helper_debounce_delay
integration_id: "{{ integration | lower }}"
# adjusted_double_press_delay:
# "{{ [helper_double_press_delay - helper_debounce_delay,
# 100] | max }}"
actions_mapping:
deconz:
button_short:
- "1002"
button_long:
- "1001"
button_release:
- "1003"
zha:
button_short:
- "on"
button_long:
- move_with_on_off_0_83
button_release:
- stop
zigbee2mqtt:
button_short:
- "on"
button_long:
- brightness_move_up
button_release:
- brightness_stop
#added by dru
button_double:
- "off"
button_short: '{{ actions_mapping[integration_id]["button_short"] }}'
button_long: '{{ actions_mapping[integration_id]["button_long"] }}'
button_release: '{{ actions_mapping[integration_id]["button_release"] }}'
#added by Dru
button_double: '{{ actions_mapping[integration_id]["button_double"] }}'
controller_entity: !input controller_entity
controller_device: !input controller_device
controller_id:
'{% if integration_id=="zigbee2mqtt" %}{{controller_entity}}{% else
%}{{controller_device}}{% endif %}'
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: !input controller_entity
- platform: event
event_type:
- deconz_event
- zha_event
event_data:
device_id: !input controller_device
condition:
- condition: and
conditions:
- '{%- set trigger_action -%} {%- if integration_id == "zigbee2mqtt" -%} {{ trigger.event.data.new_state.state
}} {%- elif integration_id == "deconz" -%} {{ trigger.event.data.event }} {%-
elif integration_id == "zha" -%} {{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length
> 0}}{{ trigger.event.data.args|join("_") }} {%- endif -%} {%- endset -%} {{ trigger_action
not in ["","None"] }}'
- '{{ integration_id != "zigbee2mqtt" or trigger.event.data.new_state.state != trigger.event.data.old_state.state
}}'
action:
- delay:
milliseconds: !input helper_debounce_delay
- variables:
trigger_action:
'{%- if integration_id == "zigbee2mqtt" -%} {{ trigger.event.data.new_state.state
}} {%- elif integration_id == "deconz" -%} {{ trigger.event.data.event }} {%-
elif integration_id == "zha" -%} {{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length
> 0}}{{ trigger.event.data.args|join("_") }} {%- endif -%}'
# trigger_delta:
# '{{ (as_timestamp(now()) - ((states(helper_last_controller_event)
# | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event)
# | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")) else as_timestamp("1970-01-01
# 00:00:00"))) * 1000 }}'
# - service: input_text.set_value
# data:
# entity_id: !input helper_last_controller_event
# value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
- choose:
# - conditions: '{{ trigger_action | string in button_short }}'
# sequence:
# - choose:
# - conditions: '{{ button_double_press }}'
# sequence:
# - choose:
# - conditions: '{{ trigger_action | string in states(helper_last_controller_event)
# and trigger_delta | int <= helper_double_press_delay | int }}'
# sequence:
# - service: input_text.set_value
# data:
# entity_id: !input helper_last_controller_event
# value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json
# }}'
# - event: ahb_controller_event
# event_data:
# controller: '{{ controller_id }}'
# action: button_double
# - choose:
# - conditions: []
# sequence: !input action_button_double
# default:
# - delay:
# milliseconds: '{{ adjusted_double_press_delay }}'
# - event: ahb_controller_event
# event_data:
# controller: '{{ controller_id }}'
# action: button_short
# - choose:
# - conditions: []
# sequence: !input action_button_short
# default:
# - event: ahb_controller_event
# event_data:
# controller: '{{ controller_id }}'
# action: button_short
# - choose:
# - conditions: []
# sequence: !input action_button_short
- conditions: "{{ trigger_action | string in button_long }}"
sequence:
- event: ahb_controller_event
event_data:
controller: "{{ controller_id }}"
action: button_long
- choose:
- conditions: "{{ button_long_loop }}"
sequence:
- repeat:
while: "{{ repeat.index < button_long_max_loop_repeats | int }}"
sequence: !input action_button_long
default: !input action_button_long
- conditions: "{{ trigger_action | string in button_release }}"
sequence:
- event: ahb_controller_event
event_data:
controller: "{{ controller_id }}"
action: button_release
- choose:
- conditions: []
sequence: !input action_button_release
# all below are added by dru
- conditions: "{{ trigger_action | string in button_short }}"
sequence:
- event: ahb_controller_event
event_data:
controller: "{{ controller_id }}"
action: button_short
- choose:
- conditions: []
sequence: !input action_button_short
- conditions: "{{ trigger_action | string in button_double }}"
sequence:
- event: ahb_controller_event
event_data:
controller: "{{ controller_id }}"
action: button_double
- choose:
- conditions: []
sequence: !input action_button_double
@LewisSpring , @lsismeiro you can close the bug if you need to. I have no further questions. Thank you!
Hello @drublin
Just to confirm, does this blueprint allow a single and double press of the button?
For now I will mark this as a workaround. After you confirm the above, I will upload this into the repository - not replacing the original version for now. Thanks for your help!
The blueprint update i posted above can assign actions to:
So yes, single, long and double press works.
Great, thank you. Will get this added for you.
Blueprint name
Controller - IKEA E1812 TRÅDFRI Shortcut button [Version 2022.08.08] [lsismeiro/ikea_e1812.yaml]
Home Assistant Core Version
2024.3.1
Home Assistant Installation Type
Home Assistant Operating System
Description
i try to configure IKEA E1812 Shortcut button [Firmware version 24.4.6] to work with Z2MQTT. Single and Long press work well. Double press though does not fire anything.
*Short press Logs (works well):![image](https://github.com/lsismeiro/awesome-ha-blueprints/assets/102928430/2a25f3cb-abbe-4493-bd59-0128007f17f8)
*Long Press and Release (works well):![image](https://github.com/lsismeiro/awesome-ha-blueprints/assets/102928430/a5aa1cf4-beae-4cd6-b23e-aeee96a61372)
*Double press Logs (doesn't work):![image](https://github.com/lsismeiro/awesome-ha-blueprints/assets/102928430/8607cb0c-f4d7-46e7-a3b3-93ccb4510504)
The blueprint documents say that double press action is not exposed, and is virtual with a separate switch. In the Z2Mqtt docs for IKEA shortcut button HERE I see a clear description of "action":"off" on double press.![image](https://github.com/lsismeiro/awesome-ha-blueprints/assets/102928430/f03c7896-f190-4cd7-9554-b249a782d206)
Same "off" action i see in the Z2M logs upon Double Press, but automation does not do what it is supposed to do.
I see the blueprint describes the exposed actions except "off".
maybe IKEA added this action command recently, after the initial blueprint was written, i don't know :(
Screenshots
Automation YAML config
To Reproduce
Expected behavior
activate a scene on button double press.
Actual Behaviour
double press is seen in logs, no automation actions are fired.
Additional Details
Screenshots
No response
Additional context
No response