Best way to implement an on/off switch with a controlled device?

I don’t use the UI for creating automations so I don’t do device automations but you could do the same with state automations using a template in the service and it will “simplify” things (templates might not be simple tho depending on your abilities).

Anyway here is how I would do it:

alias: 'Family Room: Ikea switch test'
description: ''
trigger:
  - platform: state
    entity_id: your_entity_id_here
    to: 'on'
    id: onbutton
  - platform: state
    entity_id: your_entity_id_here
    to: 'off'
    id: offbutton
action:
  -  service: switch.turn_{{ 'on' if trigger.id == 'on' else 'off'}}
     entity_id: switch.on_off_module_4f_27_d2
mode: single

Not sure what your deconz entity is tho.

or you could mix and match by using the existing device triggers with the templated service call.

1 Like