Fail2Ban Sensor Error

Hi I am trying to play around with the fail2ban sensor and I get the following error any ideas ?

2017-11-18 13:05:59 ERROR (MainThread) [homeassistant.components.sensor] Error on device update! Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/", line 216, in async_add_entity yield from entity.async_device_update(warning=False) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/", line 309, in async_device_update yield from self.hass.async_add_job(self.update) File "/usr/lib/python3.5/asyncio/", line 361, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/", line 296, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/", line 274, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/", line 91, in update if self.log_parser.timer(): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/", line 129, in timer boundary = - self.interval TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

1 Like

I have the exact same problem. The homeassistant user has permissions to the log file and can read it fine.

Do you have scan_interval: in your config? I intended for it to be optional but forgot it in the schema so you actually need to include that for the sensor to work. PR to fix the issue is currently open here

Your config should look something like this:

  - platform: fail2ban
      - hass-iptables
    file_path: /var/log/fail2ban.log
    scan_interval: 60

Sorry for the late update. That worked perfectly.

Fixed it for me too, thanks.

I tried to get the sensor to work and it seemed like this kind of issues were never addressed. I fixed these issue along with some proposed behaviour change in this pull request.

Hoping this helps other fixing their issues with this component.

I just had the exact same error again and fixed it with the scan_interval.
Did the pull request not go through yet?