I have code that works at my house. The front porch light comes on after sunset, if the front door opens.
- id: '1708744525201'
alias: New Front Porch Light on Door opening After sunset 2-23-24
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_sensor_magnet_aq2_87da0008_on_off # This is my front door sensor
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- service: switch.turn_on
metadata: {}
data: {}
target:
device_id: e0f4c7d64634bd117c387dd8fcba3ad8 # this is my front porch light
mode: single
The -id, the binary_sensors, and devices are different than yours, but this code works great, no turn-off code yet.
feel free to hit me up on chat if you’re really struggling and want some real time help. if i’m online and available i’m happy to do so. what you’re trying to do here should be really easy.
Highly recommend Lewis’s everydaysmarthome channel, it’s essentially all home assistant content, he’s a nice bloke too but as others have said we’re all here to help. The best person is the person willing to learn so your approach is fantastic.
If using tutorials that aren’t part of the official documentation, just be aware that HA evolves over time and tutorials that were once good can become out-of-date. Check how recent they are, and if you encounter problems, cross-check with the docs.