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
pull/7175/head^2
Sytone 2017-04-19 09:08:48 -07:00 committed by Paulus Schoutsen
parent 921760f8c1
commit 2f4b2ddc0a
1 changed files with 6 additions and 0 deletions

View File

@ -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