Automation not running

Hi,

I’ve built an ESP8266 based door sensor that is running fine in the front end. Door opens it toggles to off and vice versa. However I’ve built an automation that I intend to email me when the door is opened and turn on some lights but its just not running.

I’ve checked the configuration and it passes fine, any help would be most appreciated

My notify setting is as follows:
- platform: smtp
name: Email
server: mysmtpserver.co.uk
port: 25
timeout: 15
sender: [email protected]
recipient:
- [email protected]
sender_name: Home Assistant

- id: FrontDoorMonitor

alias: Monitor the front door
trigger:

  • entity_id: binary_sensor.front_door_reed
    platform: state
    from: ‘On’
    to: ‘Off’
    action:
    • service: notify.email
      data:
      title: ‘Front Door Open’
      message: ‘Front door has been opened’
    • service: homeassistant.turn_on
      entity_id: switch.side_lamp

Try again to format that so it looks correct in the right-hand pane while you’re editing your post. Follow the instructions at the top of the page.

Yes, you need to re-format your code properly:

But just from first glance it looks like you are using the wrong state for your trigger. It should be “on” & “off”. Not “On” & “Off”. Capitalization is important.

1 Like

I used the code tags, but it didnt work…
- id: FrontDoorMonitor
alias: Monitor the front door
trigger:
- entity_id: binary_sensor.front_door_reed
platform: state
from: ‘On’
to: ‘Off’
action:
- service: notify.email
data:
title: ‘Front Door Open’
message: ‘Front door has been opened’
- service: homeassistant.turn_on
entity_id: swith.side_lamp

see my reply right above yours

Which I did and posted again, if it doesn’t work now, I’m not quite sure what more I can do?

you go to your configuration yaml page in any plain text editor and you select then copy all of the code you want to put in the post.

then you paste it into the post.

then you highlight the code in the post that you just pasted in.

then you click the </> symbol at the top of the editor window.

Done!

I think @finity’s suggestion is probably correct. I.e., you’re using the wrong capitalization for the from & to states. They need to be all lower case.

In the future, if you want help from this forum you need to learn to properly format YAML code, error messages, etc. You need to copy directly from a text editor (not a word processor.) Once you’ve pasted the code into the reply box, immediately select it and click the “Preformatted text” button. If that doesn’t work (although it should), you can try putting a line before the code containing exactly three “back tick” characters, and a line after it also with exactly three back ticks. Click on the “please use code blocks and syntax highlighting” link at the top of the page for more details.

Finity

I’ve got lots of other automations using On and Off that work? However I have changed to on and off
but its still not running.

Cheers

You may have (non-binary) sensors whose state is 'On' and 'Off', but the states of binary_sensor’s are always 'on' and 'off' (lower case.) If the automation is still not working, please post it again, properly formatted, and maybe we can spot what else might be wrong.

OK

then you need to figure out how to properly format your code to post here.

After that you need to look in the “states” page (<> symbol in the left hand pane) and see what the actual states say when you switch the sensor.

I have posted the code directly from nano straight into the editor here, highlighted it and hit the preformatted text button.Twice now it hasn’t worked. I’m no noob, I’ve been a sysadmin for over 30 years primarily working with Unix environments.

To be honest, both your attitudes are exactly what is wrong with Open source community, elitist nobs!

Can be asked with it now.

I may be wrong but I’m pretty sure we aren’t the ones with any attitude.

You asked for help.

We tried to help but you (for whatever reason) can’t provide us with the information that is required to provide you the help that you asked for.

Then we try to help you provide us that information by suggesting what has worked countless times every time I’ve ever posted any code here.

Then when we say that we can’t really help until you can provide the information we need to help you then you try to impress us with your credentials and call us names.

Doesn’t seem like the best way to make people want to help you.:roll_eyes:

Believe it or not, we are just trying to help.

Using the preformatted text button is just a shortcut to preceding each selected line with four spaces. That is one way in markdown to format YAML code, etc.

The other way is using three back ticks on a line before and after the code as I mentioned above. I personally use the latter. It would look like this (in the left-hand editing pane):

```
xxx
yyy
```

The reason we put so much emphasis on this is that YAML, as you may know, is extremely sensitive to indentation, and when the code isn’t formatted right it’s impossible to see errors/problems due to incorrect indentation.

We’re more than willing to help if you will allow us. If not, that is, of course, your prerogative.

And you have a nice day too!

:rofl: