Questions an configuring a sensor and use it for automations

Hello everyone,
I’m new to Home Assistant and home automation at all and I would appreciate some help with configuring my first sensor.
I am using a Aeotec Z-Stick Gen 5 at a RPi 3 with a Hassbian running and added a Schwaiger 4 in 1 sensor (which seems to be a rebranded Philio PST02-A) via Z-Wave.
In added a screenshot at the bottom to show how this looks in Home Assistant.

First, I want to add configure the door/window sensor and added

 sensor:
 - platform: template
   sensors: 
     door_sensor:
       friendly_name: 'door sensor terrace'
       entity_id: sensor.terrace_door_open
       value_template: >-
         {%- if is_state("sensor.your_sensor", "23") -%}
         closed
         {%- else -%}
         open
         {%- endif -%}

to configuration.yaml. Is this correct? Can I tell Home Assistant via “frindly_name” which sensor to use and just use the name I gave the sensor in the overview?
I want to use this sensor now for automation and added the following to configuration.yaml

 automation:
 - alias: terrace safety
    trigger:
         platform: state
         entitiy_id: sensor.terrasse_door_open
         from: 'closed'
         to: 'open'
   action:
        service: notify.email_notify
         data_template:
         title: "Door was opened"
         message: "Someone opened the door"

However, check config tells me that this is wrong

Configuration invalid
Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/configuration.yaml”, line 104, column 11

Could someone help and tell me what I am doing wrong here? Has platform to be template here as well? I would really appreciate if someone could point me to the right direction, maybe give me a link to the right documentation as well. Because going through the getting started section I did not really get how Home Assistant knows which sensor is being configured with an entry and how names and entity_ids are connected…

Thanks in advance
Celdrion

When I

Your indentation is not correct. It is very important in YAML.

Try:

 automation:
 - alias: 'terrace safety'
   trigger:
     platform: state
     entitiy_id: sensor.terrace_door_open
     from: 'closed'
     to: 'open'
   action:
     service: notify.email_notify
     data_template:
       title: "Door was opened"
       message: "Someone opened the door"

Also if your alias has spaces in it use single quotes.

Also you misspelled the sensor name (sensor.terrace_door_open vs sensor.terrasse_door_open).

This doesn’t look correct. does sensor.your_sensor exist? I think you should get rid of the entity_id line and place that in the sensor.your_sensor spot. Also, as a side note, I think you should be looking for the ‘open’ state, not closed state. I’ve heard some devices report outside 23 when closed.

 sensor:
 - platform: template
   sensors: 
     door_sensor:
       friendly_name: 'door sensor terrace'
       value_template: >-
         {%- if is_state("sensor.terrace_door_open", "22") -%}
         open
         {%- else -%}
         closed
         {%- endif -%}

EDIT: For clarification, the entity_id line is for entities that don’t fit into your calculation. Basically, if you want to update a template when an entity updates that is NOT part of your equation, use the entity_id attribute to accomplish that task.

Hey and thank you very much for helping. The terrace was not a real problem, I just translated to English for the forum and missed that once… Anyways, I just go with everything in English now so that there won’t be any problem.

I got rid of the entity_id line and placed that in sensor.your_sensor and Home Assistant seems fine with it.
However, the part with the automation still seems to be wrong, even though I tried to copy your text, @tom_l.

Checking the configuration gives me:

in “/config/configuration.yaml”, line 102, column 3 expected , but found ‘’ in “/config/configuration.yaml”, line 103, column 4

line 102 is the line in which “- alias” is.
Do you guys know what’s wrong?

Did you just change what you did in your original or did you copy exactly what you @tom_l had written?

Your original code has the wrong spacing

  • extra space in front of trigger
  • too many spaces in front of all the lines for platform, entity_id, from, and to
  • service has too many spaces in front of it.
  • data_template should be in line with service.
  • title, and message have too few spaces in relation to data_template.

You want to keep your spacing at spaces per ‘level’ typically, unless you have a list of items (indicated by the -)

Also you named your sensor door_sensor. not terrasse_door_open

  automation:
 - alias: terrace safety
   trigger:
     platform: state
     entitiy_id: sensor.door_sensor
     from: 'closed'
     to: 'open'
   action:
     service: notify.email_notify
     data_template:
       title: "Door was opened"
       message: "Someone opened the door"