Motion activates scenes DAY and NIGHT with illumination, time and sun possition

Hi
I wanted to share my first blueprint which works for me (so far) almost perfectly as intended.
It is based on @networkingcat blueprint, but simplified and adjusted to my day/night behavior and needs.

IMPORT BP:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

There are many variants of motion activate lights which required light entity and was either fully dependent on hour or sun position. I wanted to have it more like this:

  1. Day scene is active from sun azimuth (close to sunrise) till specific hour (when we go sleep).
  2. Night scene is active from specific hour to sun azimuth .
  3. Ambient scene is active from sun azimuth in evening till some hour.
  4. Day/Night scene is active only when light sensor have low LUX value (I’m checking outside light so when it’s cloudy then it makes sense to use scene).
    You will need only light sensor and some scenes.
blueprint:
  name: YAMA Falo Scenes v2
  description: >
    # YAMA Falo Scenes

    Turn on scenes when motion is detected. 

    Separate scene for day and night

    Assumptions:
    1. Day scene is active from sun azimuth (close to sunrise) till specific hour (when we go sleep).
    2. Night scene is active from specific hour to sun azimuth .
    3. Ambient scene is active from sun azimuth in evening till some hour.
    4. Day/Night scene is active only when light sensor have low LUX value (I'm checking outside light so when it's cloudy then it makes sense to use scene).

  domain: automation
  input:
    motion_entity:
      name: Motion Sensor
      description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off")
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    illuminance_sensor:
      name: (OPTIONAL) Illuminance sensor
      description: This sensor will be used to determine the illumination.
      default:
      selector:
        entity:
          domain: sensor
          device_class: illuminance
    illuminance_cutoff:
      name: (OPTIONAL) Illuminance cutoff value
      description: This input_number will be used to compare to the current illumination to determine if it is low.
      default:
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: lux
    no_motion_wait:
      name: Wait time
      description: Time to leave the light on after last motion is detected.
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    scene_day:
      name: DAY Scene (Optional)
      default: scene.none
      selector:
        entity:
          domain: scene
    scene_night:
      name: NIGHT Scene (Optional)
      default: scene.none
      selector:
        entity:
          domain: scene
    time_scene_night_start:
      name: NIGHT Scene start - time (Optional)
      description: A time input which defines the time from which on the scene will be activated if motion is detectedd.
      default: "22:00:00"
      selector:
        time:
    sun_scene_night_end:
      name: NIGHT Scene end - sun possition (Optional)
      description: Night scene will go off after sun is higher than
      default: none
      selector:
        number:
          min: -90
          max: 90
          unit_of_measurement: degrees
    scene_ambient:
      name: AMBIENT Scene (Optional)
      description: Scene for ambient state. Will be activated when no motion is detected.
      default: scene.none
      selector:
        entity:
          domain: scene
    sun_scene_ambient_start:
      name: AMBIENT scene start - sun (Optional)
      description: Time from which on ambient scene will be activated
      default: none
      selector:
        number:
          min: -90
          max: 90
          unit_of_measurement: degrees
    time_scene_ambient_end:
      name: AMBIENT scene end - sun (Optional)
      description: Time from which on ambient scene will be not activated
      default: "23:30:00"
      selector:
        time:
    scene_dark:
      name: DARK Scene (Optional)
      description: Scene for DARK STATE state. Will be activated when no motion is detected.
      default: scene.none
      selector:
        entity:
          domain: scene

    time_day_change:
      name: Time when "day" is over
      description: This is only needed for conditions to work correctly
      default: "03:00:00"
      selector:
        time:
mode: restart
max_exceeded: silent

variables:

  scene_ambient_start: !input sun_scene_ambient_start
  scene_night_end: !input sun_scene_night_end


trigger:
  - platform: state
    entity_id: !input motion_entity
    from: "off"
    to: "on"
  - platform: state
    entity_id: !input motion_entity
    from: "on"
    to: "off"
    for: !input no_motion_wait

# All Conditions must be true
#condition:
#No special conditions in this blueprint

action:
  - choose:
      # Trigger to state == "on"
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state == 'on' }}"
          - condition: numeric_state
            entity_id: !input "illuminance_sensor"
            below: !input "illuminance_cutoff"
        sequence:
          - choose:
              # day Scene
              - conditions:
                  - "{{ scene_day != 'scene.none'}}"
                  - condition: time
                    after: !input time_day_change
                    before: !input time_scene_night_start
                sequence:
                  - scene: !input scene_day
              # Night Scene
              - conditions:
                  - "{{ scene_night != 'scene.none'}}"
                  - condition: time
                    after: !input time_scene_night_start
                    before: !input time_day_change
                  - condition: template
                    value_template: "{{ (state_attr('sun.sun','elevation') < scene_night_end) }}"
                sequence:
                  - scene: !input scene_night
      # Trigger to state = "off"
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state == 'off' }}"
        sequence:
          - choose:
              # Used if ambient scene is true and in ambient scene time frame
              - conditions:
                  - "{{ scene_ambient != 'scene.none' }}"
                  - condition: time
                    after: !input time_day_change
                    before: !input time_scene_ambient_end
                  - condition: template
                    value_template: "{{ (sun_scene_ambient_start == none) or (state_attr('sun.sun','elevation') <= scene_ambient_start) }}"
                sequence:
                  - scene: !input scene_ambient
            default:
              - scene: !input scene_dark
1 Like

hi! after enter all params I’ve get error
Message malformed: Entity IDs cannot be None for dictionary value @ data[‘action’][0][‘choose’][0][‘conditions’][1][‘entity_id’]