How do I have a device (e.g., light or another switch) mirror the behavior of a source switch. In SmartThings, it was called “mirror behavior.”
You can use an automation:
trigger:
platform: state
entity_id: switch.controller
condition:
platform: template
value_template: "{{ trigger.to_state.state in ['on', 'off'] }}"
action:
service: >
light.turn_{{ trigger.to_state.state }}
entity_id: light.controlled
This assumes you are using HA v0.115 or greater. If not you must use:
action:
service_template: >
light.turn_{{ trigger.to_state.state }}
entity_id: light.controlled
Thanks. This is a very noob is question, but where do I find the device ids to include in the code? I keep getting them wrong.
Developer Tools > States
I tried this code and the plugged lights don’t respond. Further, the switch is a dimmer as is the plug module. I believe this code just turns the lights on and off.
You asked about a switch. I gave you an answer about a switch.
Sorry, I guess I was unclear. So, what I have (three instances of this) is a zwave or zigbee dimmer switch that is actually not hooked up to a light; they are just servicing a wall plug that is not used. I then have Leviton or GE dimmer plug module that the lights plug into. When I used Smartthings, I just set the plug to “mirror behavior” of the switch, it was a simple pull down option. When I dimmed the switch, the plug in module would dim the lights to match the switch. This is my way of keeping my wife happy as she can just use the normal switch.
I am now trying to figure out this coding. Thanks for your help, btw.