How do I test a helper in a script?

This is a question similar to one I asked last week, but that thread got way off topic. So, I am trying again.

I am trying to enable/disable OTA in an ESP node without using MQTT. I have it working. Sort of.
What works is a switch in the node yaml:

switch:
  - platform: gpio
    name: ${device_name} otamode
    pin:
      number: D4
      mode: output
    id: ${device_name}_d4

And in the script I test the switch state:

  - if:
    condition:
      switch.is_on: ${device_name}_d4
	then:

This works exactly as I want, except for one small issue… I can only control the switch state from the front-end when the ESP is online.

So, why not use a helper entity? It would be there whether the ESP is online or not.

I created a boolean helper that I can control in the front-end. But, how do I test it in a script?
I can’t test it with a .is_on: condition, (Or can I?)

I tried reading the state:

  -if:
    condition:
      state:
      entity_id: input_boolean.ota_mode
      state: "on"
    then:

But my expertise with yaml is about as hopeless as is possible.

Any tips would be appreciated.

This how I use an input_boolean for switching an Oled screen “on/off”. Just check the state in a lambda

text_sensor:
  - platform: homeassistant
    entity_id: input_boolean.mobiele_baro_scherm
    id: scherm_aan

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    update_interval: 5s
    id: oled
    lambda: |-
      if (id(scherm_aan).state == "on") {
        it.printf(0, 0, id(my_font), "Tem: %.1f°C", id(temp).state);
        it.printf(0, 30, id(my_font), "Hum: %.1f%%", id(hum).state);
      } else {
        it.fill(COLOR_OFF);
      }

Thanks for the tip. Working with Lambdas is my weakness, but I am learning.

See here an example if you want to avoid a lambda call Text Sensor Component — ESPHome

Thanks. Your tips got me to a solution.