Issue creating an automation from my own blueprint

Hey there!

I’m trying to create an automation from my own blueprint. It is neither working nor showing up in the UI. Any idea what I am doing wrong?

I am using packages. The automation is in a file inside packages folder. I have other automations inside packages there as well.

Thank you.
Matt

homeassistant:
  packages: !include_dir_named mesa/packages

# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

### Automations ###
automation ui-automation: !include automations.yaml

### Scripts ###
script ui-script: !include scripts.yaml

### Scenes ###
scene: !include scenes.yaml

### Groups ###
group: !include_dir_merge_named mesa/groups

### Input Booleans ###
input_boolean: !include mesa/inputs/input_booleans.yaml

## Input Numbers ###
input_number: !include mesa/inputs/input_numbers.yaml

## Input Datetimes ###
input_datetime: !include mesa/inputs/input_datetimes.yaml
blueprint:
  name: Mesa Motion-Activated Light
  description: Turn a light on based on detected motion, only if it's dark
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: This sensor will be synchronized with the light
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    target_light:
      name: Lights
      description: The lights to turn on
      selector:
        target:
          entity:
            domain: light
    illuminance_sensor:
      name: Illuminance Sensor
      description: The sensor to read the brightness from
      selector:
        entity:
          domain: sensor
          device_class: illuminance
    lux:
      name: Lux Floor
      description: The light will turn on only if the lux in the room is less than this value
      default: "{{ states('input_number.lights_on_below_lux') | int }}"
      selector:
        number:
          min: 1
          max: 1000
    brightness:
      name: Brightness
      description: The brightness to set the lights to
      default: "{{ states('input_number.dynamic_light_brightness') | int }}"
      selector:
        number:
          min: 1
          max: 100
    no_motion_wait:
      name: Wait time
      description: Time in minutes to leave the light on after last motion is detected
      default: 5
      selector:
        number:
          min: 5
          max: 120
          unit_of_measurement: minutes

variables:
  motion_sensor: !input motion_sensor
  target_light: !input target_light
  illuminance_sensor: !input illuminance_sensor
  lux: !input lux
  brightness: !input brightness
  no_motion_wait: !input no_motion_wait

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input motion_sensor
    from: "off"
    to: "on"
  - platform: numeric_state
    entity_id: !input illuminance_sensor
    below: !input lux

condition:
  - condition: numeric_state
    entity_id: !input illuminance_sensor
    below: !input lux

action:
  - service: light.turn_on
    target:
      entity_id: !input target_light
    data:
      brightness_pct: !input brightness
  - alias: "Wait until there is no motion from device"
    wait_for_trigger:
      - platform: state
        entity_id: !input motion_sensor
        from: "on"
        to: "off"
  - alias: "Wait the number of minutes that has been set"
    delay: !input no_motion_wait
  - alias: "Turn off the light"
    service: light.turn_off
    target: !input target_light

automation:
  - id: ethans_room_automatic_lighting
    alias: "[Lighting] Ethan's Room Automatic Lighting"
    use_blueprint:
      path: /config/blueprints/automation/mesa/mesa_motion_light.yaml
      input:
        motion_sensor: binary_sensor.ethans_room_motion
        target_light: light.ethans_room_main_lights
        illuminance_sensor: sensor.ethans_room_illuminance_sensor

Are you sure you can use templates for default values on your input selectors? Try change that to fix numbers and see if it works.

By the way, you have a trigger to turn on the light when the illuminance level goes below the input value… That will turn on the light even if no movement is happening or when movement stops after a while. Is this really what you want?

@EdwardTFN thank you kindly for your reply. I Just removed those default values and put integers, but it’s still not working. I appreciate you helping me out. You’re right about the blueprint. I’ll fix that.

I’ll keep poking around … really weird.

Matt

Ah. I just found out how to view live logs. (Sorry, relatively new to HA).

I see this. This looks like it has enough info for me to debug.

Thank you!

Blueprint Mesa Motion-Activated Light generated invalid automation with inputs OrderedDict([('motion_sensor', 'binary_sensor.ethans_room_motion'), ('target_light', 'light.ethans_room_main_lights'), ('illuminance_sensor', 'sensor.ethans_room_illuminance_sensor')]): expected a dictionary for dictionary value @ data['action'][3]['target']. Got None expected float for dictionary value @ data['condition'][0]['below']. Got None
Blueprint Mesa Motion-Activated Light generated invalid automation with inputs OrderedDict([('motion_sensor', 'binary_sensor.ethans_room_motion'), ('target_light', OrderedDict([('device_id', '1ba4a65e2bfdfdb11ddcf1feba7b7062')])), ('illuminance_sensor', 'sensor.ethans_room_illuminance_sensor'), ('lux', 10), ('brightness', 20)]): not a valid value for dictionary value @ data['action'][0]['target']['entity_id']. Got None
Blueprint Mesa Motion-Activated Light generated invalid automation with inputs OrderedDict([('motion_sensor', 'binary_sensor.ethans_room_motion'), ('illuminance_sensor', 'sensor.ethans_room_illuminance_sensor'), ('target_light', OrderedDict([('device_id', '1ba4a65e2bfdfdb11ddcf1feba7b7062')])), ('lux', 2), ('brightness', 50)]): not a valid value for dictionary value @ data['action'][0]['target']['entity_id']. Got None
Blueprint Mesa Motion-Activated Light generated invalid automation with inputs OrderedDict([('motion_sensor', 'binary_sensor.ethans_room_motion'), ('target_light', 'light.ethans_room_main_lights'), ('illuminance_sensor', 'sensor.ethans_room_illuminance_sensor')]): expected a dictionary for dictionary value @ data['action'][3]['target']. Got None

After much debugging…

turning this:

  - service: light.turn_off
    target: !input target_light

to this:

  - service: light.turn_off
    target:
      entity_id: !input target_light

Fixed my issue.

1 Like

@EdwardTFN

my idea was that if you are in the room and the sensor is constantly seeing motion, around sunset time, the lights would start as “OFF” given there was sufficient light. If the motion sensor constantly saw motion and the sun fell below the horizon, you’d want the lights to turn on.

Hence the “low lux” trigger.

I’ve added a condition here to restrict this to only fire when the motion sensor sees motion, but this means it doesn’t necessarily need to cross the boundary from no motion to motion.

Reading the docs for the numeric state trigger, it only fires when the below/above threshold is crossed so I shouldn’t have issues with the automation firing a lot.

Does this make sense? Anything you’d improve?

Thank you again.

Matt

blueprint:
  name: Mesa Motion-Activated Light
  description: Turn a light on based on detected motion, only if it's dark
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: This sensor will be synchronized with the light
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    target_light:
      name: Lights
      description: The lights to turn on
      selector:
        target:
          entity:
            domain: light
    illuminance_sensor:
      name: Illuminance Sensor
      description: The sensor to read the brightness from
      selector:
        entity:
          domain: sensor
          device_class: illuminance
    lux:
      name: Lux
      description: The light will turn on only if the lux in the room is less than this value
      default: 15
      selector:
        number:
          min: 1
          max: 1000
    brightness:
      name: Brightness
      description: The brightness to set the lights to
      default: 10
      selector:
        number:
          min: 1
          max: 100
    no_motion_wait:
      name: Wait time
      description: Time in minutes to leave the light on after last motion is detected
      default: 5
      selector:
        number:
          min: 5
          max: 120
          unit_of_measurement: minutes

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input motion_sensor
    from: "off"
    to: "on"
  - platform: numeric_state
    entity_id: !input illuminance_sensor
    below: !input lux

condition:
  - condition: numeric_state
    entity_id: !input illuminance_sensor
    below: !input lux
  - condition: state
    entity_id: !input motion_sensor
    state: "on"

action:
  - service: light.turn_on
    target:
      entity_id: !input target_light
    data:
      brightness_pct: !input brightness
  - wait_for_trigger:
      - platform: state
        entity_id: !input motion_sensor
        from: "on"
        to: "off"
  - delay: !input no_motion_wait
  - service: light.turn_off
    target:
      entity_id: !input target_light