Notifications; mapping values not allowed here

ARGH!
Sorry if this is simple but I can’t work this out. I’ve trying to get location triggers to work. I’m getting what appears to be a common error:
2017-06-28 23:54:19 ERROR (SyncWorker_0) [homeassistant.util.yaml] mapping values are not allowed here in "/Users/Vanessa/.homeassistant/automations.yaml", line 34, column 11

line 34 is the first “data” in this automations.yaml file excerpt:

  alias: I'm home
  id: '1498656841685'
  trigger:
  - entity_id: device_tracker.johns_iphone_6
    from: not home
    platform: state
    to: home
- action:
  - service: notify.ios_johns_iphone_6
      data:
      message: I'm home!
      
  alias: I've left home
  id: '1498656965470'
  trigger:
  - entity_id: device_tracker.johns_iphone_6
    from: home
    platform: state
    to: not home
- action:
  - service: notify.ios_johns_iphone_6
     data:
      message: I've left home!

or here:

I’ve read all the relevant threads but cannot figure out where I’ve gone wrong.

Thanks.

Can you post the code, then highlight it and select this button in the post editor?

That will preserve the formatting of your code so we can see it properly. The error you got is pointing to a formatting issue but it’s hard to tell where it is from your image.

I think the problem is the data: line, which should be lined up under service: and the message: line which should be indented two spaces under data:. Here’s an example from my setup:

# Dryer Notification Sequence Done
- alias: 'Dryer Done - away'
  trigger:
    platform: state
    entity_id: sensor.aeotec_smart_switch_6_power_11_8
    state: '0.0'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.dryer_switch
        state: 'on'
      - condition: state
        entity_id: device_tracker.rpitera_rpitera
        state: 'not_home'
  action:
    - service: notify.pushbullet
      data:
        message: 'Robert, the dryer is done.'
    - service: input_boolean.turn_off
      entity_id: input_boolean.dryer_switch

Try this…

automation:
  - alias: "Garage Door Opened When Away"
    id: '1498656841685'
    trigger:
      platform: state
      entity_id: device_tracker.johns_iphone_6
      from: 'not home'
      to: 'home'
    action:
      service: notify.ios_johns_iphone_6
      data:
        message: "I'm home!"

You only need to use hyphens when you are creating a list, so multiple triggers, actions ect.

check the link below, it goes through yaml formatting. Spacing is super important and is likely what broke your automation here.

Thank you all again,
I’ll have to take the plunge and learn about this YAML aren’t I, instead of annoying you all with my simple questions. Sigh.
This came from trying to use the graphical interface in HA, but it’s also JSON formatting that I’ll need to get up to speed with as well!
John

That’s what we’re here for - you’re not annoying anyone. If someone replies, it means they care about you getting a solution.

Welcome to HA. We’re the friendlier open source option. :wink:

5 Likes

Thank you.
I’m going to put the project “on hold” for a few days until my Raspberry arrives. I suspect it will be much easier if I’m speaking the “same language” as all the help files.
John

It’s definitely easier. I came from a Win10 install, which I ran for about twp months. Moved to the Pi and everything just worked so much better and support was easier to find.

Does it matter either installing HA on top of the NOOB raspberry install, or using HASSbian?

IMO hassbian is easier. Just download, write to SD card and boot.

Hassbian has a few extra things pre installed, check the docs.

1 Like

Thank you. Is the raspberry then able to be programmed and run all the other raspberry Pi functions or is is “locked” into only HA?

It’s essentially a basic vanilla PI setup with HA and any requirements added. Otherwise, it’s just a Pi and you can run anything else you want on it.

Thank you all.
So I have my Pi, installed Noob and then the all-in-one HA installer. Working through the “access remotely using SSL” instructions and have hit a snag where it’s asking me for the password for user “homeassistant”! Step 4 here https://home-assistant.io/docs/ecosystem/certificates/lets_encrypt/#4---obtain-a-tlsssl-certificate-from-lets-encrypt where you enter the command starting with $ ./certbot-auto. The user homeassitant was created by the all in one, and has been loaded on the sudoers list, and has no password. I’ve tried all of my usual ones, blank, “PASSWORD”, etc. I’ve logged out of that user to user Pi and it makes no difference. I’ve run the command prefixed with sudo. Any ideas at all?
Apologies for lack of formatting but I’m on my iPhone waiting for my delayed plane.
Regards,
John

Before you run the cert-bot script, use SU to switch over to the equivalent user

sudo su -s /bin/bash homeassistant

yes I did that and the text to the left of the curser changed to reflect it - sorry I’m not home to copy and paste it. But yes after that step all the commands were within user “home assistant”.
I’ve decided to get remote access to work before proceeding to solve other issues, so I might start again and use Hassbian instead.
John

I keep getting

Error loading /config/configuration.yaml: mapping values are not allowed here
in "/config/automations.yaml", line 11, column 18

Line 11 is the following line:
- condition: sun

What am I doing wrong??

- id: '1610727094914'
  alias: Doorbell light
  description: ''
  trigger:
  - platform: device
    device_id: 3fcd4e52dd980dd25a1ebbba5e752237
    domain: nest
    type: doorbell_chime
  condition:
    conditions: or
      - condition: sun
        before: sunrise
      - condition: sun
        after: sunset
  action:
  - type: turn_on
    device_id: 7fdf22d71defd345592854a0a7458d6a
    entity_id: light.321728022462ab4decac
    domain: light
    brightness_pct: 100
  - delay: '3'
  - type: turn_off
    device_id: 7fdf22d71defd345592854a0a7458d6a
    entity_id: light.321728022462ab4decac
    domain: light
  mode: single

Your syntax is incorrect for the or condition, should be…

- id: '1610727094914'
  alias: Doorbell light
  description: ''
  trigger:
  - platform: device
    device_id: 3fcd4e52dd980dd25a1ebbba5e752237
    domain: nest
    type: doorbell_chime
  condition:
    condition: or
    conditions:
      - condition: sun
        before: sunrise
      - condition: sun
        after: sunset
  action:
  - type: turn_on
    device_id: 7fdf22d71defd345592854a0a7458d6a
    entity_id: light.321728022462ab4decac
    domain: light
    brightness_pct: 100
  - delay: '3'
  - type: turn_off
    device_id: 7fdf22d71defd345592854a0a7458d6a
    entity_id: light.321728022462ab4decac
    domain: light
  mode: single

Okay. thanks that solves it!!!

I did also found out manual triggering ignores conditions… :-D. That took me a while…

1 Like