Config error autiomation

Hi,

Trying to get my head around Home assistant. Currently have a config to turn the lights out when no one is at home. this is the current error:
Check config
Invalid config for [automation]: [service] is an invalid option for [automation]

this is my config automation:

#lights when everybody leaves the house
  - alias: 'Away Mode'
    trigger:
     platform: state
     entity_id: device_tracker.life360_amma, device_tracker.life360_sabina_rahman, device_tracker.life360_shazad_ahmed
     to: 'not_home'
    action:
  -   service:  light.turn_off
      entity_id: group.all_lights
  -   service: notify.notify
      data: 
      Message: "lights off"

Spacing/indentation… the hyphens for service need to be under action… then one space - service … everything that is under/indented should be two spaces

I would suggest moving the device_trackers into a group. The result would be everyone is not_home, and one person can be home. Instead of every person being home or not home.

group:
  people:
    name: People
    entity_id:
      - device_tracker.life360_amma
      - device_tracker.life360_sabina_rahman
      - device_tracker.life360_shazad_ahmed

Next, spacing is very important in YAML, see below. Message was capitalized, but shouldn’t be.

#lights when everybody leaves the house
  - alias: 'Away Mode'
    trigger:
      platform: state
      entity_id: group.people
      to: 'not_home'
    action:
      - service: light.turn_off
        entity_id: group.all_lights
      - service: notify.notify
        data: 
          message: "lights off"
1 Like

Thank you. I have a group set up so will add to that. Really appreciate your help. Will give this a go.

The trigger spacing was off by one indent as well. Edited post should be correct.

thank you - with the people group. can I just cut and past that into my group like this?

Hallway  lights:
  name: Hallway Lights
  entities:
  
    - light.bathroom
    - light.entrance
    - light.stairs
    - light.kitchen
    
 group:
  people:   
 name: People
    entity_id:
      - device_tracker.life360_amma
      - device_tracker.life360_sabina_rahman
      - device_tracker.life360_shazad_ahmed

Thank you for all your help.

Negative, “group” can only be defined once. Bring the people group in line with your other entries in your group yaml. I made a mistake using entity_id, it should be entities.

people:   
  name: People
  entities:
    - device_tracker.life360_amma
    - device_tracker.life360_sabina_rahman
    - device_tracker.life360_shazad_ahmed

Yes!!! seems to have done the trick!! I have spent the best part of a week trying to figure this stuff out! Many thanks!

1 Like

Actually -
Not sure how to approach this. I have 3 people I track which is me, my wife and my mum. Both me and my wife live at the home location. Mum lives at a location called Mum. I would like to automate my lights at the home location. To go on and off when the last person lives/enters home. Currently my states are home, moving, mum, away or my work location. I have a group which has my life360 device codes This is my config. Is this correct? I suspect that my mum being at mum might cause it not to fire
#lights when everybody leaves the house

  • alias: ‘Away Mode’
    trigger:
    platform: state
    entity_id: group.people
    to: ‘not_home’
    action:
    • service: light.turn_off
      entity_id: group.all_lights
    • service: notify.pushbullet
      data:
      message: “lights off”

#lights when first person enters

  • alias: ‘home Mode’
    trigger:
    platform: state
    entity_id: group.people
    to: ‘home’
    action:
    • service: light.turn_on
      entity_id: group.hallway_lights

I’m not sure what your concern is… that the Mum zone would get confused with someone being at “home”?

I think it would be fine how you have it. I have a group called family which includes my wife and I and the in-laws… I have no issues with it setting the house/empty/not empty status. The wife and are tracked with iCloud3 and the in-laws phones are only tracked with asuswrt when then join my WiFi… but have yet to have it say the house is unoccupied when it’s not .

You just may want to consider combining a couple device trackers for each person as no one presence method seems to be 100% so previously we each had our own groups I tracked each of us with multiple trackers… group.brian_status contained the trackers then group.family (or group.people in your case) just contained the group.PERsOns_status

Now I just moved to the person component with just the two device trackers and have been very pleased with how well it’s been working.

1 Like

Yes. I wasn’t sure if the home/not home status would not fire if anyone was on the mum or moving status.

You will probably find it’s ultimately going to depend on how quickly the device updates its location (I edited my above post with a little more info on using multiple trackers)

Cheers. Seems like a good idea. Will look into that