Hi,
I created a blueprint (my first one), but I have an issue when an entity (that should be optional) is not set.
Basically, the Blueprint has 2 inputs: Lights and Switches.
If one of the 2 is not configured, then the automation fails with the following error: “Error executing script. Invalid data for call_service at pos 2: must contain at least one of entity_id, device_id, area_id.”
Can someone help, please?
This is the code:
blueprint:
name: Motion off - Lights off - Switches off (Based on Alarm Status)
description: Turn lights and switches off if there is no motion for x minutes when the Alarm has a specific status
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: This sensor will be synchronized with the lights and the switches.
selector:
entity:
domain: binary_sensor
device_class: motion
alarm:
name: Alarm Control Panel
description: Select a Alarm Control Panel
selector:
entity:
domain: alarm_control_panel
disarmed:
name: When the alarm is disarmed
default: true
selector:
boolean: {}
armed_away:
name: When the alarm is armed "Away"
default: true
selector:
boolean: {}
armed_home:
name: When the alarm is armed "Home"
default: true
selector:
boolean: {}
armed_night:
name: When the alarm is armed "Night"
default: true
selector:
boolean: {}
armed_custom_bypass:
name: When the alarm is armed "Custom Bypass"
default: false
selector:
boolean: {}
target_light:
name: Lights
description: The lights to keep in sync.
default: {}
selector:
target:
entity:
domain: light
target_switch:
name: Switches
description: The switches to keep in sync.
default: {}
selector:
target:
entity:
domain: switch
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 5
selector:
number:
min: 0
max: 60
unit_of_measurement: minutes
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_sensor
to: 'off'
for:
hours: 0
minutes: !input no_motion_wait
seconds: 0
milliseconds: 0
variables:
on_disarmed: !input 'disarmed'
on_armed_away: !input 'armed_away'
on_armed_custom_bypass: !input 'armed_custom_bypass'
on_armed_home: !input 'armed_home'
on_armed_night: !input 'armed_night'
condition:
- condition: or
conditions:
- condition: and
conditions:
- '{{ on_disarmed }}'
- condition: state
entity_id: !input 'alarm'
state: disarmed
- condition: and
conditions:
- '{{ on_armed_away }}'
- condition: state
entity_id: !input 'alarm'
state: armed_away
- condition: and
conditions:
- '{{ on_armed_custom_bypass }}'
- condition: state
entity_id: !input 'alarm'
state: armed_custom_bypass
- condition: and
conditions:
- '{{ on_armed_home }}'
- condition: state
entity_id: !input 'alarm'
state: armed_home
- condition: and
conditions:
- '{{ on_armed_night }}'
- condition: state
entity_id: !input 'alarm'
state: armed_night
action:
- service: light.turn_off
target: !input target_light
- service: switch.turn_off
target: !input target_switch