Esempio n. 1
0
    def _parse_week_program(self, buffer):
        program = []

        for day in range(0, 7):
            day_schedules = []
            offset = day * 26

            day_config = buffer[offset:offset + 26]

            start = datetime.time()

            for schedule_offset in range(0, 26, 2):
                schedule_bytes = day_config[schedule_offset:schedule_offset +
                                            2]
                temp, time = unpack_temp_and_time(schedule_bytes)

                schedule = ProgramSchedule(temp, start, time)
                day_schedules.append(schedule)

                start = schedule.end_minutes

                if time >= 1440:
                    break

            program.append(day_schedules)

        return program
Esempio n. 2
0
	def _parse_week_program(self, buffer):
		program = []

		for day in range(0, 7):
			day_schedules = []
			offset = day * 26

			day_config = buffer[offset:offset+26]

			start = datetime.time()

			for schedule_offset in range(0, 26, 2):
				schedule_bytes = day_config[schedule_offset:schedule_offset+2]
				temp, time = unpack_temp_and_time(schedule_bytes)

				schedule = ProgramSchedule(temp, start, time)
				day_schedules.append(schedule)

				start = schedule.end_minutes

				if time >= 1440:
					break

			program.append(day_schedules)

		return program
Esempio n. 3
0
	def get_payload(self):
		data = super(SetProgramMessage, self).get_payload()
		data += bytearray([py_day_to_cube_day(self.weekday)])

		# the cube happily accepts less than 13 * 2 bytes for the schedules on a day
		# and will replace the the rest with "low temperature till midnight" schedules
		for schedule in self.program:
			result = pack_temp_and_time(schedule.temperature, schedule.end_minutes)
			rev_temp, rev_minutes = unpack_temp_and_time(result)
			#print("{0}°C, {1} results in {2:2X} {3:2X} ({2:08b} {3:08b}), revd: {4}°C, {5} minutes ({6} h)".format(schedule.temperature, schedule.end_minutes, result[0], result[1], rev_temp, rev_minutes, rev_minutes / 60.0))
			data += result

		self.dump_bytes(data, "SetProgramMessage payload")

		return data
Esempio n. 4
0
    def get_payload(self):
        data = super(SetProgramMessage, self).get_payload()
        data += bytearray([py_day_to_cube_day(self.weekday)])

        # the cube happily accepts less than 13 * 2 bytes for the schedules on a day
        # and will replace the the rest with "low temperature till midnight" schedules
        for schedule in self.program:
            result = pack_temp_and_time(schedule.temperature, schedule.end_minutes)
            rev_temp, rev_minutes = unpack_temp_and_time(result)
            #print("{0}°C, {1} results in {2:2X} {3:2X} ({2:08b} {3:08b}), revd: {4}°C, {5} minutes ({6} h)".format(schedule.temperature, schedule.end_minutes, result[0], result[1], rev_temp, rev_minutes, rev_minutes / 60.0))
            data += result

        self.dump_bytes(data, "SetProgramMessage payload")

        return data
Esempio n. 5
0
File: util.py Progetto: ercpe/pymax
    def test_unpack_temp_and_time(self):
        temperature, minutes = unpack_temp_and_time(bytearray([0x40, 0x49]))

        self.assertEqual(temperature, 16)
        self.assertEqual(minutes, 365)