Can somebody help me with automation basics? Sensors etc

I am trying to turn on a night light when illumination goes below 200lm

I used the built in web interface to “code” this automation

Automations.yaml
https://pastebin.com/Nmzd3iX8

Device States
https://pastebin.com/Xwbcd9DS

You got your order all wrong, first the trigger, than the condition (only if neccessary), than the action. Like this:

- alias: Night Light On
  trigger:
    platform: numeric_state
    entity_id: sensor.illumination_34ce0088d7eb
    above: '1'
    below: '200'
  action:
    service: light.turn_on
    data:
      entity_id: light.gateway_light_34ce0088d7eb
      color_name: purple
      brightness: 20
      transition: 200
- alias: Night Light Off
  trigger:
    platform: numeric_state
    entity_id: sensor.illumination_34ce0088d7eb
    above: '201'
    below: '1000'
  action:
    service: light.turn_off
    data:
      entity_id: light.gateway_light_34ce0088d7eb

I did it in the web interface, should I not use that or did I do something wrong?

YAY it is working! Thank you :slight_smile:

1 Like

I think HA parses the code backwards as it’s easier to do that than forwards, so it’s printed cockeyed to our eyes. I think you could just do above 201 for off and below 200 for on.