device: push device settings when device is active after suspend

This commit is contained in:
Peter F. Patel-Schneider 2020-11-22 21:54:18 -05:00
parent 56db8fbdf9
commit 808a719823
2 changed files with 9 additions and 4 deletions

View File

@ -20,6 +20,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
from logging import DEBUG as _DEBUG
from logging import INFO as _INFO
from logging import getLogger
from time import time as _timestamp
@ -303,8 +304,8 @@ class DeviceStatus(dict):
# Devices lose configuration when they are turned off,
# make sure they're up-to-date.
if _log.isEnabledFor(_DEBUG):
_log.debug('%s pushing device settings %s', d, d.settings)
if _log.isEnabledFor(_INFO):
_log.info('%s pushing device settings %s', d, d.settings)
for s in d.settings:
s.apply()

View File

@ -323,11 +323,14 @@ def stop_all():
# after a resume, the device may have been off
# so mark its saved status to ensure that the status is pushed to the device when it comes back
def ping_all(resuming=False):
if _log.isEnabledFor(_INFO):
_log.info('ping all devices%s', ' when resuming' if resuming else '')
for l in _all_listeners.values():
if l.receiver.isDevice:
if resuming:
l.receiver.status._active = False
l.receiver.ping()
if l.receiver.ping():
l.receiver.status.changed(active=True)
l._status_changed(l.receiver)
else:
count = l.receiver.count()
@ -335,7 +338,8 @@ def ping_all(resuming=False):
for dev in l.receiver:
if resuming:
dev.status._active = False
dev.ping()
if dev.ping():
dev.status.changed(active=True)
l._status_changed(dev)
count -= 1
if not count: