How to include binary_sensor?

Hi,

My Lyric custom component works fine…when the API server isn’t down.

But when I try to add a binary_sensor: and some platform, like hikvision, the config checks out.

Then after I restart, I get a notification that lyric isn’t started.

So the questions:
a) How do I make a binary_sensors.yaml file?
b) Are there some binary_sensors that get automatically defined (like user or updater) that make it impossible for me to put another binary_sensor: statement in configuration.yaml?
c) How do others clean up their config by making a binary_sensors.yaml file? Do they have to turn off discovery or other auto-defined aspects of the config.

Thanks,
Ambi

Not sure how long you have been using YAML in HASS

Perhaps you are repeating the binary_sensor: section in your configuration

Have a look at the syntax here: https://www.home-assistant.io/docs/configuration/devices/#style-1-collect-every-entity-under-the-parent

Hope this helps

Phil

Hi Phil,

Thanks for the answer!

I’ve been working with Hass.io on my RPi 4 for about 4-6 weeks now.

I’ve gotten to the point where I need to split up a few things in my config, and these all work:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
sensor: !include sensors.yaml
panel_custom: !include panel_custom.yaml

So, as I’m attempting to put some Hikvision binary sensors in, I added a section:
binary_sensor: !include binary_sensors.yaml

This doesn’t work…either with a camera binary sensor, or any other. In fact, the config check is OK, but upon restarting, I get a message “lyric can’t start” (or words to that effect).

As my lyric is the custom component that many people use, and the fact that adding a binary_sensor breaks it, makes me wonder if the lyric custom component has a binary_sensor: definition somewhere in it. Is Hass telling me “we’ve already defined the binary_sensor declaration somewhere else, so you can’t do another one here”?

The only other thing I could think of was that the following entries in my configuration.yaml may, themselves, already declared a binary_sensor, so, again, adding another declaration would be redundant? Here are the other entries:

default_config:
python_script:
zeroconf:
discovery:
ios:

If I find a binary_sensor: section in the lyric code, I could break it out to my binary_sensors.yaml and have all the binary_sensors in one spot.

I’ll let you know what I figure out…but please reply if you’ve got more info. I can’t believe I’m discovering something nobody else has, so it’s certainly possible it’s a noob issue! :smiley:

Thanks,

Ambi

OK Folks,

It works now.

Normally I’d just delete my previous post but in the interest of other noobs, I’ll leave it in.

The answer was there was a missing space on each line in the binary_sensor definition. The binary_sensors.yaml should look like this:

#  Fish Camera
  - platform: hikvision
    host: 192.168.123.211
    port: 65001
    ssl: False
    username: foo
    password: bar

My Lyric component and the binary sensors work fine now, so, thanks for giving me a forum where I could figure it out!

Cheers,
Ambi

2 Likes