Start time-based automation from Lovelace

hi!

How to start and stop execution of this automation by switch from Lovelace?

 - platform: sntp
    id: someid
    on_time:
      - seconds: 0
        minutes: 50
        hours: 7, 21
        days_of_week: '*'
        then:
          if:
            condition:
              switch.is_off: relay2
            then:    
            - switch.turn_on: relay2
            - delay: 10s
            - switch.turn_off: relay2

any help?
thanks!

Create a “helper” input_boolean and make another automation observe it’s state changes, calling either automation.turn_on or automation.turn_off service.

Isn’t it possible to just activate or deactivate the automation via Lovelace?
You can just put the entity of the automation in a Lovelace card

See this example. You can enable or disable the automation without any need of “helper”.

1 Like

Yes, of course it is.

Maybe this is the easiest solution for @kabro
Or am I wrong?

1 Like

your better using the new custom comptent and lovelace scheduler

and

This looks suspiciously like an automation in esphome, not home assistant, so the previous answers are not applicable.

@kabro you could either:

  1. Automate the switches directly in home assistant. Write a script and call it from a button action, or write an automation. This assumes that relay2 is exposed to home assistant.

  2. Import an input boolean into esphome as a binary sensor and trigger off that (on_press) in esphome when it is switched in Lovelace.

yes. this is esphome automation.
thanks mates!
will try on tom’s advices…

one rectification…
this automation in progress every day at the specified time.
I want to stop/start execute automation by switch (turn switch ON - relay2 turns on every day at the specified time; (turn switch OFF - stops automation execution)

Then instead of triggering on the imported home assistant input boolean, use it as an extra condition:

 - platform: sntp
    id: someid
    on_time:
      - seconds: 0
        minutes: 50
        hours: 7, 21
        days_of_week: '*'
        then:
          if:
            condition:
              and:
              - switch.is_off: relay2  
              - binary_sensor.is_off: binary_sensor.input_boolean_from_home_assistant
            then:    
            - switch.turn_on: relay2
            - delay: 10s
            - switch.turn_off: relay2