Hi! I have two buttons/switches that works fine, one is a RfLink device (“matbord_brytare”), a 2-gang switch sending “ON” one way and “OFF” the other way. The second is a IKEA Tradfri E1810 (“tradfri_remote”), and I’m using action “brightness_up_click” or “brighness_down_click” to turn the lamp on or off. By themselves they works fine using an automation to turn on or off a light.
The configuration for the RfLink switch:
- platform: rflink
device_defaults:
fire_event: true
signal_repetitions: 2
devices:
newkaku_0009db9a_2:
name: matbord_brytare
The problem arises when I try to combine these two switches to control a single light (i.e. a lamp (“kokslampa_matbord”) in a room with with one switch in each end of the room) so I can control the light from any switch.
I tried the following automation (one for “on” and one for “off”):
- alias: "Matbordslampan on"
trigger:
- platform: state
entity_id: switch.matbord_brytare
to: "on"
- platform: state
entity_id: sensor.tradfri_remote_action
to: "brightness_up_click"
action:
- service: light.turn_on
entity_id: light.kokslampa_matbord
- service: switch.turn_on
entity_id: switch.matbord_brytare
- alias: "Matbordslampan off"
trigger:
- platform: state
entity_id: switch.matbord_brytare
to: "off"
- platform: state
entity_id: sensor.tradfri_remote_action
to: "brightness_down_click"
action:
- service: light.turn_off
entity_id: light.kokslampa_matbord
- service: switch.turn_off
entity_id: switch.matbord_brytare
The Tradfri seems to work most of the time (on and off), but not the RfLink. To be synchronized I try to reflect the state of the switches, so that when Tradfri turns on, it sets the state of the “matbord_brytare” to “on” as well. But however I try it will not work. Most of the time the Tradfri works ok, but if I turn on the lamp using it, I can’t change the state of the lamp using the RfLink switch. Sometimes it works when I turn the lamp off again using the Tradfri, but sometimes the RfLink doesn’t work at all.
I can see in the log that the message from the RfLink (“matbord_brytare turned on”) comes and that the automation (“Matbordslampan on”) is started, but checking the trace of the automation shows that the first service is called but the automation is still running (i.e. not executing the second service) and then the buttons are out of sync.
I’ve tried different approaches in the automation, but fail to get it working perfect (the best I can achieve (by having one set of automation for each switch) is that I sometimes have to press the RfLink on and off once or twice to get them in sync and it will work again).
Anyone have an idea what I do wrong or is missing? Any ideas for a better approach?
It seems simple enough, but apparently I have missed something …
Cheers,
Thomas