def run(self):
    try:
        self.startup()
        while True:
            self.process_home_manager_heartbeat()
            if (self.enable_serial_comms_loop == True):
                self.aircon_comms.flushInput()
                self.build_packets(self.packet_1_dictionary, self.packet_3_dictionary)
                self.send_serial_aircon_data(self.packet_1_send)
                time.sleep(0.16)
                self.aircon_comms.flushInput()
                time.sleep(0.15)
                self.receive_serial_aircon_data()
                if (self.packet_2_error == False):
                    time.sleep(0.16)
                    self.send_serial_aircon_data(self.packet_3_send)
                    self.packet_3_dictionary['1Header3'] = self.calculate_next_sequence_number(self.packet_3_dictionary['1Header3'])
                else:
                    print('Packet 3 not sent because of Packet 2 error')
                time.sleep(0.45)
                self.detect_damper_position(calibrate=False)
                self.adjust_damper_position()
            elif (self.remote_operation_on == True):
                self.remote_operation_on = False
                GPIO.output(self.control_enable, False)
                self.damper_control_state = False
                GPIO.output(self.damper_control, False)
                self.damper_day_zone()
                self.heartbeat_count = 0
                if (self.no_heartbeat_ack == True):
                    self.malfunction = True
                else:
                    self.malfunction = False
                self.update_status()
            else:
                time.sleep(1)
    except KeyboardInterrupt:
        self.shutdown_cleanup()
def run(self):
    try:
        self.startup()
        while True:
            self.process_home_manager_heartbeat()
            if (self.enable_serial_comms_loop == True):
                self.aircon_comms.flushInput()
                self.build_packets(self.packet_1_dictionary, self.packet_3_dictionary)
                self.send_serial_aircon_data(self.packet_1_send)
                time.sleep(0.16)
                self.aircon_comms.flushInput()
                time.sleep(0.15)
                self.receive_serial_aircon_data()
                if (self.packet_2_error == False):
                    time.sleep(0.16)
                    self.send_serial_aircon_data(self.packet_3_send)
                    self.packet_3_dictionary['1Header3'] = self.calculate_next_sequence_number(self.packet_3_dictionary['1Header3'])
                else:
                    print('Packet 3 not sent because of Packet 2 error')
                time.sleep(0.45)
                self.detect_damper_position(calibrate=False)
                self.adjust_damper_position()
            elif (self.remote_operation_on == True):
                self.remote_operation_on = False
                GPIO.output(self.control_enable, False)
                self.damper_control_state = False
                GPIO.output(self.damper_control, False)
                self.damper_day_zone()
                self.heartbeat_count = 0
                if (self.no_heartbeat_ack == True):
                    self.malfunction = True
                else:
                    self.malfunction = False
                self.update_status()
            else:
                time.sleep(1)
    except KeyboardInterrupt:
        self.shutdown_cleanup()