Thanks to the suggestion of fetdot I successfully implemented the option to set the time & date for my alarm clock (see using a variable in an automation) using a Helper.
It also works to set a condition for the lightlevel Helper (input_number.livingroom_lightlevel) when the automation is trigger by a movement sensor.
It looks like this:
alias: Living Room - Light On
description: ''
trigger:
- platform: state
entity_id: binary_sensor.presence_9
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.lightlevel_12
below: input_number.livingroom_lightlevel_12
action:
- scene: scene.livingroom_light_on
mode: single
So far so good, but if I now want to switch off the lights, I get a message 'Message malformed: expected float for dictionary value @ data['above'] if I create a similar trigger that turns the light off when either nobody is in the room anymore or it becomes light enough at sunrise for example:
alias: Living Room - Light Off
description: ''
trigger:
- platform: state
entity_id: binary_sensor.presence_9
from: 'on'
to: 'off'
for: '00:10:00'
- platform: numeric_state
entity_id: sensor.lightlevel_12
above: input_number.livingroom_lightlevel | float
condition: []
action:
- scene: scene.livingroom_light_off
mode: single
but here my knowledge of HA falls short. I do however have a strong feeling that there is some inconsistency here how things are implemented. At least I don’t see why it works for a Condition and not for a Trigger What would be the appropriate way to create this automation. It of course can be hard coded, but I prefer to allow my housemates to be able to set it at an appropriate light level.
I first tried without the float conversion and in that case got the error message 'Message malformed: expected float for dictionary value @ data['above'] (forgot to mention that sorry)
No, don’t use a numeric_state trigger, use a template trigger. Yeah, missed the second entity.
Also try avoiding using state.domain.entity, instead use states('domain.entity'), this avoids errors when unavailable.
Complete automation should look like this:
alias: Living Room - Light Off
description: ''
trigger:
- platform: state
entity_id: binary_sensor.presence_9
from: 'on'
to: 'off'
for: '00:10:00'
- platform: template
value_template: "{{ states('sensor.lightlevel_12') > states('input_number.livingroom_lightlevel') }}"
condition: []
action:
- scene: scene.livingroom_light_off
mode: single
but, that was just a minor slip of the pen. The original automation has two triggers. The latter one is now just switching off the lights in case it gets light again outside.
So the automation looks like:
alias: Living Room - Light Off
description: ''
trigger:
- platform: state
entity_id: sensor.lightlevel_12
from: 'on'
to: 'off'
for: '00:10:00'
- platform: template
value_template: "{{ states('sensor.lightlevel_12') > states('input_number.livingroom_lightlevel') }}"
condition: []
action:
- scene: scene.livingroom_light_off
mode: single