Template binary_sensor error "got '<scalar>'"

Trying to create a template sensor to combine a people group and an input_boolean to know if the home is occupied by either people or a ‘guest mode’.

binary_sensor:
  - platform: template
    sensors:
      home_occupied:
        friendly_name: "Home Occupied 2"
        unique_id: ishomeoccupied
        device_class: occupancy
        value_template: {{ is_state('group.family_home', 'home') or is_state('input_boolean.guest_mode', 'on') }}

When I try to use this I get the following error:

Error loading /config/configuration.yaml: while parsing a flow mapping
in "/config/configuration.yaml", line 21, column 26
expected ',' or '}', but got '<scalar>'
in "/config/configuration.yaml", line 21, column 64

line 21 is the value_template line.

I’ve read a bunch of documentation but cannot find help with this particular error.

single line templates require quotes on the outside and need to be different than on the inside:

value_template: "{{ is_state('group.family_home', 'home') or is_state('input_boolean.guest_mode', 'on') }}"

:man_facepalming:

Thank you. I could have sworn that I had quotes there at one point.

1 Like