Trouble with automation and device tracker

Hi all,

Really loving HA! I switched from OpenHAB this week, and I really love the interface. Starting to get the hang of things, I think.

But, I’m having a little bit of trouble getting automation working in conjunction with the device tracker. I have basic automation (‘turn front porch light on 20 minutes before sunset’ type of stuff) working, but what I’m looking to accomplish now is a bit trickier, it seems.

I have my work laptop set up for tracking. It shows up in the UI, when it goes offline, its status is set accurately. I put it in its own group as well:

work:
- device_tracker.Surface

I’m not entirely certain I have this defined correctly. “Surface” is the friendly name of my work PC as defined in known_devices.yaml

chadssurfacebook:
name: Surface
mac: REDACTED
picture: /local/chadwork.jpg
track: yes
hide_if_away: no

I also have a group.office that controls two bulbs. This works fine in the UI.

office:
- light.office_1
- light.office_2

My goal is to create an automation rule such that group.office is switched on every weekday at 8:00 am IF device_tracker.Surface is home. So far I have the following (the weekday part hasn’t been incorporated yet):

automation 3:

  • alias: ‘Turn on office lights when working’
    trigger:
    platform: time
    after: ‘08:00:00’
    condition: state
    entity_id: group.work (LINE 115)
    state: home
    action:
    service: light.turn_on
    entity_id: group.office

When this rule is present in the configuration, HA does not start, with the following error in the log:

16-07-22 10:30:26 homeassistant.util.yaml: mapping values are not allowed here
in “/home/chad/.homeassistant/configuration.yaml”, line 115, column 14

Line 115 is indicated in the sample above. It looks like a syntax error, or maybe a misunderstanding about what is/is not allowed as a condition on an automation rule?

Thanks for looking!

I’m now on mobile, but I recommend you to take a look at the examples page here and find similar to what you are trying to achieve.

if i’m right you need to put 1 more time condition in youre code:

automation 3:
 - alias: 'Turn on office lights when working'
 trigger:
   platform: time
   after: '08:00:00'
 condition:    #right here!! 
   condition: state
   entity_id: group.work (LINE 115)
   state: home
 action:
   service: light.turn_on
   entity_id: group.office
1 Like

That’s what I did to construct the rule posted above. What I’m looking for is specific guidance around the error message.

I’m not sure what the second condition would consist of? The error message says that mapping values are not allowed on line 115, but I have no idea what that means.

it means you have something behind your : where nothing is allowed.

you need:

trigger: (without anything behind it)
condition: (without anything behind it)
action: (without anything behind it)

and your condition without anything is failing.

so it is:

condition:
  condition: state

AH, got it! I did as you suggested, and now HA launches with no errors in the log! Thanks!

Now, to wait and see if the rule itself actually works…

1 Like