From 2f4b2ddc0a175871ae0c11e8628ccd0d11a2ed3c Mon Sep 17 00:00:00 2001 From: Sytone Date: Wed, 19 Apr 2017 09:08:48 -0700 Subject: [PATCH] Add condition for API failure (#7181) * Add condition for API failure If you are not running the latest ve3rsion of ZM this will cause exceptions to fire. This fix handles a response from ZM but a non successful attempt. This resolves the issue https://github.com/home-assistant/home-assistant/issues/7178 * Fixed houndci-bot issues --- homeassistant/components/camera/zoneminder.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/camera/zoneminder.py b/homeassistant/components/camera/zoneminder.py index be38d468f2d..e419564a887 100644 --- a/homeassistant/components/camera/zoneminder.py +++ b/homeassistant/components/camera/zoneminder.py @@ -101,11 +101,17 @@ class ZoneMinderCamera(MjpegCamera): status_response = zoneminder.get_state( 'api/monitors/alarm/id:%i/command:status.json' % self._monitor_id ) + if not status_response: _LOGGER.warning('Could not get status for monitor %i', self._monitor_id) return + if status_response['success'] is False: + _LOGGER.warning('Alarm status API call failed for monitor %i', + self._monitor_id) + return + self._is_recording = status_response['status'] == ZM_STATE_ALARM @property