EPMatt / awesome-ha-blueprints

A curated collection of automation blueprints for Home Assistant.
https://epmatt.github.io/awesome-ha-blueprints
GNU General Public License v3.0
836 stars 250 forks source link

Bug - Issues with Ikea E1743 and Zigbee2MQTT #167

Open runejuhl opened 2 years ago

runejuhl commented 2 years ago

Blueprint name

Controller - IKEA E1743 On/Off Switch & Dimmer

Home Assistant Core Version

2021.10.6

Home Assistant Installation Type

Home Assistant Container

Description

When configuring an automation using the E1743 blueprint and Zigbee2MQTT, Home Assistant shows warnings in the log when buttons are pressed:

2021-10-28 14:35:57 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'click' when rendering '{{ value_json.click }}'
2021-10-28 14:36:01 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'click' when rendering '{{ value_json.click }}'

Additionally long press and double press actions do not work.

When using the sensor action event the automation breaks completely if "Expose up/down button double press event" is enabled. If using the deprecated click event single press events work, but actions have a delay matching the configured "Helper - Double Press delay".

I've confirmed this by adding additional actions to long and double presses that send notifications.

Automation YAML config

alias: Bedroom RGBW LED strip
description: ''
use_blueprint:
  path: EPMatt/ikea_e1743.yaml
  input:
    integration: Zigbee2MQTT
    zigbee2mqtt_remote: sensor.0x5c0272fffe44cb9e_click
    action_up_short:
      - type: turn_on
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        entity_id: light.rgbw_led_strip
        domain: light
      - service: notify.matrix_botsen
        data:
          message: turn on led strip
    action_down_short:
      - type: turn_off
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        entity_id: light.rgbw_led_strip
        domain: light
    button_up_long_loop: true
    button_down_long_loop: true
    action_up_long:
      - device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
        entity_id: light.rgbw_led_strip
        type: brightness_increase
      - service: notify.matrix_botsen
        data:
          message: led strip increase
    action_down_long:
      - device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
        entity_id: light.rgbw_led_strip
        type: brightness_decrease
    helper_last_loop_event_input: input_text.bedroom_e1743_led_strip_helper
    action_up_double:
      - service: mqtt.publish
        data:
          payload: '{"color_temp": "500", "brightness": "254"}'
          topic: zigbee2mqtt/0x842e14fffe34429e/set
      - service: notify.matrix_botsen
        data:
          message: double press led strip remote
    button_up_double_press: true
    button_down_double_press: true
    remote: 89f6acce4fc881b810a4b48ab9a25b94
    helper_double_press_delay: 500

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Trigger the automation '....'
  4. See error

Expected behavior

Double and long press actions should work.

Actual Behaviour

Double and long press actions do not work.

Additional Details

Screenshots

No response

Additional context

Thank you for the blueprints @EPMatt!

runejuhl commented 2 years ago

I just noticed that my blueprint was ancient -- it seems to be from 6bf93e59a7ae35801be166ee985d97eb05bb0626 or before. Somehow I had got the idea that blueprints were automatically updated.

I'll try upgrading the blueprint and seeing if it works properly.

EPMatt commented 2 years ago

Hi @runejuhl,

thank you for your report.

I just noticed that my blueprint was ancient -- it seems to be from 6bf93e59a7ae35801be166ee985d97eb05bb0626 or before.

Yeah, I can see from the YAML you provided that the version you're using is quite old. We did many improvements throughout the latest months (including better documentation, debouncing support, etc.). :)

We also introduced a couple of Breaking Changes to blueprint inputs. I highly suggest you to read the E1743 Changelog to see what's changed.

Anyway, I prepared the updated YAML for your automation. Here it is:

alias: Bedroom RGBW LED strip
description: ''
use_blueprint:
  path: EPMatt/ikea_e1743.yaml
  input:
    integration: Zigbee2MQTT
    controller_entity: sensor.0x5c0272fffe44cb9e_entity
    helper_last_controller_event: input_text.bedroom_e1743_led_strip_helper
    action_up_short:
      - type: turn_on
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        entity_id: light.rgbw_led_strip
        domain: light
      - service: notify.matrix_botsen
        data:
          message: turn on led strip
    action_down_short:
      - type: turn_off
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        entity_id: light.rgbw_led_strip
        domain: light
    action_up_long:
      - device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
        entity_id: light.rgbw_led_strip
        type: brightness_increase
      - service: notify.matrix_botsen
        data:
          message: led strip increase
    action_down_long:
      - device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
        entity_id: light.rgbw_led_strip
        type: brightness_decrease
    action_up_double:
      - service: mqtt.publish
        data:
          payload: '{"color_temp": "500", "brightness": "254"}'
          topic: zigbee2mqtt/0x842e14fffe34429e/set
      - service: notify.matrix_botsen
        data:
          message: double press led strip remote
    button_up_long_loop: true
    button_down_long_loop: true
    button_up_double_press: true
    button_down_double_press: true
    helper_double_press_delay: 500

I converted a few input names, but kept all your custom actions and configs. I also removed the remote input (currently named controller_device but not required when using Zigbee2MQTT) and provided the *_action entity to the controller_entity input.

Let me know if updating the blueprint and using the above YAML to configure the automation solve your issue. If you've any additional questions or doubts I'd be glad to help. :)

Thanks!

rschoultz commented 2 years ago

Not OP, but I have the same issue with the error message in version 2021.10.26 of EPMatt/ikea_e1743

When "Run Actions", I get this error:

2021-11-28 20:51:12 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'dict object' has no attribute 'event' when rendering '{%- 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 -%}'
2021-11-28 20:51:12 ERROR (MainThread) [homeassistant.components.automation.my_test] My Switch: Error executing script. Error rendering template for variables at pos 2: UndefinedError: 'dict object' has no attribute 'event'
2021-11-28 20:51:12 ERROR (MainThread) [homeassistant.components.automation.my_test] Error while executing automation automation.my_test: UndefinedError: 'dict object' has no attribute 'event'

I copied and modified from your message above (note you wrote action_up_long and I figured after a while it should be action_button_up_long). I do get the brightness to increase/decrease despite the problem with the Run Action, but this is as far as I have tested.

alias: My test
description: ''
use_blueprint:
  path: EPMatt/ikea_e1743.yaml
  input:
    integration: Zigbee2MQTT
    controller_entity: sensor.my_switch_action
    helper_last_controller_event: input_text.my_switch_help
    action_button_up_long:
      - type: brightness_increase
        entity_id: light.my_light_1
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
    action_button_down_long:
      - type: brightness_decrease
        entity_id: light.my_light_1
        device_id: d89dbe23b8615d8b0927c053b8adeec7
        domain: light
    button_up_long_loop: true
    button_down_long_loop: true
    button_up_double_press: true
    button_down_double_press: true
    helper_double_press_delay: 500

Also, here is a screenshot of what I believe you had requested:

Screenshot 2021-11-28 at 21 52 07

Many thanks for providing these blueprints! Indeed awesome.