I need "entity: light.zs_ho" to become "switch.sw_ho" with all on/off functionality

Hi. I have an entity: light.zs_ho and I need it to become an entity: switch.sw_ho with all on/off functionality.

Entity: light.zs_ho is zigbee2mqtt dimmer switch device and does not have the option of changing to a switch!

I currently have the following configuration in switch.yaml:

  • platform: template
    switches:
    sw_ho1:
    value_template: “{{ is_state(‘switch.sw_ho’, ‘on’) }}”
    turn_on:
    service: light.turn_on
    target:
    entity_id: light.zs_ho
    turn_off:
    service: light.turn_off
    target:
    entity_id: light.zs_ho
    unique_id: 1979270a-9225-4b55-9f5b-4d160d521b74
    icon_template: >-
    {% if is_state(‘switch.sw_ho’, ‘on’) %}
    mdi:toggle-switch-variant
    {% else %}
    mdi:toggle-switch-variant-off
    {% endif %}
    • platform: template
      switches:
      sw_ho2:
      value_template: “{{ is_state(‘light.zs_ho’, ‘on’) }}”
      turn_on:
      service: switch.turn_on
      target:
      entity_id: switch.sw_ho
      turn_off:
      service: switch.turn_off
      target:
      entity_id: switch.sw_ho
      unique_id: a38ee6b3-6bb7-4ddd-a3a3-e1fb44e07722
      icon_template: >-
      {% if is_state(‘light.zs_ho’, ‘on’) %}
      mdi:toggle-switch-variant
      {% else %}
      mdi:toggle-switch-variant-off
      {% endif %}

When I turn on the light.zs_ho

it shows me in the template switch

when i click on switch.sw_ho2 it shows me that it is on when light.zs_ho is on



both are on

when I want through the entity: switch switch.sw_ho2 which shows me that it is on this switch turn off the switch turns off.

entities: switch switch.sw_ho1 is off

entity: light.zs_ho, however, remains on

when I turn on entity: switch.sw_ho1

nothing happens except that this switch becomes on.

but when entity: switch.sw.ho1 turn off

the entity: light.zs.ho turn off

Does anyone have an idea how to solve the problem?

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Use the value_template from your second switch in your first switch. Then delete the second switch.

1 Like

Thanks. It is works now.