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
This commit is contained in:
Marcelo Moreira de Mello 2017-02-10 23:51:19 -05:00 committed by Paulus Schoutsen
parent e877d572f5
commit 75887e6069

View File

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