Setting up a binary sensor to check states and state attributes

Hi I am trying to figure out how to setup a binary sensor to evaluate multiple states and one state attribute of the same sensor. I am using the “next holiday” integration from HACS. This integration provides a sensor that list the next major holiday as the state. It also has a state attribute that lists if that next holiday is today. If it is today that state attribute says “true”. Below is the yaml I wrote. If I don’t include the last line with the “is_state_attr” the sensors works as expected. When I add that line I get an error in the logs that says

invalid config for 'template' at configuration.yaml, line 125: required key 'state' not provided Invalid config for 'template' at configuration.yaml, line 126: 'value_template' is an invalid option for 'template', check: binary_sensor->0->value_template

obvisouly I have set something up incorrectly. Any help would be appreciated.

Template:
  - binary_sensor:
      - name: Xcel Holiday
        state: >
          {{ is_state('sensor.next_holiday', 'New Year's Day')
             or is_state('sensor.next_holiday', 'Good Friday')
             or is_state('sensor.next_holiday', 'Memorial Day')
             or is_state('sensor.next_holiday', 'Independence Day')
             or is_state('sensor.next_holiday', 'Labor Day')
             or is_state('sensor.next_holiday', 'Thanksgiving')
             or is_state('sensor.next_holiday', 'Christmas Day')
             or is_state('sensor.next_holiday', 'Washington's Birthday')
             and is_state_attr('sensor.next_holiday', 'Today is holiday', true) }}

template: should not be capitalised and you need to escape apostrophes with single quotes (same symbol) in YAML:

template:
  - binary_sensor:
      - name: Xcel Holiday
        state: >
          {{ is_state('sensor.next_holiday', 'New Year''s Day')
             or is_state('sensor.next_holiday', 'Good Friday')
             or is_state('sensor.next_holiday', 'Memorial Day')
             or is_state('sensor.next_holiday', 'Independence Day')
             or is_state('sensor.next_holiday', 'Labor Day')
             or is_state('sensor.next_holiday', 'Thanksgiving')
             or is_state('sensor.next_holiday', 'Christmas Day')
             or is_state('sensor.next_holiday', 'Washington''s Birthday')
             and is_state_attr('sensor.next_holiday', 'Today is holiday', true) }}

Or use double quotes:

template:
  - binary_sensor:
      - name: Xcel Holiday
        state: >
          {{ is_state("sensor.next_holiday", "New Year's Day")
             or is_state('sensor.next_holiday', 'Good Friday')
             or is_state('sensor.next_holiday', 'Memorial Day')
             or is_state('sensor.next_holiday', 'Independence Day')
             or is_state('sensor.next_holiday', 'Labor Day')
             or is_state('sensor.next_holiday', 'Thanksgiving')
             or is_state('sensor.next_holiday', 'Christmas Day')
             or is_state("sensor.next_holiday", "Washington's Birthday")
             and is_state_attr('sensor.next_holiday', 'Today is holiday', true) }}

In case it is difficult to see the problematic states are New Year's Day and Washington's Birthday.

You probably also need parentheses around all the or tests if you want the and to apply to all of them.

template:
  - binary_sensor:
      - name: Xcel Holiday
        state: >
          {{ ( is_state("sensor.next_holiday", "New Year's Day")
             or is_state('sensor.next_holiday', 'Good Friday')
             or is_state('sensor.next_holiday', 'Memorial Day')
             or is_state('sensor.next_holiday', 'Independence Day')
             or is_state('sensor.next_holiday', 'Labor Day')
             or is_state('sensor.next_holiday', 'Thanksgiving')
             or is_state('sensor.next_holiday', 'Christmas Day')
             or is_state("sensor.next_holiday", "Washington's Birthday") )
             and is_state_attr('sensor.next_holiday', 'Today is holiday', true) }}

Finally, this error message is not for the config you posted:

thank you. It is always something small like that.

So this bit of code was working fine but one of the home assistant updates made it so it doesn’t work any more.

The code below is suppose to be true when the sensor “next_holiday” matches one of the listed holiday’s AND when the sensors attribute “today is holiday” equals true. If I separate out the statements and test them individually they work. It seems like my code isn’t understanding the “AND” statement. Any insight would be appreciated.

template:
   - binary_sensor:
      - name: Xcel Holiday
        state: >
          {{ ( is_state("sensor.next_holiday", "New Year's Day")
             or is_state('sensor.next_holiday', 'Good Friday')
             or is_state('sensor.next_holiday', 'Memorial Day')
             or is_state('sensor.next_holiday', 'Independence Day')
             or is_state('sensor.next_holiday', 'Labor Day')
             or is_state('sensor.next_holiday', 'Thanksgiving')
             or is_state('sensor.next_holiday', 'Christmas Day')
             or is_state("sensor.next_holiday", "Washington's Birthday") 
             and is_state_attr('sensor.next_holiday', 'today_is_holiday', (true))) }}