Sure, please see below and thanks for your help in advance @Achronite !
I wonder though: You say the device_id and entity_id have to match the z2mqtt device, which is the hue motion sensor. For that, only the entity_id is set two times within the automation as far as I can see: First to capture the light level change and at the very end to make sure the new value is written into the helper. For the light in the condition on the other hand, there is both, the device_id and the entity_id.
When I hit traces, there are no traces found. I guess this is because the automation does not kick in by itself. Only when I execute it manually, the current value of the lux captured by the motion sensor is stored into the helper. A change in lux does not change the value of the helper. All of course while the target light mentioned within the condition is off.
I use illuminance_lux entity instead of illuminance as in your example because that is the one activated by default for that sensor. It works as I can see the lux value changing during the day. The illuminance entity (without _lux) is disabled. Might that be the reason? I thought these two entities are basically the same just a different conversion from raw value to lux value.
alias: Store background lux
description: ""
trigger:
- platform: state
entity_id:
- sensor.badezimmer_rechts_bewegungsmelder_illuminance_lux
attribute: light_level
condition:
- condition: device
type: is_off
device_id: XXX
entity_id: light.badezimmer_rechts
domain: light
action:
- service: input_number.set_value
data:
value: >-
{{ states('sensor.badezimmer_rechts_bewegungsmelder_illuminance_lux') |
int}}
target:
entity_id: input_number.ambient_lux
mode: single