Found this brilliant code to put 2 automation into 1 which works great to turn something ON/OFF, but I can’t work out how to adjust the dimming when the light goes on.
Can someone put me on the right track
- id: Automatic_Study_lamp
alias: Automatic Study Lamp
trigger:
- platform: state
entity_id: binary_sensor.study_motion_occupancy_a
to: 'on'
- platform: state
entity_id: binary_sensor.study_motion_occupancy_a
to: 'off'
for:
minutes: 1
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.study_motion_occupancy_a
state: 'on'
- condition: numeric_state
entity_id: sensor.study_motion_illuminance_a
below: 100
- condition: state
entity_id: binary_sensor.study_motion_occupancy_a
state: 'off'
action:
service_template: >
{% if trigger.to_state.state == 'on' %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
data_template:
transition: 1
entity_id: light.study_test