def onClick(self, controlId): xbmc.log("window click " + str(controlId), level=xbmc.LOGNOTICE) statusSlider = self.controls["slider"] downButton = self.controls["down"] upButton = self.controls["up"] autoButton = self.controls["auto"] favoriten_radio_control = self.controls["favoriten"] current_device_position = self.device.get_position() current_device_position_in_percent = self.__get_slider_percent_from_position(self.device) current_slider_position = statusSlider.getPercent() if controlId == downButton.getId(): if current_slider_position >= 5: self.client.move_to_degree(self.device.get_device_id(), current_device_position - 5) elif controlId == upButton.getId(): if current_slider_position <= 95: self.client.move_to_degree(self.device.get_device_id(), current_device_position + 5) elif controlId == statusSlider.getId(): if current_slider_position != current_device_position_in_percent: statusLabel = self.controls["status"] device_group = self.device.get_devicegroup() diff = current_slider_position - current_device_position_in_percent # thermostats can only be shifted in 0.5 degree steps over a range from 3°-28° # this results in 50 possible value. As the slider has 100 possible values # this requires some mappings if current_slider_position < 3: current_slider_position = 3 if diff == 1: new_position = (float(current_slider_position + 1) * 5 + 60) / 2 if new_position % 5 == 0: self.updater.update_slider(int(new_position)) elif diff == -1: new_position = (float(current_slider_position - 1) * 5 + 60) / 2 if new_position % 5 == 0: self.updater.update_slider(int(new_position)) else: new_position = (float(current_slider_position) * 5 + 60) / 2 if new_position % 5 == 0: self.updater.update_slider(int(new_position)) if new_position % 5 == 0: display_value = homepilot_utils.get_display_value(int(new_position), device_group) statusLabel.setLabel(display_value) if controlId == autoButton.getId(): self.handle_automation(self.device.get_device_id(), autoButton.isSelected(), self.device.is_automated()) if controlId == favoriten_radio_control.getId(): self.handle_favorit( self.device.get_device_id(), favoriten_radio_control.isSelected(), self.device.is_favored(), self.use_local_favorites, )
def get_display_value(self): position = self.get_position() group = self.get_devicegroup() return homepilot_utils.get_display_value(position, group)
def get_cmd_txt(self, cmd_id, param, device_group, addon): EIN = 10 AUS = 11 AUF = 1 AB = 2 STOPP = 3 SENSOR = 666 FAHRE_IN_POS = 9 if cmd_id == SENSOR: return addon.getLocalizedString(32379) elif device_group == 1: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif device_group == 2: if cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value(param, device_group) else: return "-" elif device_group == 5: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value(param, device_group) else: return "-" elif device_group == 4: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == 23: return addon.getLocalizedString(32371) elif cmd_id == 24: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value(param, device_group) else: return "-" elif device_group == 8: if cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value(param, device_group) else: return "-" return ""
if controlId == down_button.getId(): if status <= 95: self.client.move_to_position(self.device.get_device_id(), status + 5) elif controlId == up_button.getId(): if status >= 5: self.client.move_to_position(self.device.get_device_id(), status - 5) except Exception, e: xbmc.log(str(e), level=xbmc.LOGWARNING) self.has_error = True #handle slider if controlId == statusSlider.getId(): current_slider_value = statusSlider.getPercent() statusLabel = self.controls["status"] device_group = self.device.get_devicegroup() display_value = homepilot_utils.get_display_value(int(current_slider_value), device_group) statusLabel.setLabel(display_value) if current_slider_value > status: new_position = current_slider_value self.updater.update_slider(new_position) elif current_slider_value < status: new_position = current_slider_value self.updater.update_slider(new_position) if controlId == auto_button.getId(): self.handle_automation(self.device.get_device_id(), auto_button.isSelected(), self.device.is_automated()) if controlId == favoriten_radio_control.getId(): self.handle_favorit(self.device.get_device_id(), favoriten_radio_control.isSelected(), self.device.is_favored(), self.use_local_favorites)
def get_cmd_txt(self, cmd_id, param, device_group, addon): EIN = 10 AUS = 11 AUF = 1 AB = 2 STOPP = 3 SENSOR = 666 FAHRE_IN_POS = 9 if cmd_id == SENSOR: return addon.getLocalizedString(32379) elif device_group == 1: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif device_group == 2: if cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value( param, device_group) else: return "-" elif device_group == 5: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value( param, device_group) else: return "-" elif device_group == 4: if cmd_id == EIN: return addon.getLocalizedString(32375) elif cmd_id == AUS: return addon.getLocalizedString(32376) elif cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == 23: return addon.getLocalizedString(32371) elif cmd_id == 24: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value( param, device_group) else: return "-" elif device_group == 8: if cmd_id == AUF: return addon.getLocalizedString(32371) elif cmd_id == STOPP: return addon.getLocalizedString(32372) elif cmd_id == AB: return addon.getLocalizedString(32373) elif cmd_id == FAHRE_IN_POS: if param is not None: return homepilot_utils.get_display_value( param, device_group) else: return "-" return ""