asetek: warn when --non-volatile is passed to unsupported devices
This commit is contained in:
parent
8a8c1ed2b1
commit
26ce11cdd5
|
@ -367,6 +367,7 @@ class Legacy690Lc(_Base690Lc):
|
|||
self._data.store('pump_duty', None)
|
||||
self._data.store('fan_duty', None)
|
||||
self._set_all_fixed_speeds()
|
||||
_warn_on_unsupported_option(**kwargs)
|
||||
|
||||
def get_status(self, **kwargs):
|
||||
"""Get a status report.
|
||||
|
@ -414,6 +415,7 @@ class Legacy690Lc(_Base690Lc):
|
|||
else:
|
||||
raise KeyError(f'unsupported lighting mode {mode}')
|
||||
self._end_transaction_and_read()
|
||||
_warn_on_unsupported_option(**kwargs)
|
||||
|
||||
def set_fixed_speed(self, channel, duty, **kwargs):
|
||||
"""Set channel to a fixed speed duty."""
|
||||
|
@ -421,6 +423,7 @@ class Legacy690Lc(_Base690Lc):
|
|||
duty = clamp(duty, dmin, dmax)
|
||||
self._data.store(f'{channel}_duty', duty)
|
||||
self._set_all_fixed_speeds()
|
||||
_warn_on_unsupported_option(**kwargs)
|
||||
|
||||
def set_speed_profile(self, channel, profile, **kwargs):
|
||||
"""Not supported by this device."""
|
||||
|
@ -446,6 +449,11 @@ class Hydro690Lc(_ModernBase690Lc):
|
|||
super().set_color(channel, mode, colors, **kwargs)
|
||||
|
||||
|
||||
def _warn_on_unsupported_option(**kwargs):
|
||||
if kwargs.get('non_volatile'):
|
||||
_LOGGER.warning('device does not support non-volatile settings, skipping')
|
||||
|
||||
|
||||
# deprecated aliases
|
||||
AsetekDriver = Modern690Lc
|
||||
LegacyAsetekDriver = Legacy690Lc
|
||||
|
|
|
@ -150,3 +150,22 @@ def test_legacy690Lc_device_matches_leviathan_updates(mockLegacy690LcDevice):
|
|||
_begin, pump_message, fan_message = dev.device._sent_xfers
|
||||
assert pump_message == ('write', 2, [0x13, 50])
|
||||
assert fan_message == ('write', 2, [0x12, 50])
|
||||
|
||||
|
||||
def test_legacy690Lc_device_initialize_warns_on_non_volatile(mockLegacy690LcDevice, caplog):
|
||||
mockLegacy690LcDevice.initialize(non_volatile=True)
|
||||
|
||||
assert 'device does not support non-volatile' in caplog.text
|
||||
|
||||
|
||||
def test_legacy690Lc_device_set_color_warns_on_non_volatile(mockLegacy690LcDevice, caplog):
|
||||
mockLegacy690LcDevice.set_color(channel='led', mode='blinking',
|
||||
colors=iter([[3, 2, 1]]), non_volatile=True)
|
||||
|
||||
assert 'device does not support non-volatile' in caplog.text
|
||||
|
||||
|
||||
def test_legacy690Lc_device_set_fixed_speed_warns_on_non_volatile(mockLegacy690LcDevice, caplog):
|
||||
mockLegacy690LcDevice.set_fixed_speed(channel='fan', duty=80, non_volatile=True)
|
||||
|
||||
assert 'device does not support non-volatile' in caplog.text
|
||||
|
|
Loading…
Reference in New Issue