I have an automation that runs my front porch lights. At around sunset, the lights come on at 15%, and turn off at sunrise. If the switch inside is turned on, or motion is detected, the lights go to 100%.
The ‘15%’ value I would like to change to an input_number so I can make it variable, and adjustable from an admin page on the dashboard. (ie it’s halloween, i’ve put in the orange bulbs and I just want it to stay at minimum 50% all night)
Here’s the full automation:
alias: Front Porch Motion Lighting
description: >-
Automatically turns on the front porch lights between sunset/sunrise and
toggles full bright for motion or light switch
trigger:
- platform: sun
event: sunrise
offset: '+00:30:00'
id: sunrise
- platform: sun
event: sunset
offset: '-00:30:00'
- platform: state
entity_id: binary_sensor.motion_front_porch
- platform: state
entity_id: binary_sensor.motion_front_door
- platform: state
entity_id: switch.shellydimmer_frontporch_sw1
condition:
- condition: or
conditions:
- condition: sun
before: sunrise
before_offset: '+00:30:01'
- condition: sun
after: sunset
after_offset: '-00:30:00'
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.motion_front_door
state: 'on'
- condition: state
entity_id: binary_sensor.motion_front_porch
state: 'on'
- condition: state
entity_id: switch.shellydimmer_frontporch_sw1
state: 'on'
sequence:
- type: turn_on
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
brightness_pct: 100
- conditions:
- condition: trigger
id: sunrise
- condition: state
entity_id: switch.shellydimmer_frontporch_sw1
state: 'off'
sequence:
- type: turn_off
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.motion_front_door
state: 'off'
- condition: state
entity_id: binary_sensor.motion_front_porch
state: 'off'
- condition: state
entity_id: switch.shellydimmer_frontporch_sw1
state: 'off'
sequence:
- type: turn_on
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
brightness_pct: 15
default:
- type: turn_off
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
mode: single
Here’s the part I want to change:
sequence:
- type: turn_on
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
brightness_pct: 15
To
sequence:
- type: turn_on
device_id: 55f8402b5324074cdcf2cb13f9aa2b45
entity_id: light.shellydimmer_frontporch
domain: light
brightness_pct: {{ states('input_number.brightness_night_front_porch') }}
Trying to save with that change results in a “Message malformed: expected float for dictionary value @ data[‘brightness_pct’]”
I have tried the following, with no change in error.
brightness_pct: {{ states('input_number.brightness_night_front_porch') | Float }}
brightness_pct: {{ states('input_number.brightness_night_front_porch') | Int }}
brightness_pct: {{ (states('input_number.brightness_night_front_porch') | Float ) }}
brightness_pct: {{ states.input_number.brightness_night_front_porch.state }}
brightness_pct: {{ states.input_number.brightness_night_front_porch.state |int }}
brightness_pct: {{ states.input_number.brightness_night_front_porch.state |float }}
What am I missing?
Edit: I did check using the template tab on the Developer’s Tools, and it returns a “50.0” which is what the entity is currently set to, along with the following attributes
initial: null
editable: true
min: 0
max: 100
step: 1
mode: slider
unit_of_measurement: '%'
friendly_name: Brightness_Night_Front_Porch
icon: mdi:lightbulb-outline