aik
(aik)
October 7, 2020, 3:02am
1
I have an Ikea TRÅDFRI Dimmer kit E27 with a bulb and a switch. On the demo stand in Ikea (where the switch is connected directly to the bulb, I am guessing) when push-and-hole “+” button, this continuously increases the brightness. At home, I hooked it up to HA and configured actions via automation which works but without autorepeating, i.e. I have to press and release “+” multiple time to get it to the max light.
I checked the mosquitto logs and it turns out the switch sends one “key down” event when I press “+” and that’s all. So I guess the way the bulb works is that it starts increasing the brightness when “down” arrives and stops when “up” arrives. Which is doable via HA but this requires a timer and more automations per a single switch.
Is there a simpler way to automate this brightness increase by holding a button?
francisp
(Francis)
October 7, 2020, 4:28am
2
What Zigbee integration do you use ? Zigbee2mqtt I guess because you talk about mqtt. I just used binding to bind the dimmer directly to the group, group containing just one light… Now it works like in the ikea.
Another option is to use controllerx. (Search the forum for controllerx)
aik
(aik)
October 7, 2020, 4:49am
3
yes this is Zigbee2mqtt, and the controllerx seems the way to go, thanks for the pointer!
When you bind the dimmer to the group, does it mean the group is not controlled by HA by any means?
francisp
(Francis)
October 7, 2020, 4:56am
4
I can still control the light through HA, so that is no problem.
bryanbr
(Bryan Bredehoeft)
October 7, 2020, 5:47am
5
I have had success with ZHA (not tried Zigbee2mqtt). If you want to go that route, you have to add a script like this:
---
#
# This automation simulates the use of the IKEA TRADFRI Remote control
# connected through zha but should also work for other type of events.
# Requires Home Assistant 0.113 or higher.
#
id: 'living_room-ikea_remote'
alias: IKEA Remote
description: ''
mode: restart
trigger:
- platform: event
event_type: zha_event
condition:
- condition: template
# Change this to your own device_ieee (lookup on the device page)
value_template: '{{ trigger.event.data.device_ieee == "<MAC ADDRESSS of TRADFRI>" }}'
action:
- choose:
# Short-Press on the power button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "toggle" }}'
sequence:
- service: light.toggle
data_template:
entity_id: light.entry_light
# Short-Press on the dim-up button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "step_with_on_off" }}'
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
brightness_step_pct: 20
transition: 0.5
# Short-Press on the dim-down button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "step" }}'
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
brightness_step_pct: -20
transition: 0.5
# Short-Press on the color-up button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "press" }}'
- condition: template
value_template: '{{ trigger.event.data.args == [256,13,0] }}'
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
hs_color:
- >-
{% if state_attr("light.entry_light", "hs_color")[0] + 18 > 360 %}
{{ state_attr("light.entry_light", "hs_color")[0] + 18 - 360 }}
{% else %}
{{ state_attr("light.entry_light", "hs_color")[0] + 18 }}
{% endif %}
- '{{ state_attr("light.entry_light", "hs_color")[1] }}'
transition: 0.5
# Short-Press on the color-down button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "press" }}'
- condition: template
value_template: '{{ trigger.event.data.args == [257,13,0] }}'
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
hs_color:
- '{{ state_attr("light.entry_light", "hs_color")[0] }}'
- >-
{% if state_attr("light.entry_light", "hs_color")[1] - 20 < 0 %}
{{ state_attr("light.entry_light", "hs_color")[1] - 20 + 100 }}
{% else %}
{{ state_attr("light.entry_light", "hs_color")[1] - 20 }}
{% endif %}
transition: 0.5
# Long-Press on the power button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move_to_level_with_on_off" }}'
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
brightness: 254
hs_color:
- 38.222
- 52.941
# Long-Press on the color-up button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "hold" }}'
- condition: template
value_template: '{{ trigger.event.data.args == [3328,0] }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
hs_color:
- >-
{% if state_attr("light.entry_light", "hs_color")[0] + 18 > 360 %}
{{ state_attr("light.entry_light", "hs_color")[0] + 18 - 360 }}
{% else %}
{{ state_attr("light.entry_light", "hs_color")[0] + 18 }}
{% endif %}
- '{{ state_attr("light.entry_light", "hs_color")[1] }}'
transition: 0.5
- delay:
milliseconds: 500
# Long-Press on the color-down button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "hold" }}'
- condition: template
value_template: '{{ trigger.event.data.args == [3329,0] }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
hs_color:
- '{{ state_attr("light.entry_light", "hs_color")[0] }}'
- >-
{% if state_attr("light.entry_light", "hs_color")[1] - 10 < 0 %}
{{ state_attr("light.entry_light", "hs_color")[1] - 10 + 100 }}
{% else %}
{{ state_attr("light.entry_light", "hs_color")[1] - 10 }}
{% endif %}
transition: 0.5
- delay:
milliseconds: 500
# Long-Press on the dim-up button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
brightness_step_pct: 10
transition: 0.5
- delay:
milliseconds: 500
# Long-Press on the dim-down button.
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move" }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
data_template:
entity_id: light.entry_light
brightness_step_pct: -10
transition: 0.5
- delay:
milliseconds: 500
# Any other event will cancel the repeat loops.
default: []
Then the automation looks something like this:
alias: IKEA Entry On
id: 'Entry-Turn_on_Light'
description: ''
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.entry_motion_sensor
to: 'on'
condition:
- condition: time
after: '06:30:00'
before: '22:00:00'
action:
- service: light.turn_on
entity_id: light.entry_light
Hope this helps,
~Bryan