def __init__(self, calibrate_damper_on_startup):
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    self.control_enable = 17
    self.damper_control = 25
    self.damper_stop = 24
    self.damper_zone = 23
    GPIO.setup(self.control_enable, GPIO.OUT)
    GPIO.setup(self.damper_control, GPIO.OUT)
    GPIO.setup(self.damper_stop, GPIO.OUT)
    GPIO.setup(self.damper_zone, GPIO.OUT)
    GPIO.output(self.control_enable, False)
    self.damper_control_state = False
    GPIO.output(self.damper_control, False)
    self.damper_stop_state = False
    GPIO.output(self.damper_stop, False)
    self.damper_zone_state = False
    GPIO.output(self.damper_zone, False)
    self.remote_operation_on = False
    self.enable_serial_comms_loop = False
    self.heating = False
    self.compressor = False
    self.malfunction = False
    self.heat_mode = False
    self.cool_mode = False
    self.fan_mode = False
    self.fan_hi = False
    self.fan_med = False
    self.fan_lo = False
    self.filter = False
    self.requested_damper_percent = 100
    self.adjusting_damper = False
    self.damper_day_position = 416
    self.damper_night_position = 1648
    self.calibrate_damper_on_startup = calibrate_damper_on_startup
    self.heartbeat_count = 0
    self.no_heartbeat_ack = False
    self.packet1_header_a = '00'
    self.packet1_header_b = '8f'
    self.packet1_header = (self.packet1_header_a + self.packet1_header_b)
    self.packet2_header_a = '80'
    self.packet2_header_b = '8c'
    self.packet2_header = (self.packet2_header_a + self.packet2_header_b)
    self.packet3_initial_header = self.packet1_header
    self.mode = {'Auto On': 'b0', 'Auto Off': '90', 'Dry On': 'b1', 'Dry Off': '91', 'Cool On': 'b2', 'Cool Off': '92', 'Fan On': 'b3', 'Fan Off': '93', 'Heat On': 'b4', 'Heat Off': '94'}
    self.set_temp = {'18 degrees': '48', '19 degrees': '4a', '20 degrees': '4c', '21 degrees': '4e', '22 degrees': '50', '23 degrees': '52', '24 degrees': '54', '25 degrees': '56', '26 degrees': '58', '27 degrees': '5a', '28 degrees': '5c', '29 degrees': '5e', '30 degrees': '60'}
    self.fan_speed = {'Lo On': 'f0', 'Lo Off': 'e0', 'Med On': 'f1', 'Med Off': 'e1', 'Hi On': 'f2', 'Hi Off': 'e2'}
    self.clean_filter = {'Reset': 'f1', 'No Reset': 'f0'}
    self.alerts = {'Not in Warmup': ['f8', 'fa'], 'Warmup': ['f9', 'fb'], 'Clean Filter': ['fa', 'fb'], 'Filter OK': ['f8', 'f9']}
    self.compressor_state = {'Off': 'e0', 'On': 'e2'}
    self.packet_1_dictionary = {'1Header1': self.packet1_header, '2Mode1': self.mode['Fan Off'], '3Filler1a': '00', '4SetTemp1': self.set_temp['20 degrees'], '5Fan1': self.fan_speed['Hi Off'], '6Filler1b': 'fffff03fffffffffff'}
    self.packet_2_dictionary = {'1Header2': self.packet2_header, '2Mode2': self.mode['Fan Off'], '3Filler2a': '00', '4SetTemp2': self.set_temp['20 degrees'], '5Fan2': self.fan_speed['Hi Off'], '6ActualTemp2': '90', '7Filler2b': '00', '8Unknown2': 'e0', '9Alerts2': self.alerts['Warmup'], '10Filler2c': 'ffff', '11Compressor2': self.compressor_state['On'], '12Filler2c': 'ffff', '13Checksum2': '00'}
    self.packet_3_dictionary = {'1Header3': self.packet3_initial_header, '2Mode3': self.mode['Fan Off'], '3Filler3a': '00', '4SetTemp3': self.set_temp['20 degrees'], '5Fan3': self.fan_speed['Hi Off'], '6Filler3b': 'fffff03fffffffffff'}
    self.aircon_comms = serial.Serial('/dev/ttyAMA0', 1200, parity=serial.PARITY_EVEN, timeout=0.5)
    self.spi = spidev.SpiDev()
    speed = 50000
    self.spi.open(0, 0)
    self.spi.max_speed_hz = speed
    resp = self.spi.xfer2([14, 0, 0])
    time.sleep(0.3)
    resp = self.spi.xfer2([0, 0])
    time.sleep(0.1)
    resp = self.spi.xfer2([15, 0, 0])
    time.sleep(0.3)
    resp = self.spi.xfer2([0, 0])
    time.sleep(0.1)
def __init__(self, calibrate_damper_on_startup):
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    self.control_enable = 17
    self.damper_control = 25
    self.damper_stop = 24
    self.damper_zone = 23
    GPIO.setup(self.control_enable, GPIO.OUT)
    GPIO.setup(self.damper_control, GPIO.OUT)
    GPIO.setup(self.damper_stop, GPIO.OUT)
    GPIO.setup(self.damper_zone, GPIO.OUT)
    GPIO.output(self.control_enable, False)
    self.damper_control_state = False
    GPIO.output(self.damper_control, False)
    self.damper_stop_state = False
    GPIO.output(self.damper_stop, False)
    self.damper_zone_state = False
    GPIO.output(self.damper_zone, False)
    self.remote_operation_on = False
    self.enable_serial_comms_loop = False
    self.heating = False
    self.compressor = False
    self.malfunction = False
    self.heat_mode = False
    self.cool_mode = False
    self.fan_mode = False
    self.fan_hi = False
    self.fan_med = False
    self.fan_lo = False
    self.filter = False
    self.requested_damper_percent = 100
    self.adjusting_damper = False
    self.damper_day_position = 416
    self.damper_night_position = 1648
    self.calibrate_damper_on_startup = calibrate_damper_on_startup
    self.heartbeat_count = 0
    self.no_heartbeat_ack = False
    self.packet1_header_a = '00'
    self.packet1_header_b = '8f'
    self.packet1_header = (self.packet1_header_a + self.packet1_header_b)
    self.packet2_header_a = '80'
    self.packet2_header_b = '8c'
    self.packet2_header = (self.packet2_header_a + self.packet2_header_b)
    self.packet3_initial_header = self.packet1_header
    self.mode = {'Auto On': 'b0', 'Auto Off': '90', 'Dry On': 'b1', 'Dry Off': '91', 'Cool On': 'b2', 'Cool Off': '92', 'Fan On': 'b3', 'Fan Off': '93', 'Heat On': 'b4', 'Heat Off': '94'}
    self.set_temp = {'18 degrees': '48', '19 degrees': '4a', '20 degrees': '4c', '21 degrees': '4e', '22 degrees': '50', '23 degrees': '52', '24 degrees': '54', '25 degrees': '56', '26 degrees': '58', '27 degrees': '5a', '28 degrees': '5c', '29 degrees': '5e', '30 degrees': '60'}
    self.fan_speed = {'Lo On': 'f0', 'Lo Off': 'e0', 'Med On': 'f1', 'Med Off': 'e1', 'Hi On': 'f2', 'Hi Off': 'e2'}
    self.clean_filter = {'Reset': 'f1', 'No Reset': 'f0'}
    self.alerts = {'Not in Warmup': ['f8', 'fa'], 'Warmup': ['f9', 'fb'], 'Clean Filter': ['fa', 'fb'], 'Filter OK': ['f8', 'f9']}
    self.compressor_state = {'Off': 'e0', 'On': 'e2'}
    self.packet_1_dictionary = {'1Header1': self.packet1_header, '2Mode1': self.mode['Fan Off'], '3Filler1a': '00', '4SetTemp1': self.set_temp['20 degrees'], '5Fan1': self.fan_speed['Hi Off'], '6Filler1b': 'fffff03fffffffffff'}
    self.packet_2_dictionary = {'1Header2': self.packet2_header, '2Mode2': self.mode['Fan Off'], '3Filler2a': '00', '4SetTemp2': self.set_temp['20 degrees'], '5Fan2': self.fan_speed['Hi Off'], '6ActualTemp2': '90', '7Filler2b': '00', '8Unknown2': 'e0', '9Alerts2': self.alerts['Warmup'], '10Filler2c': 'ffff', '11Compressor2': self.compressor_state['On'], '12Filler2c': 'ffff', '13Checksum2': '00'}
    self.packet_3_dictionary = {'1Header3': self.packet3_initial_header, '2Mode3': self.mode['Fan Off'], '3Filler3a': '00', '4SetTemp3': self.set_temp['20 degrees'], '5Fan3': self.fan_speed['Hi Off'], '6Filler3b': 'fffff03fffffffffff'}
    self.aircon_comms = serial.Serial('/dev/ttyAMA0', 1200, parity=serial.PARITY_EVEN, timeout=0.5)
    self.spi = spidev.SpiDev()
    speed = 50000
    self.spi.open(0, 0)
    self.spi.max_speed_hz = speed
    resp = self.spi.xfer2([14, 0, 0])
    time.sleep(0.3)
    resp = self.spi.xfer2([0, 0])
    time.sleep(0.1)
    resp = self.spi.xfer2([15, 0, 0])
    time.sleep(0.3)
    resp = self.spi.xfer2([0, 0])
    time.sleep(0.1)