Deprecation template

Hi everyone… I know this topic has been covered in other threads. I’ve tried following the other threads and reading the HomeAssistant documentation, but I can’t seem to update this switch with the new expected syntax.
Would anyone be so kind as to help me?

switch:
  - platform: template
    switches:
      auto_clean:
        unique_id: XXXXXXXX
        value_template: "{{ is_state_attr('climate.samsung_ac_1', 'auto_clean', 'on') }}"
        turn_on:
          service: climate.climate_ip_set_property
          data:
            entity_id: climate.samsung_ac_1
            auto_clean: 'on'
        turn_off:
          service: climate.climate_ip_set_property
          data:
            entity_id: climate.samsung_ac_1
            auto_clean: 'off'```

try this.

template:
  - switch:
      - name: Auto Clean
        unique_id: xxx
        state: "{{ is_state_attr('climate.samsung_ac_1', 'auto_clean', 'on') }}"
        turn_on:
          - action: climate.climate_ip_set_property
            data:
              entity_id: climate.samsung_ac_1
              device: 'on'
        turn_off:
          - action: climate.climate_ip_set_property
            data:
              entity_id: climate.samsung_ac_1
              device: 'off'

If you update to the latest version, you will get a repair notice. Don’t worry, the old things will still work in the new version. They will keep working for six months. But the repair notice shows the exact yaml you need, together with some instructions. Those instructions have improved in the latest maintenance release. The safest way is to use that, because manual conversions tend to miss important stuff (or contain typos).

If you do insist on manual conversion, which is a great way to learn, at least compare it to the converted template in the repair notice to see if you missed anything.

If you tried and failed, check the top post of the below mentioned thread. It contains common mistakes and solutions. If that too does not help, reach out in the same thread and we will help you fix whatever error you get.

when I try to activate the switch, I get this error: “Failed to perform the action switch/turn_on. extra keys not allowed @ data[‘device’]”

I tried to use the code suggested by the Home Assistant alert, but with that the switch just stops working (it turns grey)

Where did you put the new yaml exactly? In configuration.yaml or some other file? The problem is not in the yaml but in where/how it was placed. What is the right way depends on what you already had in there.

Again, use the version from the repair, as you’ve seen manual conversions do contain mistakes.

ps. No need to hide the unique id with xxx - it is not secret. It does need to remain the same. If it was XXXX, keep it but use something more unique in the future.

I added it to configuration.yaml, exactly where the old switch was. Home Assistant basically suggests I change the code (in the first comment) to:

template:
- switch:
  - unique_id: 3o0aOVtcvT
    turn_on:
    - data:
        entity_id: climate.samsung_ac_1
        auto_clean: 'on'
      action: climate.climate_ip_set_property
    turn_off:
    - data:
        entity_id: climate.samsung_ac_1
        auto_clean: 'off'
      action: climate.climate_ip_set_property
    default_entity_id: switch.auto_clean
    state: '{{ is_state_attr(''climate.samsung_ac_1'', ''auto_clean'', ''on'') }}'
    name: auto_clean

so the switch stops working

The old one was below switch but it now belongs below template, so it can not remain in exactly the same place. If you already had a template: line then you must place it below that, and remove the template: line from the suggested yaml. That is because you can only have one template: line in the file. You also need to match the indenting of the new template and the existing ones. Indentation is important in yaml.

Thanks so much. That solved it! :kissing_heart:

1 Like