If/Then is an action… you need a sequence key to to start the action sequence and you need to use the correct selectors… target and entity are not directly interchangeable.
blueprint:
name: Update Status
description: Change a light color subject to A) lockout, then B) sensor state
domain: script
input:
the_lockout:
name: Lockout
description: The light will change only if this input is state OFF
selector:
entity:
filter:
- domain: input_boolean
the_sensor:
name: Input Sensor
selector:
entity:
filter:
- domain: sensor
the_light:
name: Status Light
description: The light to be changed
selector:
target:
entity:
- domain: light
the_oncolor:
name: On Color
default:
- 0
- 255
- 0
selector:
color_rgb: {}
the_offcolor:
name: Off Color
default:
- 255
- 0
- 0
selector:
color_rgb: {}
sequence:
- condition: state
entity_id: !input the_lockout
state: "off"
- if:
- condition: state
entity_id: !input the_sensor
state: "on"
then:
- action: light.turn_on
metadata: {}
data: !input the_oncolor
target: !input the_light
else:
- action: light.turn_on
metadata: {}
data: !input the_offcolor
target: !input the_light
Yes I fixed the target/entity issue after finding a post about it previously. Where I’m at now:
blueprint:
name: update_status
description: Change a light color subject to A) lockout, then B) sensor state
domain: script
input:
the_lockout:
name: Lockout
description: The light will change only if this input is state OFF
selector:
entity:
filter:
domain: input_boolean
the_sensor:
name: Input Sensor
selector:
entity:
filter:
domain: sensor
the_light:
name: Status Light
description: The light to be changed
selector:
target:
entity:
domain: light
the_oncolor:
name: On Color
default: [0,255,0]
selector:
color_rgb:
the_offcolor:
name: Off Color
default: [255,0,0]
selector:
color_rgb:
sequence:
- if:
- condition: state
entity_id: !input the_lockout
state: "off"
then:
- if:
- condition: state
entity_id: !input the_sensor
state: "on"
then:
- action: light.turn_on
data:
rgb_color: !input the_oncolor
target:
entity_id: !input the_light
else:
- action: light.turn_on
data:
rgb_color: !input the_offcolor
target:
entity_id: !input the_light
Throwing an error about the color data (I believe):
“Message malformed: not a valid value for dictionary value @ data[‘sequence’][0][‘then’][0][‘then’][0][‘target’][‘entity_id’]”
Thanks greatly for the help. I’m trying to cast as a list:
blueprint:
name: update_status
description: Change a light color subject to A) lockout, then B) sensor state
domain: script
input:
the_lockout:
name: Lockout
description: The light will change only if this input is state OFF
selector:
entity:
filter:
domain: input_boolean
the_sensor:
name: Input Sensor
selector:
entity:
filter:
domain: sensor
the_light:
name: Status Light
description: The light to be changed
selector:
target:
entity:
domain: light
the_oncolor:
name: On Color
default: [0,255,0]
selector:
color_rgb:
the_offcolor:
name: Off Color
default: [255,0,0]
selector:
color_rgb:
variables:
oncolorgrab: !input the_oncolor
offcolorgrab: !input the_offcolor
sequence:
- if:
- condition: state
entity_id: !input the_lockout
state: "off"
then:
- if:
- condition: state
entity_id: !input the_sensor
state: "on"
then:
- action: light.turn_on
data:
rgb_color:
- '{{ oncolorgrab.split(",")[0][1:] | int }}'
- '{{ oncolorgrab.split(",")[1] | int }}'
- '{{ oncolorgrab.split(",")[2][:-1] | int }}'
target:
entity_id: !input the_light
else:
- action: light.turn_on
data:
rgb_color:
- '{{ offcolorgrab.split(",")[0][1:] | int }}'
- '{{ offcolorgrab.split(",")[1] | int }}'
- '{{ offcolorgrab.split(",")[2][:-1] | int }}'
target:
entity_id: !input the_light
And getting a similar error: “Message malformed: not a valid value for dictionary value @ data[‘sequence’][0][‘then’][0][‘then’][0][‘target’][‘entity_id’]”
I’ve tried remaking this as an automation, and using color names instead - I’m still running into an error I don’t undersand:
blueprint:
name: update_status_automation
description: Change a light color subject to A) lockout, then B) sensor state
domain: automation
input:
the_lockout:
name: Lockout
description: The light will change only if this input is state OFF
selector:
entity:
filter:
domain: input_boolean
the_sensor:
name: Input Sensor
selector:
entity:
filter:
domain: sensor
the_light:
name: Status Light
description: The light to be changed
selector:
target:
entity:
domain: light
the_oncolor:
name: On Color
default: green
selector:
select:
options:
- yellow
- red
- green
- blue
- orange
- purple
the_offcolor:
name: Off Color
default: yellow
selector:
select:
options:
- yellow
- red
- green
- blue
- orange
- purple
triggers:
- trigger: state
entity_id: !input the_sensor
conditions:
- condition: state
entity_id: !input the_lockout
state: "off"
actions:
- if:
- condition: state
entity_id: !input the_sensor
state: "on"
then:
- action: light.turn_on
metadata: {}
data:
color_name: !input the_oncolor
target:
entity_id: !input the_light
else:
- action: light.turn_on
metadata: {}
data:
color_name: !input the_offcolor
target:
entity_id: !input the_light
Message malformed: not a valid value for dictionary value @ data[‘actions’][0][‘then’][0][‘target’][‘entity_id’]
Is it something in the way I’m selecting the target entity for the light?