Help needed MQTT HA SUN.SUN

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

You don’t put the topic you put the switch id as specified in the state table or you get it from the name in the mqtt switch you set up under switch: …

- platform: mqtt
  name: bathroom_light   <----------- so switch.bathroom_light but you need to check this in the states table!
  state_topic:   "stat/bathroomPIR"
  command_topic: "cmnd/bathroomPIR"
  qos: 1
  payload_on: "on"
  payload_off: "off"
  retain: true 
  optimistic: false

Thanks there Keith666 I’ll give it a go.