Skip to content

Commit

Permalink
Merge pull request #88 from twrecked/thumbnail-fix
Browse files Browse the repository at this point in the history
Thumbnail fix
  • Loading branch information
twrecked authored Jul 16, 2019
2 parents 1d470d7 + 8ae2048 commit 2bad978
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.const import (
CONF_USERNAME, CONF_PASSWORD, CONF_SCAN_INTERVAL)

__version__ = '0.0.17'
__version__ = '0.0.18'

_LOGGER = logging.getLogger(__name__)

Expand Down
16 changes: 11 additions & 5 deletions aarlo/pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

_LOGGER = logging.getLogger('pyaarlo')

__version__ = '0.0.17'
__version__ = '0.0.18'

class PyArlo(object):

Expand Down Expand Up @@ -110,9 +110,10 @@ def __init__( self,username,password,name='aarlo',
# always ping bases first!
self._ping_bases()

# queue up initial config retrieval
# Queue up initial config and state retrieval.
self.debug('getting initial settings' )
self._bg.run_in( self._refresh_cameras,2 )
self._bg.run_in( self._refresh_camera_thumbnails,2 )
self._bg.run_in( self._refresh_camera_media,2 )
self._bg.run_in( self._initial_refresh,5 )
self._bg.run_in( self._ml.load,10 )

Expand All @@ -137,9 +138,14 @@ def _parse_devices( self ):
if value is not None:
self._st.set( [device_id,key],value )

def _refresh_cameras( self ):
def _refresh_camera_thumbnails( self ):
""" Request latest camera thumbnails, called at start up to make. """
for camera in self._cameras:
camera.update_last_image()

def _refresh_camera_media( self ):
""" Rebuild cameras media library, called at start up or when day changes. """
for camera in self._cameras:
camera.update_media()

def _refresh_ambient_sensors( self ):
Expand Down Expand Up @@ -170,7 +176,7 @@ def _fast_refresh( self ):
self.debug( 'day changed to {}!'.format( str(today) ) )
self._today = today
self._bg.run( self._ml.load )
self._bg.run( self._refresh_cameras )
self._bg.run( self._refresh_camera_media )

def _slow_refresh( self ):
self.debug( 'slow refresh' )
Expand Down
8 changes: 5 additions & 3 deletions aarlo/pyaarlo/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def _update_media_and_thumbnail( self ):

def _update_last_image( self ):
self._arlo.debug('getting image for ' + self.name )
img = None
img = False
url = self._arlo._st.get( [self.device_id,LAST_IMAGE_KEY],None )
if url is not None:
img = http_get( url )
if img is None:
if img is False:
self._arlo.debug('using blank image for ' + self.name )
img = self._arlo.blank_image

Expand All @@ -123,7 +123,7 @@ def _update_last_image_from_snapshot( self ):
url = self._arlo._st.get( [self.device_id,SNAPSHOT_KEY],None )
if url is not None:
img = http_get( url )
if img is not None:
if img is not False:
# signal up if nedeed
self._arlo._st.set( [self.device_id,LAST_IMAGE_SRC_KEY],'snapshot/' + now_strftime(self._arlo._last_format) )
self._save_and_do_callbacks( LAST_IMAGE_DATA_KEY,img )
Expand Down Expand Up @@ -324,10 +324,12 @@ def min_days_vdo_cache(self, value):
self._min_days_vdo_cache = value

def update_media( self ):
""" Get latest list of recordings from the backend server. """
self._arlo.debug( 'queing media update' )
self._arlo._bg.run_low( self._update_media )

def update_last_image( self ):
""" Get last thumbnail from the backend server. """
self._arlo.debug( 'queing image update' )
self._arlo._bg.run_low( self._update_last_image )

Expand Down
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
0.0.2: Added manifest to aarlo

aarlo:
0.0.18: mirror pyaarlo version
0.0.17: Turn siren off when disabling, add siren on/off service calls.
0.0.16: Allow https pool parameters to be customized.
0.0.15: Mode API fixes and optional device list refresh
Expand All @@ -18,6 +19,7 @@ aarlo:
0.0.4: mirror pyaarlo version

pyaarlo:
0.0.18: fix thumbnails disappearing overnight
0.0.17: mirror aarlo version
0.0.16: Allow https pool parameters to be customized.
0.0.15: Mode API fixes and optional device list refresh
Expand Down
4 changes: 2 additions & 2 deletions custom_components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"aarlo": {
"version": "0.0.17",
"version": "0.0.18",
"local_location": "/custom_components/aarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/aarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand All @@ -15,7 +15,7 @@
]
},
"pyaarlo": {
"version": "0.0.17",
"version": "0.0.18",
"local_location": "/custom_components/aarlo/pyaarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/aarlo/pyaarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand Down

0 comments on commit 2bad978

Please sign in to comment.