Binary Sensor - help!

I’ve been trying to setup a binary_sensor for homekit presence detection, however, when I try to validate it it throws this: Error loading /config/configuration.yaml: mapping values are not allowed here in "/config/binary_sensor.yaml", line 2, column 11

The code in question is here:

 - platform: template
    sensors:
      k_present:
        friendly_name: "K"
        device_class: presence
        value_template: >-
          {{ is_state('input_boolean.k_present', 'on') }}
 - platform: template
    sensors:
      o_present:
        friendly_name: "O"
        value_template: >-
          {{ is_state('input_boolean.o_present', 'on') }}

For the life of me, I can’t figure this one out. I’m pretty new when it comes to YAML.

try this:

- platform: template
  sensors:
    k_present:
      friendly_name: "K"
      device_class: presence
      value_template: >-
        {{ is_state('input_boolean.k_present', 'on') }}
    o_present:
      friendly_name: "O"
      value_template: >-
        {{ is_state('input_boolean.o_present', 'on') }}

Since you’re breaking your config in separate files, you need to watch your indentation
Also you can simply list your sensors without having to call the platform template again

Awesome, thanks heaps! That worked a treat. I’ve been caught by the indentations before.

1 Like

Fab, feel free to mark it as solved :wink: