Esphome number operation is not clear for me :(

Hi, i am stuck!
I am searching a way to use only esphome without homeassistant to do this:

i have two input number one for light on one for light off and an input select with two options
My goal is to insert an hour for light turn on and if the input select is in option 1 set the light off (current light on time + 18h automatically)

number:
  - platform: template
    name: "Ora accensione"
    mode: box
    unit_of_measurement: HH
    optimistic: true
    min_value: 0
    max_value: 23
    step: 1
    id: lon
    on_value:
      then:
        - if:
            condition:
              lambda: |-
                return id(stadio).state == "1";
            then:
In this section i have tryed infinite stuff but i cant think that is the right way 
              - number.operation:
                  id: loff
                  operation: !lambda "return id(lon);"
              - number.operation:
                  id: loff
                  operation: !lambda "(return id(lon) +18);"
                  cycle: yes
  - platform: template
    name: "Ora spegnimento"
    mode: box
    unit_of_measurement: HH
    optimistic: true
    min_value: 0
    max_value: 23
    step: 1
    id: loff

I would like to create a on off timer that have power loss capability (so time platform is not an option if i turn on the light and i had a power outage if the power come up after turn off hour it remain on until the next day.)
The perfect solution can be to program a funcion like this in esphome:
Times of the Day - Home Assistant.

And use it in a time interval but i cant find anything similar in esphome :frowning: