Template switch not showing up

Trying to create a switch to enable manual control of my house fan via Ecobee. I cannot get the switch to show up in HA anywhere. Read high and low and seems like anyone else who had this problem had a yaml formatting error, but it checks out as valid, also copied/pasted numerous other people’s “working” code, can’t get it. I can intentionally muck up the formatting and make it throw an error, so it’s evaluating the code. I built a simple “test” switch in case something with the ecobee was throwing it off, won’t work either. Been in and out with formatting, extra indenting, anything I could change but still have it validate with no luck. Any ideas welcome!!

configuration.yaml
switch: !include switches.yaml

switches.yaml

- platform: template
  switches:
    test_switch:
      friendly_name: "Test switch"
      value_template: "{{ is_state('switch.desk_lamp', 'on') }}"
      turn_on:
        - service: switch.turn_on
          data:
            entity_id: switch.desk_lamp
      turn_off:
        - service: switch.turn_off
          data:
            entity_id: switch.desk_lamp

- platform: template
  switches:
    thermostat_fan_mode:
      friendly_name: "Thermostat Fan Mode"
      value_template: "{{ states.climate.my_ecobee.attributes.fan_min_on_time | int > 10 }}"
      turn_on:
        - service: ecobee.set_fan_min_on_time
          data:
            entity_id: climate.my_ecobee
            fan_min_on_time: 60
      turn_off:
        - service: ecobee.set_fan_min_on_time
          data:
            entity_id: climate.my_ecobee
            fan_min_on_time: 10

Have you looked in the STATES tab of the Developer Tools page? Maybe they’re just not showing up in the frontend due to how you configured Lovelace???

I don’t know if this is a problem, but typically you put all the template switches under one platform: template entry, like so:

- platform: template
  switches:
    test_switch:
      friendly_name: "Test switch"
      value_template: "{{ is_state('switch.desk_lamp', 'on') }}"
      turn_on:
        - service: switch.turn_on
          data:
            entity_id: switch.desk_lamp
      turn_off:
        - service: switch.turn_off
          data:
            entity_id: switch.desk_lamp
    thermostat_fan_mode:
      friendly_name: "Thermostat Fan Mode"
      value_template: "{{ states.climate.my_ecobee.attributes.fan_min_on_time | int > 10 }}"
      turn_on:
        - service: ecobee.set_fan_min_on_time
          data:
            entity_id: climate.my_ecobee
            fan_min_on_time: 60
      turn_off:
        - service: ecobee.set_fan_min_on_time
          data:
            entity_id: climate.my_ecobee
            fan_min_on_time: 10

Yes, not showing under dev tools/states.

You’re right they should probably be under one template headings, but I only had the one until I added the “test_switch” and didn’t work then either… But I will try consolidating them

Found it…There was one tiny little duplicate switch: entry buried in configuration.yaml that was causing the switch file to be ignored.

After getting it to work, I tried it both with the two switches under one platform: template entry as well as under their own duplicate entries and it worked both ways. Thanks

1 Like