Hi I have been trying to work out how to get a light on after sun set and turn off 4 hours later.
I am running home assistant, MQTT on RPi2
I can make the light turn on and off via the HA GUI, I am using a ESP8266 to make the light turn on/off via a relay.
I have this work just fine, the MQTT topic is “/gate/light1”
So looking at this example where do you put the topic to turn the light on?
Also can I just put this in the configuration.yaml?
Sorry I am new to this.
automation:
alias: “Exterior Lighting on when dark outside”
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: “{{ state.attributes.elevation }}”
# Can be a positive or negative number
below: -4.0
action:
service: switch.turn_on
entity_id: switch.exterior_lighting