Switch makes me crazy: not recognized

Hi guys,
Really happy to join this community. I have set up a HA first on PI3 and now on NUC using KVM. Everything works fine. I want to set up a PSA controller, here also all good.
Except one thing which makes me cray : switch are simply not recognized.

I even try a very simple configuration.yaml:

default_config:

switch:
  - platform: command_line
    switches:
      test_switch:
        command_on: "echo 'on' > /tmp/test_switch.txt"
        command_off: "echo 'off' > /tmp/test_switch.txt"
        command_state: "cat /tmp/test_switch.txt"
        value_template: '{{ value == "on" }}'
        friendly_name: "Test Switch"

I then restart HA (system restart) and when I look for switch.test_switch in Developer Tools → States…nothing!

Any help is more than welcome.
Thanks

Your formatting doesn’t really seem to follow the docs:

Ok thanks, indeed it helped me. I finally fixed it but really strange is that what chatgpt generate is wrong and exactly the opposite:
Below code is OK for HA but Chatgpt says it is worng:
`
command_line:

  • switch:
    name: office_computer
    command_on: “your_cmd”
    command_off: “your_cmd”
  • switch:
    name: office_computer2
    command_on: “your_cmd”
    command_off: “your_cmd”
    `

And ChatGPT proposes yaml below which is rejected by HA:

`
switch:

  • platform: command_line
    switches:
    office_computer3:
    command_on: “your_cmd”
    command_off: “your_cmd”

  • platform: command_line
    switches:
    office_computer4:
    command_on: “your_cmd”
    command_off: “your_cmd”
    `
    So at least I hope it can help some of you, and even better if soe of can understand why chatgpt is wrong :wink:
    Thanks