#####################################################################################
###  If the Kitchen Lights go on for more than 10 minutes, turn off the accent lights
### connected to [Etekcity Outlets](https://amzn.to/2efNoBP)
## [433Mhz Transmitter and receiver](https://amzn.to/2dceNY2)
#####################################################################################

- alias: Kitchen lights on - Accent lights off
  id: 3810e522-be2c-45b5-9b9c-9f8639653cf2
  trigger:
    - platform: state
      entity_id: light.kitchen_lights
      to: 'on'
      for: '00:05:00'

  condition:
    - condition: state
      entity_id: group.kitchen_Accents
      state: 'on'

  action:
    - service: switch.turn_off
      entity_id: group.kitchen_Accents

##############################################################################

- alias: Kitchen lights off - turn on Accent lights
  id: b2b089ca-588a-48d0-8688-57bf144cac85
  trigger:
    - platform: state
      entity_id: light.kitchen_lights
      to: 'off'
      for: '00:05:00'
    - platform: state
      entity_id: sun.sun
      to: 'below_horizon'
      from: 'above_horizon'

  condition:
    - condition: sun
      after: 'sunset'
    - condition: state
      entity_id: light.kitchen_lights
      state: 'off'
    - condition: or
      conditions:
        - condition: state
          entity_id: binary_sensor.sleepnumber_carlo_carlo_is_in_bed
          state: 'off'
        - condition: state
          entity_id: person.carlo
          state: 'not_home'
    - condition: or
      conditions:
        - condition: state
          entity_id: binary_sensor.sleepnumber_carlo_stacey_is_in_bed
          state: 'off'
        - condition: state
          entity_id: person.stacey
          state: 'not_home'
    - condition: or
      conditions:
        - condition: state
          entity_id: group.family
          state: 'home'
        - condition: state
          entity_id: input_boolean.guest_mode
          state: 'on'

  action:
    - service: switch.turn_on
      entity_id: group.kitchen_Accents