device: push device settings when device is active after suspend
This commit is contained in:
parent
56db8fbdf9
commit
808a719823
|
@ -20,6 +20,7 @@
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
from logging import DEBUG as _DEBUG
|
from logging import DEBUG as _DEBUG
|
||||||
|
from logging import INFO as _INFO
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from time import time as _timestamp
|
from time import time as _timestamp
|
||||||
|
|
||||||
|
@ -303,8 +304,8 @@ class DeviceStatus(dict):
|
||||||
|
|
||||||
# Devices lose configuration when they are turned off,
|
# Devices lose configuration when they are turned off,
|
||||||
# make sure they're up-to-date.
|
# make sure they're up-to-date.
|
||||||
if _log.isEnabledFor(_DEBUG):
|
if _log.isEnabledFor(_INFO):
|
||||||
_log.debug('%s pushing device settings %s', d, d.settings)
|
_log.info('%s pushing device settings %s', d, d.settings)
|
||||||
for s in d.settings:
|
for s in d.settings:
|
||||||
s.apply()
|
s.apply()
|
||||||
|
|
||||||
|
|
|
@ -323,11 +323,14 @@ def stop_all():
|
||||||
# after a resume, the device may have been off
|
# 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
|
# so mark its saved status to ensure that the status is pushed to the device when it comes back
|
||||||
def ping_all(resuming=False):
|
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():
|
for l in _all_listeners.values():
|
||||||
if l.receiver.isDevice:
|
if l.receiver.isDevice:
|
||||||
if resuming:
|
if resuming:
|
||||||
l.receiver.status._active = False
|
l.receiver.status._active = False
|
||||||
l.receiver.ping()
|
if l.receiver.ping():
|
||||||
|
l.receiver.status.changed(active=True)
|
||||||
l._status_changed(l.receiver)
|
l._status_changed(l.receiver)
|
||||||
else:
|
else:
|
||||||
count = l.receiver.count()
|
count = l.receiver.count()
|
||||||
|
@ -335,7 +338,8 @@ def ping_all(resuming=False):
|
||||||
for dev in l.receiver:
|
for dev in l.receiver:
|
||||||
if resuming:
|
if resuming:
|
||||||
dev.status._active = False
|
dev.status._active = False
|
||||||
dev.ping()
|
if dev.ping():
|
||||||
|
dev.status.changed(active=True)
|
||||||
l._status_changed(dev)
|
l._status_changed(dev)
|
||||||
count -= 1
|
count -= 1
|
||||||
if not count:
|
if not count:
|
||||||
|
|
Loading…
Reference in New Issue