Just for fun, an example of the perils of using an LLM to write an automation:
Me: write an automation to turn on the bathroom light when the bathroom motion sensor detects movement
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'on'
actions:
- action: light.turn_on
target:
entity_id: light.bathroom
Me: modify it so that the light is turned off when no movement has been detected for 10 minutes
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'off'
for:
minutes: 10
actions:
- action: light.turn_on
target:
entity_id: light.bathroom
- action: light.turn_off
target:
entity_id: light.bathroom
Me: that will not work. the light will be turned on and off every time the automation triggers
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'off'
for:
minutes: 10
condition:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor
state: 'on'
actions:
- action: light.turn_on
target:
entity_id: light.bathroom
- action: light.turn_off
target:
entity_id: light.bathroom
Me: that will not work. the light will be turned on and off every time motion is detected. when motion has not been detected for 10 minutes nothing will happen
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'off'
for:
minutes: 10
actions:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor
state: 'on'
sequence:
- action: light.turn_on
target:
entity_id: light.bathroom
- conditions:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor
state: 'off'
sequence:
- action: light.turn_off
target:
entity_id: light.bathroom
Me: add an override to optionally prevent the motion sensor turning the light on and off
trigger:
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_motion_sensor
to: 'off'
for:
minutes: 10
condition:
- condition: state
entity_id: input_boolean.motion_sensor_override
state: 'off'
actions:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor
state: 'on'
sequence:
- action: light.turn_on
target:
entity_id: light.bathroom
- conditions:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor
state: 'off'
sequence:
- action: light.turn_off
target:
entity_id: light.bathroom
I’m impressed that it got the idea of an override. ![]()
Every time I try this experiment (with the same wording) it invents a different cockeyed approach. Back to the prompt.