Need help setting up a Template Switch in ESPHome

I am trying to set up a template switch in ESPHome that will use a binary sensor (button1) on a Nextion display. When I try to validate the whole page is mostly red.

# Example configuration entry
switch:
  - platform: template
    name: "Template Switch"
    lambda: |-
      if (id(some_binary_sensor).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - switch.turn_on: switch2
    turn_off_action:
      - switch.turn_on: switch1

I am not sure what the switch1 and switch2 are.

I replaced some_binary_sensor with button1, changed the name to button1_switch and I set up under binary senor:

  - platform: nextion
    page_id: 0
    component_id: 2
    nextion_id: irrigation
    id: button1
    name: "Button 1"
    filters:
      - delayed_on_off: 100ms
    on_press:
      then:
        - switch.toggle: button1_switch

Thanks for any help.

So now all you need is a switch with id: button1_switch. Perhaps show us more code and explain what should be happening. It’s always good practice to give your entities descriptive names rather than “Button 1”.