ZHA - Error while processing state changed for binary_sensor

I’m running Home Assistant Core v114.4 on Raspbian and recently noticed that one of my motion sensor automations wasn’t always triggering. The automation watches the state of a Samsung SmartThings ZigBee motion sensor to turn on and off lights. The following has been showing up in the logs for that motion sensor:

2020-09-08 14:29:26 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state changed for binary_sensor.bathroom_motion_sensor
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/event.py", line 173, in _async_state_change_dispatcher
    hass.async_run_job(action, event)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 384, in async_run_job
    target(*args)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/automation/state.py", line 120, in state_automation_listener
    time_delta.async_render(variables)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py", line 230, in async_render
    return compiled.render(kwargs).strip()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

I have seven or eight of these motion sensors and only this one is generating the errors. Any ideas on what would have caused this all of the sudden? And what would be the best way to resolve it? Removing and re-adding the device?

I removed the problematic device from the ZHA integration and re-added it yesterday afternoon. Unfortunately, that didn’t resolve the issue.