Help with binary sensor - what am I doing wrong?

Hi,

Been working on a binary sensor to show “on” when anyone of the household is at home. My attempts so far haven’t worked.

I have the following code:

- platform: template 
  sensors: 
    house_occupation_status:
      friendly_name: "Occupation status"
      value_template: >-
        {{ is_state('person.pete', 'home') or
        is.state('person.2', 'home') }}

The code above kept showing “on”, so created a simpler, test sensor to test if it actually worked.

- platform: template 
  sensors:
    test_sensor:
      value_template: >-
        {{ is.state('person.pete', 'home') }}

The test sensor is “off” all the time, even though I am at home. And my person is registered showing as home in HA.

I’m new to HA, so am having trouble deciphering where I’m going wrong - any help is appreciated.

Thanks,

The function is called
is_state
not
is.state

Templating documentation

well, this is embarrassing… They now both work. Thank you :slight_smile:

Let this thread be a warning to double-check the spelling when writing a function.

1 Like