def test_parse_manual_l_message(self, ClassMock): self.init(ClassMock, INIT_RESPONSE_1) self.__update( [ Message.decode( b"L:Cwa8U/ESGQkhALMACwa8WgkSGQAhAMAACwa8XAkSGQUhALIACwirggMSGQUhAAAA" ) ] ) device = self.cube.devices[0] self.assertEqual(MAX_DEVICE_MODE_MANUAL, device.mode) self.assertEqual(17.9, device.actual_temperature) self.assertEqual(16.5, device.target_temperature)
def test_parse_m_message(self, ClassMock): self.init(ClassMock, INIT_RESPONSE_2) self.__update( [ Message.decode( b"M:00,01,VgIEAQdLaXRjaGVuBrxTAgZMaXZpbmcGvFoDCFNsZWVwaW5nCKuCBARXb3JrBrxcBAEGvF" b"NLRVEwMzM2MTA4B0tpdGNoZW4BAQa8WktFUTAzMzYxMDAGTGl2aW5nAgEIq4JLRVEwMzM1NjYyCFNs" b"ZWVwaW5nAwEGvFxLRVEwMzM2MTA0BFdvcmsEAQ==" ), INIT_RESPONSE_2[-1], ] ) self.assertEqual("0E2EBA", self.cube.devices[0].rf_address) self.assertEqual("Thermostat", self.cube.devices[0].name) self.assertEqual(MAX_THERMOSTAT, self.cube.devices[0].type) self.assertEqual("KEQ1086437", self.cube.devices[0].serial) self.assertEqual(1, self.cube.devices[0].room_id) self.assertEqual("0A0881", self.cube.devices[1].rf_address) self.assertEqual("Wandthermostat", self.cube.devices[1].name) self.assertEqual(MAX_WALL_THERMOSTAT, self.cube.devices[1].type) self.assertEqual("KEQ0655743", self.cube.devices[1].serial) self.assertEqual(2, self.cube.devices[1].room_id) self.assertEqual("0CA2B2", self.cube.devices[2].rf_address) self.assertEqual("Fensterkontakt", self.cube.devices[2].name) self.assertEqual(MAX_WINDOW_SHUTTER, self.cube.devices[2].type) self.assertEqual("KEQ0839778", self.cube.devices[2].serial) self.assertEqual(1, self.cube.devices[2].room_id) self.assertEqual("Kitchen", self.cube.rooms[0].name) self.assertEqual(1, self.cube.rooms[0].id) self.assertEqual("Living", self.cube.rooms[1].name) self.assertEqual(2, self.cube.rooms[1].id)
def to_messages(lines): return [Message.decode(line) for line in lines]
b"C:015d2a,7QFdKgATAf9KRVEwMzQxMjY3AQsABEAAAAAAAAAAAP///////////////////////////wsABEAAAAAAAAAAQf///////////////" b"////////////2h0dHA6Ly9tYXguZXEtMy5kZTo4MC9jdWJlADAvbG9va3VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" b"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENFVAAACgADAAAOEENFU1QAAwACAAAcIA==", b"C:0a0881,zgoIgQMCEP9LRVEwNjU1NzQzKyE9CURIVQhFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhVCEUgRSBFIEUgRSBFIEUgRSBFIEUgRSBES" b"FRsRMxVFEUgRSBFIEUgRSBFIEUgRSBFIERIVGxEzFUURSBFIEUgRSBFIEUgRSBFIEUgREhUbETMVRRFIEUgRSBFIEUgRSBFIEUgRSBESFRsRMx" b"VFEUgRSBFIEUgRSBFIEUgRSBFIERIVGxEzFUURSBFIEUgRSBFIEUgRSBFIEUgBxgw", b"C:0ca2b2,EQyisgQBFA9LRVEwODM5Nzc4", b"C:0e2eba,0g4uugEBEKBLRVExMDg2NDM3KyE9CQcYAzAM/wAgYFR4ISAhICEgISAhIEUgRSBFIEUgRSBFICBgVHghICEgISAhICEgRSBFIEUgR" b"SBFIEUgIEJUTiEfISAhICEgISBFIEUgRSBFIEUgRSAgQlROIR8hICEgISAhIEUgRSBFIEUgRSBFICBCVE4hHyEgISAhICEgRSBFIEUgRSBFIEU" b"gIEJUTiEfISAhICEgISBFIEUgRSBFIEUgRSAgQlROIR8hICEgISAhIEUgRSBFIEUgRSBFIA==", b"L:DAoIgewSGAQQAAAA5QYMorL3EpALDi66ChIYABAAAAA=", ] ) LAST_STATE_MSG = Message.decode( b"L:Cwa8U/ESGAAiAAAACwa8WgkSGAAiAAAACwa8XAkSGAUiAAAACwirggMSGAUiAAAA" ) SEND_CMD_OK_RESPONSE = "S:04,0,31" WORKDAY_PROGRAMME_1 = [ {"until": "05:30", "temp": 8}, {"until": "06:30", "temp": 21}, {"until": "23:55", "temp": 8}, {"until": "24:00", "temp": 8}, ] WEEKEND_PROGRAME_1 = [ {"until": "08:00", "temp": 8}, {"until": "10:00", "temp": 21}, {"until": "24:00", "temp": 8},
def testDecodeValidMessage(self): line = b"s:AARAAAAABrxTAWo=\r\n" msg = Message.decode(line) self.assertEqual(Message("s", "AARAAAAABrxTAWo="), msg) self.assertEqual("S", msg.reply_cmd()) self.assertEqual(line, msg.encode())
def testDecodeEmptyMessage(self): self.assertEqual(Message(""), Message.decode(b"\r\n"))