Automation to continuously monitor

Hi I have tuya turn on some lights at sunset through a script.
while I am not home I want to turn off these lights so did following script.
It works but problem is if I leave home in the day and turn on the alarm it will trigger the script which lights are off anyways because it is the day.
Come around 5pm tuya will send a signal to turn on those lights. So now they will stay on. How can I have my automation script run every 10 minutes or so so it will turn off those lights if system is armed
Thanks

- alias: turn off candle lights when alarm set to armed
  trigger:
    platform: state
    entity_id: alarm_control_panel.my_house
    to: 'armed_away'
  action:
    service: homeassistant.turn_off
    entity_id:
      - switch.20808347bcddc2975aba #Candles kitchen light
      - switch.eb921a530e5b351815l4fj #Candles living room

Turn off whatever tuya automation you are using.

Thanks nickrout, but I want the lights to turn on at sunset everyday when I am home. So if I turn off tuya automation they will never go on at sunset.
I just want an automation to turn it off when I am not home by using alarm armed …

Well add an automation in home assistant to turn the lights on at sunset when the alarm is not set.

1 Like

that is a good idea
I have an automation to turn on those lights when I come back home after disarming alarm. Can I modify this script to also turn on after sunset if alarm is disarmed? Or add another one like second below

- alias: turn on candle lights when alarm disarmed
  trigger:
  - platform: state
    entity_id: alarm_control_panel.my_house
    from: armed_away
    to: disarmed
  condition:
  - condition: state
    entity_id: sun.sun
    state: 'below_horizon'
  action:
    service: homeassistant.turn_on
    entity_id:
      - switch.20808347bcddc2975aba #Candles kitchen light
      - switch.eb921a530e5b351815l4fj #Candles living room
- alias: turn on candle lights at sunset if alarm is disarmed
  trigger:
  - platform: state
    entity_id: alarm_control_panel.my_house
   state: disarmed
  condition:
  - condition: state
    entity_id: sun.sun
    state: 'below_horizon'
  action:
    service: homeassistant.turn_on
    entity_id:
      - switch.20808347bcddc2975aba #Candles kitchen light
      - switch.eb921a530e5b351815l4fj #Candles living room