So I tried just pasting the entity name into the brightness value and it’s telling me Expected float for dictionary value @ Brightness pct or something. I’m guessing brightness percentage. It’s set to 5 right now. I’m not sure how to do this…
Show what you are trying to do.
Ok, so basically I have an automation to turn on. A light upon there being motion. I want the light to be set to the percentage that is indicated on a variable. The variable input_number.chinchilla_brightness. I entered that onto the field for brightness percentage but it gave me an error. I’m not sure how I would format it for it to be a string. I think that’s what it needs. Idek
alias: main room motion on chinchilla protocol on
description: ''
trigger:
- type: motion
platform: device
device_id: 088ef7eb1297d9f4ea7bdff13ef790e0
entity_id: binary_sensor.main_room_motion_tv_motion
domain: binary_sensor
- type: motion
platform: device
device_id: e744730e617ccdd8d5496280ac03e549
entity_id: binary_sensor.main_room_motion_window_motion
domain: binary_sensor
condition:
- condition: state
entity_id: input_boolean.mainroomautolighting
state: 'on'
- condition: state
entity_id: input_boolean.chinchilla_protocol
state: 'on'
action:
- type: turn_on
device_id: 80d0915e90feec6e507e5b15c55b7e01
entity_id: light.main_room_4
domain: light
brightness_pct: 15
- type: turn_on
device_id: 49e944ad78cd62f7579c25ad037686cc
entity_id: light.main_room_1
domain: light
brightness_pct: 15
- type: turn_on
device_id: ba7a31d5ba14c2e27bd0c4bf958d2bf0
entity_id: light.main_room_2
domain: light
brightness_pct: 15
- type: turn_on
device_id: 168687d9ae72e3f8df92ebb60aa8553e
entity_id: light.main_room_light_3
domain: light
brightness_pct: 15
mode: single
I tried changing the “15” on one of them to input_number.chinchilla_brightness via the web GUI (not directly with yaml code) and it gave me an error. I just tried by replacing the brightness percentage with it via yaml, gave me this
Message malformed: expected float for dictionary value @ data['brightness_pct']
type: turn_on
device_id: 80d0915e90feec6e507e5b15c55b7e01
entity_id: light.main_room_4
domain: light
brightness_pct: {{states('input_number.chinchilla_brightness')|float}}
Tried that too. With and without the {{}} bit. Not sure how I’m supposed to format it.
I’m pretty sure you cant use templates with device actions. You will have to use a service call like this:
action:
- service: light.turn_on
target:
entity_id: light.main_room_4
data:
brightness_pct: "{{ states('input_number.chinchilla_brightness')|int }}"
Because you are using brightness_pct
your input number must be limited to the range 0 to 100. Make sure you have set this correctly in your input_number configuration.
Ya I figured that much and I left it limited from 1-100, Jw, is there a reason it had to be an integer instead of a float? Can it not use a decimal? Not that i need that, just wondering if it causes a problem.
brightness_pct
has to be an integer between 0 and 100.
https://www.home-assistant.io/integrations/light/#service-lightturn_on
Put this in the Developer Tools Template Editor and compare the results:
With int filter: {{ states('input_number.chinchilla_brightness')|int }}
Without: {{ states('input_number.chinchilla_brightness') }}
Oh ya, I see. Even if it’s 5, it comes up as 5.0, I’m guessing that would trip it up. Didn’t know I could just test stuff like that. Hot damn. Seems like a time saver for sure.
Correct.
Yes it is a very handy tool. So are the other ones in the Developer Tools:
- You can look up the actual state of entities or attributes on the States page.
- You can call any service from the Services page.
- You can fire or monitor events on the Events Page.
Can I use events to see everything that’s happening as it’s happening and what happened in the past?
“Like my light turned on for no reason, let’s see why”