Switches showing differently in Home Assistant

I am just moving over to esphome but I am obviously not understanding something; my switches for the plugs don’t show up as the sliding type in HA but as individual lightning bolts/light bolt with line through them! How can I get them to be sliding switches? The code in esphome is

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO13
    mode: INPUT_PULLUP
    inverted: True
    id: button
    on_press:
    • switch.toggle: fakebutton
  • platform: status
    name: “Power Monitor 2 Status”
    switch:
  • platform: template
    name: “Power Monitor 2 Switch” –this is the switch name in HA
    id: fakebutton
    optimistic: true
    turn_on_action:
    • light.turn_on: led
    • switch.turn_on: relay
      turn_off_action:
    • light.turn_off: led
    • switch.turn_off: relay
  • platform: gpio
    pin: GPIO15
    id: relay
  • platform: restart
    name: “Power Monitor 2 Restart”
    output:
  • platform: esp8266_pwm
    id: basic_blue_led
    pin:
    number: GPIO2
    inverted: True
    light:
  • platform: monochromatic
    output: basic_blue_led
    id: led

The ‘Restart’ switch shows up as I want. What am I doing wrong?

For a start you aren’t posting your code properly formatted for the forum. :wink:

1 Like

Because there is no function to fetch the state and you set it up as optimistic, so is expected to show like that.

1 Like

This is the line. See docs

1 Like

Thank you all! I have now learnt how to include code snips !! and solved my problem with a better understanding of lambda.