From 75887e6069e6d6af4a6448def6dd5e938a6a0a6d Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Fri, 10 Feb 2017 23:51:19 -0500 Subject: [PATCH] Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call (#5865) * Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call * Make lint happy --- homeassistant/components/sensor/amcrest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/amcrest.py b/homeassistant/components/sensor/amcrest.py index 08d551b8fde..f250905e952 100644 --- a/homeassistant/components/sensor/amcrest.py +++ b/homeassistant/components/sensor/amcrest.py @@ -122,10 +122,18 @@ class AmcrestSensor(Entity): def update(self): """Get the latest data and updates the state.""" - version, build_date = self._camera.software_information - self._attrs['Build Date'] = build_date.split('=')[-1] - self._attrs['Serial Number'] = self._camera.serial_number - self._attrs['Version'] = version.split('=')[-1] + try: + version, build_date = self._camera.software_information + self._attrs['Build Date'] = build_date.split('=')[-1] + self._attrs['Version'] = version.split('=')[-1] + except ValueError: + self._attrs['Build Date'] = 'Not Available' + self._attrs['Version'] = 'Not Available' + + try: + self._attrs['Serial Number'] = self._camera.serial_number + except ValueError: + self._attrs['Serial Number'] = 'Not Available' if self._sensor_type == 'motion_detector': self._state = self._camera.is_motion_detected