Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
device.hold_heat = False
device.hold_cool = False
elif args.permanent_hold:
device.hold_heat = True
device.hold_cool = True
elif args.hold_until:
try:
holdtime = datetime.datetime.strptime(args.hold_until,
'%H:%M')
except ValueError:
print('Invalid time (use HH:MM)')
return False
try:
device.hold_heat = holdtime.time()
device.hold_cool = holdtime.time()
except somecomfort.client.SomeComfortError as ex:
print('Failed to set hold: %s' % str(ex))
return False
elif args.get_hold:
modes = {}
for mode in ['cool', 'heat']:
hold = getattr(device, 'hold_%s' % mode)
if hold is True:
modes[mode] = 'permanent'
elif hold is False:
modes[mode] = 'schedule'
else:
modes[mode] = str(hold)
print('heat:%s cool:%s' % (modes['heat'], modes['cool']))
return False
return True
def update(self) -> None:
"""Update the state."""
retries = 3
while retries > 0:
try:
self._device.refresh()
break
except (
somecomfort.client.APIRateLimited,
OSError,
requests.exceptions.ReadTimeout,
) as exp:
retries -= 1
if retries == 0:
raise exp
if not self._retry():
raise exp
_LOGGER.error("SomeComfort update failed, Retrying - Error: %s", exp)
_LOGGER.debug(
"latestData = %s ", self._device._data # pylint: disable=protected-access
)
device.hold_heat = False
device.hold_cool = False
elif args.permanent_hold:
device.hold_heat = True
device.hold_cool = True
elif args.hold_until:
try:
holdtime = datetime.datetime.strptime(args.hold_until,
'%H:%M')
except ValueError:
print('Invalid time (use HH:MM)')
return False
try:
device.hold_heat = holdtime.time()
device.hold_cool = holdtime.time()
except somecomfort.client.SomeComfortError as ex:
print('Failed to set hold: %s' % str(ex))
return False
elif args.get_hold:
modes = {}
for mode in ['cool', 'heat']:
hold = getattr(device, 'hold_%s' % mode)
if hold is True:
modes[mode] = 'permanent'
elif hold is False:
modes[mode] = 'schedule'
else:
modes[mode] = str(hold)
print('heat:%s cool:%s' % (modes['heat'], modes['cool']))
return False
return True