Multiple switch template crashing HA

I’m obviously missing something crucial here. The logic works fine in the Developer tools, and have based the rest of it on the templating docs. But I can’t figure out why HA throws a wobbly at this.

What am I doing wrong?! Suggestions gratefully received…

- platform: template
  sensors:
    awc_status:
        friendly_name: 'AWC Status'           
        value_template: >
              {% if is_state('switch.tapo_10', 'on') 
                 and is_state('switch.tapo_13', 'on') %}
                Overflow
              {% elif  is_state('switch.tapo_10', 'off')  
                 and is_state('switch.tapo_13', 'off') %}
                Standby
              {% elif  is_state('switch.tapo_10', 'on')  
                 and is_state('switch.tapo_13', 'off') %}
                Drain
              {% elif  is_state('switch.tapo_10', 'off')  
                 and is_state('switch.tapo_13', 'on') %}
                Fill
              {% else %}
                Error
              {% endif %}

Actually appears to break HA in some way (won’t restart / check config without throwing errors).

The logs show:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config.py”, line 895, in async_process_component_config
p_validated = platform.PLATFORM_SCHEMA(p_config) # type: ignore
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 218, in call
return self._exec((Schema(val) for val in self.validators), v)
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 337, in _exec
v = func(v)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 817, in validate_callable
return schema(data)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 386, in validate_mapping
cval = cvalue(key_path, value)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 817, in validate_callable
return schema(data)
File “/usr/src/homeassistant/homeassistant/helpers/config_validation.py”, line 489, in verify
return cast(dict, schema(value))
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 386, in validate_mapping
cval = cvalue(key_path, value)
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 215, in _run
return self._exec(self._compiled, value, path)
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 339, in _exec
v = func(path, v)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 817, in validate_callable
return schema(data)
File “/usr/src/homeassistant/homeassistant/helpers/config_validation.py”, line 750, in validator
if key in config:
TypeError: argument of type ‘NoneType’ is not iterable

Your error is outside the code you posted. Please post the entirety of the file that you placed the above code into.

Quite right. After a reboot… it suddenly works. Hmmph.

Thanks, though!