temperature: merge nested ifs

This commit is contained in:
alfrix 2022-10-14 10:18:42 -03:00
parent 723662074e
commit e208873e46

View File

@ -211,18 +211,17 @@ class TemperaturePanel(ScreenPanel):
self.hide_numpad() self.hide_numpad()
def select_heater(self, widget, device): def select_heater(self, widget, device):
if self.active_heater is None: if self.active_heater is None and self.devices[device]["can_target"]:
if self.devices[device]["can_target"]: if device in self.active_heaters:
if device in self.active_heaters: self.active_heaters.pop(self.active_heaters.index(device))
self.active_heaters.pop(self.active_heaters.index(device)) self.devices[device]['name'].get_style_context().remove_class("button_active")
self.devices[device]['name'].get_style_context().remove_class("button_active") self.devices[device]['select'].set_label(_("Select"))
self.devices[device]['select'].set_label(_("Select")) logging.info(f"Deselecting {device}")
logging.info(f"Deselecting {device}") return
return self.active_heaters.append(device)
self.active_heaters.append(device) self.devices[device]['name'].get_style_context().add_class("button_active")
self.devices[device]['name'].get_style_context().add_class("button_active") self.devices[device]['select'].set_label(_("Deselect"))
self.devices[device]['select'].set_label(_("Deselect")) logging.info(f"Seselecting {device}")
logging.info(f"Seselecting {device}")
return return
def set_temperature(self, widget, setting): def set_temperature(self, widget, setting):