mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
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'.
This commit is contained in:
parent
96fb311f6b
commit
1dbfa8f3be
@ -3,7 +3,7 @@
|
||||
"name": "Amcrest",
|
||||
"documentation": "https://www.home-assistant.io/components/amcrest",
|
||||
"requirements": [
|
||||
"amcrest==1.3.0"
|
||||
"amcrest==1.4.0"
|
||||
],
|
||||
"dependencies": [
|
||||
"ffmpeg"
|
||||
|
@ -84,8 +84,16 @@ class AmcrestSensor(Entity):
|
||||
self._state = self._api.ptz_presets_count
|
||||
|
||||
elif self._sensor_type == 'sdcard':
|
||||
sd_used = self._api.storage_used
|
||||
sd_total = self._api.storage_total
|
||||
self._attrs['Total'] = '{0} {1}'.format(*sd_total)
|
||||
self._attrs['Used'] = '{0} {1}'.format(*sd_used)
|
||||
self._state = self._api.storage_used_percent
|
||||
storage = self._api.storage_all
|
||||
try:
|
||||
self._attrs['Total'] = '{:.2f} {}'.format(*storage['total'])
|
||||
except ValueError:
|
||||
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']
|
||||
|
@ -161,7 +161,7 @@ alarmdecoder==1.13.2
|
||||
alpha_vantage==2.1.0
|
||||
|
||||
# homeassistant.components.amcrest
|
||||
amcrest==1.3.0
|
||||
amcrest==1.4.0
|
||||
|
||||
# homeassistant.components.androidtv
|
||||
androidtv==0.0.15
|
||||
|
Loading…
x
Reference in New Issue
Block a user