###################################
##  Sunrise and Sunset stuff
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
###################################

- alias: 'Stue start igen'
  trigger:
    platform: sun
    event: sunrise
  action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.first_run_stue


- alias: 'Sunset Stuff on'
  trigger:
    platform: state
#    entity_id: binary_sensor.stue_motion_sensor
    entity_id: binary_sensor.gang_sensor_motion
    to: 'on'
    
#    - platform: sun
#      event: sunset
#      offset: "-00:20:00"
  condition:
    - condition: time
      after: '15:00:00'
      before: '22:00:00'
    - condition: state
      entity_id: input_boolean.first_run_stue
      state: 'off'
    - condition: numeric_state
      entity_id: sensor.forgang_sensor_illuminance
      below: 50

  action:
#    - delay: '00:{{ (range(1, 20)|random|int) }}:00'
    - service: script.monthly_color_scene
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.first_run_stue
    - service: light.turn_on
      entity_id:
        - light.raket        
#        - light.syd
        - light.pendle1
        - light.pendle2
        - light.panton        
        
