Switch and Dimmer - 2 entities -> 1 command

Hi everybody! I have a question for you:
i have a strip led connected by two smart device:

  1. smart relay that pilot the power supply 220v - 24v
  2. dimmer 24v - 24v for light intensity
    I know that was better have a TRIAC and a 220v dimmer but now i wan’t buy everything twice.
    My question is: it’s possible pilote this two entities like one, e.g. like a native dimmer lightbulb
    → ON-OFF: switch the status of releay
    → Dimming: change intensity

using a custom entity like this:

thank you so much

can u write an example of integration?

What are your relay and brightness control entity ids?

And what values does the brightness control take?

dimmer

switch

Try this:

# configuration.yaml entry
light:
  - platform: template
    lights:
      some_light: # change this to whatever entity_id you want
        friendly_name: "Some Light" # change this to whatever name you want
        level_template: "{{ state_attr('light.zig_dimmer_letto', 'brightness')|int(0) }}"
        value_template: "{{ is_state('light.micromodule_switch_3_lightbulb','on') }}"
        turn_on:
          service: light.turn_on
          target: 
            entity_id: light.micromodule_switch_3_lightbulb
        turn_off:
          service: light.turn_off
          target: 
            entity_id: light.micromodule_switch_3_lightbulb
        set_level:
          - service: light.turn_on
            target: 
              entity_id: light.micromodule_switch_3_lightbulb
          - service: light.turn_on
            target:
              entity_id: light.zig_dimmer_letto
            data:
              brightness: "{{ brightness }}"
1 Like

thank you so much! it works perfectly!

1 Like

can I create a separate light.yaml file and import it in configuration.yaml to beautify that ?

Sure:

configuration.yaml

light: !include lights.yaml

lights.yaml

- platform: template
  lights:
    some_light: # change this to whatever entity_id you want
      friendly_name: "Some Light" # change this to whatever name you want
      level_template: "{{ state_attr('light.zig_dimmer_letto', 'brightness')|int(0) }}"
      value_template: "{{ is_state('light.micromodule_switch_3_lightbulb','on') }}"
      turn_on:
        service: light.turn_on
        target: 
          entity_id: light.micromodule_switch_3_lightbulb
      turn_off:
        service: light.turn_off
        target: 
          entity_id: light.micromodule_switch_3_lightbulb
      set_level:
        - service: light.turn_on
          target: 
            entity_id: light.micromodule_switch_3_lightbulb
        - service: light.turn_on
          target:
            entity_id: light.zig_dimmer_letto
          data:
            brightness: "{{ brightness }}"
1 Like