I am trying to make a binary sensor that detects when my sump pump runs… I have my sensors broken down by device in a sensors folder with yaml sub-files. None of my other files use binary sensors, so I suspect I have a problem with the template. All I want out of it is an on/off answer, then I can count it over time or notify if it is running to long.
The configuration you posted is a legacy-format Template Binary Sensor placed within the template domain and that’s invalid. You cannot use legacy-format in the template domain which is reserved for modern-format configuration.
Remove the first line containing template: and shift the remainder to the left by two spaces. Now it’s ready for insertion in configuration.yaml.
You said you were putting this in a “sensors folder”. However, this entity is member of the binary_sensor domain and not the sensor domain so don’t mix the two together.
So, now it works and I can get the automation written to warn me if it is running to much.
So, I really need to create /config/sensor/bin_sens.yaml for consistency. Then I have to figure out the proper syntax again. Have been running HA for years, a good thing, but it has lead to my configuration.yaml being bloated and to problems like this.
Also the config change that affected formatting still just blows my mind. I did manage to get my config/sensor/mqtt.yaml fixed day one because it was going to break things in a bad way.
If you are interested, you can use an !include directive, similar to the one you currently have for the sensor domain, for the template domain. It would allow you to place Template Sensors, Template Binary Sensors, Trigger-based Template Sensors, etc in a separate file (or multiple separate files).
For example, this is what I use to support multiple files in a “templates” sub-directory.
Thanks, that is how I do it with many of the domains already. For some reason, it did not register with my brain that templates are just another domain.