Error when binary_sensor moves to a difference file

Hi,

I have my binary sensors are also inside the configuration.yaml file.

I want move them to a seperate file called binary_sensor.yaml

I have created this file & moved the binary sensors to this file & added the following line to the configuration.yaml file.

binary_sensor: !include binary_sensor.yaml

But I get the error Configuration warnings
Invalid config for ‘binary_sensor’ at configuration.yaml, line 11: required key ‘platform’ not provided

My binary_sensor.yaml files lookes as follows

binary_sensor:
  - platform: template
    sensors:
      is_night:
        friendly_name: "Is Night"
        value_template: >-
          {{ now().time() >= strptime('18:00:00', '%H:%M:%S').time() or now().time() < strptime('06:00:00', '%H:%M:%S').time() }} 
          
  - platform: template
    sensors:
      pixel_work:
        friendly_name: "Pixel Work"
        value_template: "{{ is_state('device_tracker.pixel_7', 'work') }}"    

How to resolve this?

Remove this line from your binary_sensor.yaml file.

At the moment your !include resolves to this in your configuration.yaml file:

binary_sensor:
  binary_sensor:
    - platform: template
      sensors: etc...

When it should only be this:

binary_sensor:
  - platform: template
    sensors: etc...

Also you should be using the new template integration for new sensors. And your “is night” sensor could be done a lot easier with the ToD integration:

1 Like