Bump amcrest to 1.4.0 and use new storage_all method (#23446)

Improve sdcard sensor so it only sends one command to camera per update as opposed to the four it used to send to reduce network traffic and make data consistent. Also better handle returned values of 'unknown'.
pull/23478/head
Phil Bruckner 2019-04-27 10:24:07 -05:00 committed by Andrew Sayre
parent 96fb311f6b
commit 1dbfa8f3be
3 changed files with 15 additions and 7 deletions

View File

@ -3,7 +3,7 @@
"name": "Amcrest", "name": "Amcrest",
"documentation": "https://www.home-assistant.io/components/amcrest", "documentation": "https://www.home-assistant.io/components/amcrest",
"requirements": [ "requirements": [
"amcrest==1.3.0" "amcrest==1.4.0"
], ],
"dependencies": [ "dependencies": [
"ffmpeg" "ffmpeg"

View File

@ -84,8 +84,16 @@ class AmcrestSensor(Entity):
self._state = self._api.ptz_presets_count self._state = self._api.ptz_presets_count
elif self._sensor_type == 'sdcard': elif self._sensor_type == 'sdcard':
sd_used = self._api.storage_used storage = self._api.storage_all
sd_total = self._api.storage_total try:
self._attrs['Total'] = '{0} {1}'.format(*sd_total) self._attrs['Total'] = '{:.2f} {}'.format(*storage['total'])
self._attrs['Used'] = '{0} {1}'.format(*sd_used) except ValueError:
self._state = self._api.storage_used_percent self._attrs['Total'] = '{} {}'.format(*storage['total'])
try:
self._attrs['Used'] = '{:.2f} {}'.format(*storage['used'])
except ValueError:
self._attrs['Used'] = '{} {}'.format(*storage['used'])
try:
self._state = '{:.2f}'.format(storage['used_percent'])
except ValueError:
self._state = storage['used_percent']

View File

@ -161,7 +161,7 @@ alarmdecoder==1.13.2
alpha_vantage==2.1.0 alpha_vantage==2.1.0
# homeassistant.components.amcrest # homeassistant.components.amcrest
amcrest==1.3.0 amcrest==1.4.0
# homeassistant.components.androidtv # homeassistant.components.androidtv
androidtv==0.0.15 androidtv==0.0.15