Help Blueprints are driving me mad! - extra keys not allowed [in condition] Got None required key not provided [entity id]. Got None

Hey Folks,

I’m trying to write my first Blueprint to make it easier to roll out soft shutdown on my metered smart sockets.
I’m being plagued with this error:

extra keys not allowed @ data['condition'][1]['target']. Got None required key not provided @ data['condition'][1]['entity_id']. Got None

Here is the code of my Blueprint:

blueprint:
  name: Auto Power-Off Smart Socket
  domain: automation
  input:
    start_time:
      name: "Start Time"
      description: "The time from which you would like the switch to be automatically turned off."
      selector:
        time:
    end_time:
      selector:
        time:
    power_sensor:
      selector:
        target:
          entity:
            domain: sensor
            device_class: power
    power_switch:
      selector:
        target:
          entity:
            domain: switch

trigger:
  - platform: numeric_state
    entity_id: !input power_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 5
  - platform: time
    at: !input start_time
condition:
  - condition: time
    before: !input end_time
    after: !input start_time
  - condition: numeric_state
    target: !input power_sensor
    below: 5
action:
  - service: switch.turn_off
    target: !input power_switch

And here is the code of my Automation:

alias: Auto Power-Off Smart Socket
description: ""
use_blueprint:
  path: auto_poweroff_smart_sock.yaml
  input:
    end_time: "00:00:00"
    start_time: "06:00:00"
    power_sensor:
      entity_id: sensor.attic_entertainment_power
    power_switch:
      entity_id: switch.attic_entertainment

I found a solution! Removing the target: part of my power_sensor and power_switch input declarations.
Credit to this suggestion on a similar post.

I’ll test some more and then post my finished blueprint.

I believe more is involved than merely “removing” target. The example you posted doesn’t use a State Condition and service call correctly (i.e. contains syntax errors). entity_id is the correct option name.

condition:
  - condition: time
    before: !input end_time
    after: !input start_time
  - condition: numeric_state
    entity_id: !input power_sensor  # <--- entity_id not target 
    below: 5
action:
  - service: switch.turn_off
    entity_id: !input power_switch  # <--- entity_id not target

Alternative:

action:
  - service: switch.turn_off
    target:
      entity_id: !input power_switch 
1 Like

Here is my “finished” blueprint. It’s still a bit rough and ready but it it works.
Ideally it would take the timeout and power shutdown threshold as inputs and turn the socket back on at it’s end time.

blueprint:
  name: Auto Power-Off Smart Socket
  domain: automation
  input:
    start_time:
      name: "Start Time"
      description: "The time from which you would like the switch to be automatically turned off."
      selector:
        time:
    end_time:
      name: "End Time"
      description: "The time to stop auto shutdown of the switch. Maybe when you plan to turn it on with another automation."
      selector:
        time:
    power_sensor:
      name: "Power Sensor"
      description: "The power sensor for your energy monitoring smart socket."
      selector:
        entity:
          domain: sensor
          device_class: power
    power_switch:
      name: "Power Switch"
      description: "The switch control for your energy monitoring smart socket."
      selector:
        entity:
          domain: switch

trigger:
  - platform: numeric_state
    entity_id: !input "power_sensor"
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 5
  - platform: time
    at: !input "start_time"

condition:
  - condition: and
    conditions:
    - condition: time
      before: !input "end_time"
      after: !input "start_time"
    - condition: numeric_state
      entity_id: !input "power_sensor"
      below: 5

action:
  - service: switch.turn_off
    entity_id: !input "power_switch"
mode: single

Ah so that’s how you make the targets actually work!