######################################################################
##  Dark House Little extra light - DARK and Cloudy or just rainy.
######################################################################

- alias: 'Dark House Little extra light'
  trigger:
    - platform: numeric_state
      entity_id: sun.sun
      value_template: '{{ state.attributes.elevation }}'
      below: 20.0
    - platform: numeric_state
      entity_id: sensor.dark_sky_cloud_coverage
      above: 90
    - platform: numeric_state
      entity_id: sensor.dark_sky_precip_intensity
      above: 1
    - platform: state
      entity_id: group.family
      to: 'home'
      from: 'not_home'

  condition:
    condition: and
    conditions:
      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sun.sun
                value_template: '{{ state.attributes.elevation }}'
                below: 20.0
              - condition: numeric_state
                entity_id: sensor.dark_sky_cloud_coverage
                above: 90
          - condition: numeric_state
            entity_id: sensor.dark_sky_precip_intensity
            above: 1
      - condition: state
        entity_id: binary_sensor.sleepnumber_carlo_carlo_is_in_bed
        state: 'off'
      - condition: state
        entity_id: binary_sensor.sleepnumber_carlo_stacey_is_in_bed
        state: 'off'
      - condition: state
        entity_id: sun.sun
        state: 'above_horizon'
      - condition: state
        entity_id: group.family
        state: 'home'

  action:
    - service: light.turn_on
      entity_id:
        - light.couch_1
        - light.sink
    - service: input_boolean.turn_on
      entity_id:
        - input_boolean.daylight_override
    - service: script.speech_engine
      data_template:
        value1: "It is getting a little dark inside the house because of the {{trigger.entity_id.split('_')[2]|replace('precip','rain') }} {{trigger.entity_id.split('_')[3]|replace('intensity',' ')}} outside.  I will turn on some extra lights in the living room."
        call_window_check: 1
        call_garage_check: 1

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