Help! post update

After the update I can’t get this to work:

 - platform: mqtt
    unique_id: Luce_Studio_switch
    name: "Switch_luce_studio"
    state_topic: "stat/consumi/POWER1"
    command_topic: "cmnd/consumi/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
    #state_on: "ON"
    #state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
  - platform: template
    switches:
      luce_studio_template:
        unique_id: Luce_Studio_template
        value_template: "{{ is_state('switch.Switch_luce_studio', 'on') }}"
        turn_on:
          service: script.Script_luce_studio
          data:
            entity_id: switch.Switch_luce_studio_open
        turn_off:
          service: script.Script_luce_studio
          data:
            entity_id: switch.Switch_luce_studio_close
        icon_template: >-
          {% if is_state('switch.Switch_luce_studio', 'on') %}
            mdi:lightbulb-on
          {% else %}
            mdi:lightbulb-off
          {% endif %}

I changed it like this but it gives me an error on the template

mqtt:
  switch:
  - unique_id: Luce_Studio_switch
    name: "Switch_luce_studio"
    state_topic: "stat/consumi/POWER1"
    command_topic: "cmnd/consumi/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
    #state_on: "ON"
    #state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
- platform: template
    switches:
       luce_studio_template:
        unique_id: Luce_Studio_template
        value_template: "{{ is_state('switch.Switch_luce_studio', 'on') }}"
        turn_on:
          service: script.Script_luce_studio
          target: #data:
            entity_id: switch.Switch_luce_studio_open
        turn_off:
          service: script.Script_luce_studio
          target: #data:
            entity_id: switch.Switch_luce_studio_close
        icon_template: >-
          {% if is_state('switch.Switch_luce_studio', 'on') %}
            mdi:lightbulb-on
          {% else %}
            mdi:lightbulb-off
          {% endif %}

can you help me thanks

After what update?

What error?

It might be that script.Script_luce_studio doesn’t exist, since it’ll be script.script_luce_studio. That’s just a guess though.

I assume the original code was for the “switch” domain.

so you need this:

mqtt:
  switch:
  - unique_id: Luce_Studio_switch
    name: "Switch_luce_studio"
    state_topic: "stat/consumi/POWER1"
    command_topic: "cmnd/consumi/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
    #state_on: "ON"
    #state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true

switch:
  - platform: template
    switches:
       luce_studio_template:
.
.
1 Like

Thanks a lot, now it works

1 Like