def get_payload(self): x = int(self.temperature * 2) x |= self.mode payload = super(SetTemperatureAndModeMessage, self).get_payload() + bytearray([x]) if self.end: payload += date_to_dateuntil(self.end.date()) payload += bytearray([(self.end.time().hour * 2) + (1 if self.end.time().minute >= 30 else 0)]) return payload
def test_date_to_dateuntil(self): du = date_to_dateuntil(datetime.date(2011, 9, 29)) self.assertEqual(du, bytearray([0x9D, 0x4B]))