Automation: owntracks, MQTT and turning on and off lights when i get home

Hi All i am very new here to this, and my coding skills are somewhat limited. so i hope that even though it might seem a bit simple some of my questions please do cut me some slack.

So here is what i want to do. when i leave the house it should turn of the lights when i get near the house it should turn on some lights. this should be fairly easy i hope.

i have Owntracks set up with CloudMQTT. owntracks when it broadcasts is visible in cloud mqtt, all that seems good.

I have my zones.yaml file set up with a specific zone.
i have my configuration.yaml to !include zonez.yaml.

Even when checking my config it says it should work.

I have set up the following in my automations.yaml file:

- alias: Automation 1
    trigger:
      platform: zone
      entity_id: device_tracker.Nicholas_Nicholas
      from: zone.home
      event: enter
    action:
      service: light.turn_on
      entity_id: light.udenfor_1
                 light.udenfor_2
                 light.udenfor_3
                 light.udenfor_4
                 light.udenfor_5

  - alias: Automation 2
    trigger:
      platform: zone
      entity_id: device_tracker.Nicholas_Nicholas
      from: zone.home
      event: leave
    action:
      service: light.turn_off
      entity_id: light.udenfor_1
                 light.udenfor_2
                 light.udenfor_3
                 light.udenfor_4
                 light.udenfor_5

can someone please help me out

Your triggers aren’t quite right. Try this

- alias: Automation 1
    trigger:
      platform: zone
      entity_id: device_tracker.Nicholas_Nicholas
      zone: zone.home
      event: enter
  - alias: Automation 2
    trigger:
      platform: zone
      entity_id: device_tracker.Nicholas_Nicholas
      zone: zone.home
      event: leave

Thank you for the update, i tried moving some stuff around and it works now, however i also created an automation using the automation tool within home assistant, now my code is all mixed up and i can not figure our what i can delete and still have this thing working and what in the code actually made the the lights in the front yard go off when i came home tonight.

my code looks like this now, i know it is a bit much to ask but i need a little help clearing it up, could you help once more?

- alias: Automation 1
  trigger:
    platform: zone
    entity_id: device_tracker.nicholas_iphone
    zone: zone.home
    event: enter
  action:
    service: light.turn_on
    entity_id: light.udenfor_1 light.udenfor_2 light.udenfor_3 light.udenfor_4 light.udenfor_5
  id: 8fb7c2290f134890a602cfcf291edf42
- alias: Automation 2
  trigger:
    platform: zone
    entity_id: device_tracker.nicholas_iphone
    zone: zone.home
    event: leave
  action:
    service: light.turn_off
    entity_id: light.udenfor_1 light.udenfor_2 light.udenfor_3 light.udenfor_4 light.udenfor_5
  id: c1f48848573c4737af47416a4c50b5fc
- id: '1549815358485'
  alias: turn on lights when home
  trigger:
  - entity_id: device_tracker.nicholas_nicholas
    event: enter
    platform: zone
    zone: zone.home
  condition: []
  action:
  - data: {}
    service: light.turn_on

i now get this error message when i check my config:

Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 71). Please check the docs at https://home-assistant.io/components/automation/
Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 71). Please check the docs at https://home-assistant.io/components/automation/

line 71 is the beging of the !include automations.yaml

This will be the proper formatting to fix the entity_ids for the first two automations but in the third automation you don’t have an entity_id selected for the light.turn_on service so you will still get errors if you try to use these without fixing that first:

- alias: Automation 1
  trigger:
    platform: zone
    entity_id: device_tracker.nicholas_iphone
    zone: zone.home
    event: enter
  action:
    service: light.turn_on
    entity_id: 
      - light.udenfor_1
      - light.udenfor_2
      - light.udenfor_3
      - light.udenfor_4
      - light.udenfor_5
  id: 8fb7c2290f134890a602cfcf291edf42

- alias: Automation 2
  trigger:
    platform: zone
    entity_id: device_tracker.nicholas_iphone
    zone: zone.home
    event: leave
  action:
    service: light.turn_off
    entity_id: 
      - light.udenfor_1
      - light.udenfor_2
      - light.udenfor_3
      - light.udenfor_4
      - light.udenfor_5
  id: c1f48848573c4737af47416a4c50b5fc

- id: '1549815358485'
  alias: turn on lights when home
  trigger:
    entity_id: device_tracker.nicholas_nicholas
    event: enter
    platform: zone
    zone: zone.home
  action:
    entity_id: ????????????
    service: light.turn_on

thank you very much, the third one was a double one anyway so i do not need it. thanks for your help… i will carry on with my next step which is adding that this should only happen 1 hour before the sun sets on the lights turning on automation.

However this will be my own headache. appreciate the help.