Puzzled by binary_sensor

hi,

been trying the various effects of sensor definitions. And stumbled on this very simple set of sensors which have different outcomes when defined differently in configuration.yaml:

when configuration.yaml calls a separate binary_sensor: !include binary_sensor.yaml with the contents of these 2 sensors the result in frontend is:

21

i don’t like too many files in the root, so i tried to add the sensors to my sensor setup, an include_dir_merge_list sensors, and the result of the same declaration is:

1017

Cant i include these binary_sensors in HomeAssistant whithout explicitly calling them in the configuration.yaml?

Cheers,
Marius

No, you can’t have sensors that aren’t somehow declared or referenced in configuration.yaml.
You can put your binary_sensors.yaml in a directory (let’s say config) by changing the include to this:

!include config/binary_sensor.yaml 

To change the way the sensors appear on the front end see the documentation on customization

thanks.
i know i have to declare the sensors in the configuration file, i have done so. One for Sensor: !include_dir_list_merge sensors, and now one for binary_sensor: binary_sensor.yaml.

its just that these binary_sensors are the only ones i have to declare as such in the config. All other sensors , be it template, boolean, mqtt or what have you are declared by stating the platform, followed by sensor, name etc.
Apparently the binary-sensor needs its own declaration, and can’t be declared under Sensor: in the config file. At least not without changing the output as described above.

ive i put the binary_sensor.yaml in the dir_list_merge sensors, that would still lose the above functionality, and needing an extra dir, is as complicated as having an extra yaml file.

Im learning this all on the job now, so you probably have architectural suggestions based on your experience i could benefit from. iow, don’t hold back :wink:

Thanks anyways,
Marius

1 Like

That is correct, binary sensors are different from sensors. Unless I misunderstand your question this information from should help you;

OK, I see your issue now. The Binary Sensor is a different component than sensor. It’s not a platform for sensor.
The binary_sensor component has a large number of platforms, just like sensor does. If you declare your sensors as the component binary_sensor, you get the functionality of a binary sensor. When you declare them as sensor, you get the functionality of generic sensor. So your complaint seems to be that you want the functionality of the binary sensor component, while declaring your sensors as standard sensors.

2 Likes

this helps a lot . i wasn’t so much complaining, more trying to understand it all. i ws indeed confused and thinking is the binary_sensor was another platform for sensor like the ones i mentioned.
Thanks for clarifying.
That being the case, there’s all the more reason to have a separate entry for it in the config file :wink:

unless, and that was the last bit of my question above, you might direct me otherwise.

Cheers,
Marius

thanks indeed, i m still in the phase i need that page… but it’s growing on me.
cheers,
Marius