Conditional actions

Hello, another question from a newbie…

I would like to setup a xiaomi door sensor to turn on a light, but only if the sun is below the horizon. I think it should be simple (do it in configurator?)

Is there some documenation that can help me with this kind of thing? I’m semi technical…

thanks,

You need automation with a ‘state’ trigger on the door sensor, a ‘sun’ condition (sun being ‘below_horizon’) and and action, that uses ‘light.turn_on’ service and the entity id of that light.

Roughly:

automation:
- trigger:
    platform: state
    entity_id: binary_sensor.my_xiamoni_door_sensor
    to: 'on'
  condition:
    condition: sun
    after: sunset
    before: sunrise
  action:
    service: light.turn_on
    entity_id: light.my_door_light

thanks m0wlheld. Is there a document with these states, triggers, services etc listed?

My sensor shows as “Motion Sensor_158d00011c1f46” in HA. Do I use that name instead of “binary_sensor.my_xiamoni_door_sensor”…?

Apologies for the newbie questions

You can find all entity IDs in the developer tools section of HA, lower end of the left main menu, the < > symbol.

I don’t know about your door opening sensor, but my Homematic sensors are binary, because they only can turn ‘on’ or ‘off’. Your sensor may act different, just scan the entity list to figure out what’s its type (domain) and what’s its id. You can also watch different states here, just click on it’s entity id to get the current state and attributes at the top of the list.