Motion+lux+time Blueprint doens't work

Hi,

This blueprint: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6 have what I want, but I don’t want scenes but change brigthness.
Im new to home assistant and yaml but I tried to make it:

blueprint:
  name: Motion-activated light scene with surrounding light level check and optional ambient scene
  description: Turn on a light scene when motion is detected. Three different scenes can be defined depending on time of day. Furthermore a source for checking sourrounding light can be defined to enable light only if it is dark enough.
  domain: automation
  source_url: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6
  input:
    motion_entity:
      name: Motion Sensor
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    lightsensor_entity:
      name: Illuminance Sensor
      selector:
        entity:
          domain: sensor
          device_class: illuminance
    illuminace_level:
      name: Max Illuminance
      description: Maximal immuminance level in lux. If illuminance is higher, light will not be enabled
      default: 600
      selector:
        number:
          min: 0
          max: 5000
          unit_of_measurement: lux
    light_target:
      name: Light
      selector:
        target:
          entity:
            domain: light
    scene_ambient:
      name: Ambient Scene (Optional)
      description: Scene for ambient state. Will be activated when no motion is detected and light level is under threshold. Default value = scene.none
      default: 2
      selector:
       number:
          min: 1.0
          max: 100.0
          step: 1.0
          mode: slider
    time_scene_ambient_start:
      name: Ambient time frame start
      description: Time from which on ambient scene will be activated
      default: "00:00:00"
      selector:
        time:
    time_scene_ambient_end:
      name: Ambient time frame end
      description: Time from which on ambient scene will be not activated
      default: "00:00:00"
      selector:
        time:
    scene_morning:
      name: Scene for the morning
      default: 100
      selector:
       number:
          min: 1.0
          max: 100.0
          step: 1.0
          mode: slider
    time_scene_morning:
      name: Time for the morning scene
      description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
      default: "00:00:00"
      selector:
        time:
    scene_day:
      name: Scene for the bright day
      default: 80
      selector:
       number:
          min: 1.0
          max: 100.0
          step: 1.0
          mode: slider
    time_scene_day:
      name: Time for the day scene
      description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
      default: "00:00:00"
      selector:
        time:
    scene_evening:
      name: Scene for the evening
      default: 50
      selector:
       number:
          min: 1.0
          max: 100.0
          step: 1.0
          mode: slider
    time_scene_evening:
      name: Time for the evening scene
      description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
      default: "00:00:00"
      selector:
        time:
    scene_night:
      name: Scene for the dark night
      default: 1
      selector:
       number:
          min: 1.0
          max: 100.0
          step: 1.0
          mode: slider
    time_scene_night:
      name: Time for the night scene
      description: A time input which defines the time from which on the scene will be activated if motion is detectedd. Default value = scene.none
      default: "00:00:00"
      selector:
        time:
    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

mode: restart
max_exceeded: silent

variables:
  scene_ambient: !input scene_ambient
trigger:
  platform: state
  entity_id: !input motion_entity
  from: "off"
  to: "on"
## condition for illumination has to be checked for every scece and not global. reason: action should be also triggered if no lights should be enabled to switch off ambient scene if it is to bright
action:
  - choose:
      - conditions:
          - condition: time
            after: !input time_scene_morning
            before: !input time_scene_day
          - condition: numeric_state
            entity_id: !input lightsensor_entity
            below: !input illuminace_level
        sequence:
          - alias: "lights on"
            service: light.turn_on
            target:
              entity_id: !input light_target
            data:
              brightness: !input scene_morning
      - conditions:
          - condition: time
            after: !input time_scene_day
            before: !input time_scene_evening
          - condition: numeric_state
            entity_id: !input lightsensor_entity
            below: !input illuminace_level
        sequence:
          - alias: "lights on"
            service: light.turn_on
            target:
              entity_id: !input light_target
            data:
              brightness: !input scene_day
      - conditions:
          - condition: time
            after: !input time_scene_evening
            before: !input time_scene_night
          - condition: numeric_state
            entity_id: !input lightsensor_entity
            below: !input illuminace_level
        sequence:
          - alias: "lights on"
            service: light.turn_on
            target:
              entity_id: !input light_target
            data:
              brightness: !input scene_evening
      - conditions:
          - condition: time
            after: !input time_scene_night
            before: !input time_scene_morning
          - condition: numeric_state
            entity_id: !input lightsensor_entity
            below: !input illuminace_level
        sequence:
          - alias: "lights on"
            service: light.turn_on
            target:
              entity_id: !input light_target
            data:
              brightness: !input scene_night
  - wait_for_trigger:
      platform: state
      entity_id: !input motion_entity
      from: "on"
      to: "off"
  - delay: !input no_motion_wait
  - choose:
      - conditions:
          - "{{ scene_ambient != 'scene.none'}}"
          - condition: time
            after: !input time_scene_ambient_start
            before: !input time_scene_ambient_end
          - condition: numeric_state
            entity_id: !input lightsensor_entity
            below: !input illuminace_level
        sequence:
          - alias: "lights on"
            service: light.turn_on
            target:
              entity_id: !input light_target
            data:
              brightness: !input scene_ambient
    default:
      - service: light.turn_off
        target: !input light_target

It doens’t work i get this ERROR:

2021-08-28 14:11:06 ERROR (MainThread) [homeassistant.components.automation] Blueprint Motion-activated light scene with surrounding light level check and optional ambient scene generated invalid automation with inputs OrderedDict([('motion_entity', 'binary_sensor.badkamer_beweging'), ('lightsensor_entity', 'sensor.badkamer_lx'), ('light_target', OrderedDict([('device_id', '297b0313ce1a9a5bbebfc918bc963a35')])), ('scene_morning', 85), ('scene_evening', 54), ('scene_day', 90), ('illuminace_level', 324), ('time_scene_morning', '10:00:00'), ('time_scene_day', '12:00:00'), ('time_scene_evening', '13:00:00'), ('time_scene_night', '14:00:00')]): not a valid value for dictionary value @ data['action'][0]['choose'][0]['sequence'][0]['target']['entity_id']. Got None

What do I wrong?

Can you tell us what you are trying to achieve? Maybe if your scenario is not too complex, it can be achieved by just using regular automation.

Based on your error, you have-

  1. binary_sensor.badkamer_beweging
  2. sensor.badkamer_lx
  3. light entity_id? Can you provide this?

My idea is light(s) go on when motion and lux is < Max Illuminance set different brigthness based on time.
Like:
motion detected > lux is lower then 200 > time is between 23:00 and 7:00 > light on and set brigthness 30
motion detected > lux is lower then 200 > time is between 7:00 and 10:00 > light on and set brigthness 50
motion detected > lux is lower then 200 > time is between 10:00 and 23:00 > light on and set brigthness 100
Yes I can make it with regular automation but I want for many sensors the same result so I want to make blueprint to make is easyer.

You can make advantage of choose action where you can add options and specify condition-

trigger:
  - platform: state
    entity_id: binary_sensor.badkamer_beweging
    to: 'on'
condition:
  - condition: numeric_state
    entity_id: sensor.badkamer_lx
    below: '200'
action:
  - choose:
      - conditions:
          - condition: time
            after: '23:00:00'
          - condition: time
            before: '07:00:00'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.your_light
      - conditions:
          - condition: time
            before: '10:00:00'
            after: '07:00:00'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.your_light
    default: []

choose action is used in this blueprint already

Looks like it works now