mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Arlo - Fixes for updated library (#9892)
* Reduce update calls to API. Add signal strength monitor. * Fix lint errors * Fix indent * Update pyarlo version and review fixes * Fix lint errors * Remove staticmethod * Clean up attributes * Update arlo.py
This commit is contained in:
parent
c7b0f25eae
commit
c2d0c8fba4
@ -12,7 +12,7 @@ from requests.exceptions import HTTPError, ConnectTimeout
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
|
||||
|
||||
REQUIREMENTS = ['pyarlo==0.0.7']
|
||||
REQUIREMENTS = ['pyarlo==0.1.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=10)
|
||||
SCAN_INTERVAL = timedelta(seconds=90)
|
||||
|
||||
ARLO_MODE_ARMED = 'armed'
|
||||
ARLO_MODE_DISARMED = 'disarmed'
|
||||
@ -31,6 +31,7 @@ ATTR_MOTION = 'motion_detection_sensitivity'
|
||||
ATTR_POWERSAVE = 'power_save_mode'
|
||||
ATTR_SIGNAL_STRENGTH = 'signal_strength'
|
||||
ATTR_UNSEEN_VIDEOS = 'unseen_videos'
|
||||
ATTR_LAST_REFRESH = 'last_refresh'
|
||||
|
||||
CONF_FFMPEG_ARGUMENTS = 'ffmpeg_arguments'
|
||||
|
||||
@ -73,6 +74,8 @@ class ArloCam(Camera):
|
||||
self._motion_status = False
|
||||
self._ffmpeg = hass.data[DATA_FFMPEG]
|
||||
self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS)
|
||||
self._last_refresh = None
|
||||
self._camera.base_station.refresh_rate = SCAN_INTERVAL.total_seconds()
|
||||
self.attrs = {}
|
||||
|
||||
def camera_image(self):
|
||||
@ -105,14 +108,17 @@ class ArloCam(Camera):
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {
|
||||
ATTR_BATTERY_LEVEL: self.attrs.get(ATTR_BATTERY_LEVEL),
|
||||
ATTR_BRIGHTNESS: self.attrs.get(ATTR_BRIGHTNESS),
|
||||
ATTR_FLIPPED: self.attrs.get(ATTR_FLIPPED),
|
||||
ATTR_MIRRORED: self.attrs.get(ATTR_MIRRORED),
|
||||
ATTR_MOTION: self.attrs.get(ATTR_MOTION),
|
||||
ATTR_POWERSAVE: self.attrs.get(ATTR_POWERSAVE),
|
||||
ATTR_SIGNAL_STRENGTH: self.attrs.get(ATTR_SIGNAL_STRENGTH),
|
||||
ATTR_UNSEEN_VIDEOS: self.attrs.get(ATTR_UNSEEN_VIDEOS),
|
||||
name: value for name, value in (
|
||||
(ATTR_BATTERY_LEVEL, self._camera.battery_level),
|
||||
(ATTR_BRIGHTNESS, self._camera.brightness),
|
||||
(ATTR_FLIPPED, self._camera.flip_state),
|
||||
(ATTR_MIRRORED, self._camera.mirror_state),
|
||||
(ATTR_MOTION, self._camera.motion_detection_sensitivity),
|
||||
(ATTR_POWERSAVE, POWERSAVE_MODE_MAPPING.get(
|
||||
self._camera.powersave_mode)),
|
||||
(ATTR_SIGNAL_STRENGTH, self._camera.signal_strength),
|
||||
(ATTR_UNSEEN_VIDEOS, self._camera.unseen_videos),
|
||||
) if value is not None
|
||||
}
|
||||
|
||||
@property
|
||||
@ -160,13 +166,4 @@ class ArloCam(Camera):
|
||||
|
||||
def update(self):
|
||||
"""Add an attribute-update task to the executor pool."""
|
||||
self.attrs[ATTR_BATTERY_LEVEL] = self._camera.get_battery_level
|
||||
self.attrs[ATTR_BRIGHTNESS] = self._camera.get_battery_level
|
||||
self.attrs[ATTR_FLIPPED] = self._camera.get_flip_state,
|
||||
self.attrs[ATTR_MIRRORED] = self._camera.get_mirror_state,
|
||||
self.attrs[
|
||||
ATTR_MOTION] = self._camera.get_motion_detection_sensitivity,
|
||||
self.attrs[ATTR_POWERSAVE] = POWERSAVE_MODE_MAPPING[
|
||||
self._camera.get_powersave_mode],
|
||||
self.attrs[ATTR_SIGNAL_STRENGTH] = self._camera.get_signal_strength,
|
||||
self.attrs[ATTR_UNSEEN_VIDEOS] = self._camera.unseen_videos
|
||||
self._camera.update()
|
||||
|
@ -29,7 +29,8 @@ SENSOR_TYPES = {
|
||||
'last_capture': ['Last', None, 'run-fast'],
|
||||
'total_cameras': ['Arlo Cameras', None, 'video'],
|
||||
'captured_today': ['Captured Today', None, 'file-video'],
|
||||
'battery_level': ['Battery Level', '%', 'battery-50']
|
||||
'battery_level': ['Battery Level', '%', 'battery-50'],
|
||||
'signal_strength': ['Signal Strength', None, 'signal']
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
@ -97,6 +98,16 @@ class ArloSensor(Entity):
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data and updates the state."""
|
||||
try:
|
||||
base_station = self._data.base_station
|
||||
except (AttributeError, IndexError):
|
||||
return
|
||||
|
||||
if not base_station:
|
||||
return
|
||||
|
||||
base_station.refresh_rate = SCAN_INTERVAL.total_seconds()
|
||||
|
||||
self._data.update()
|
||||
|
||||
if self._sensor_type == 'total_cameras':
|
||||
@ -114,7 +125,13 @@ class ArloSensor(Entity):
|
||||
|
||||
elif self._sensor_type == 'battery_level':
|
||||
try:
|
||||
self._state = self._data.get_battery_level
|
||||
self._state = self._data.battery_level
|
||||
except TypeError:
|
||||
self._state = None
|
||||
|
||||
elif self._sensor_type == 'signal_strength':
|
||||
try:
|
||||
self._state = self._data.signal_strength
|
||||
except TypeError:
|
||||
self._state = None
|
||||
|
||||
@ -128,7 +145,8 @@ class ArloSensor(Entity):
|
||||
|
||||
if self._sensor_type == 'last_capture' or \
|
||||
self._sensor_type == 'captured_today' or \
|
||||
self._sensor_type == 'battery_level':
|
||||
self._sensor_type == 'battery_level' or \
|
||||
self._sensor_type == 'signal_strength':
|
||||
attrs['model'] = self._data.model_id
|
||||
|
||||
return attrs
|
||||
|
@ -603,7 +603,7 @@ pyairvisual==1.0.0
|
||||
pyalarmdotcom==0.3.0
|
||||
|
||||
# homeassistant.components.arlo
|
||||
pyarlo==0.0.7
|
||||
pyarlo==0.1.0
|
||||
|
||||
# homeassistant.components.notify.xmpp
|
||||
pyasn1-modules==0.1.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user