* heateroutput limit 0 - 15000 w * heatoutput always positive * ENUM_IN_FSV_2041 value 0c00 unknwon added * recalculate crc6 checksum and check it * skip exception to reduce logging * NASAPacket and NASAMessage prepared for write mode MQTT Auto Discovery changed single entitity to all entities NASA Packet crc16 Checksum verificated * - Changed MQTT Auto Discovery Config Message from single Entitiy to all Entities at ones, known devices are fully configured, not known empty (markt to delete) - NASAPacket and NASAMessage are now bidirectional, can decode and encode Packets - Added crc16 Checksum check for any Packet to reduce incorrect value changes - Folling warnings moved to SkipInvalidPacketException and from warning to debug log level to reduce Logentries - Source Adress Class out of enum - Destination Adress Class out of enum - Checksum for package could not be validatet calculated - Message with structure type must have capacity of 1. * NASA_OUTDOOR_HP as kw unit * NASA Repository, measurements enums completed * filter wifikit heartbeat * process only packets from indoor or outdoor * correct readme * remove expire * device discovery status * new mqtt hass configuration approach * added new measurements * added new logging features from config * NASA_EHSSENTINEL_TOTAL_COP added * removed silentMode, added logging proccessedMessage * loaded devices * loaded devices counter fix * only if retain true * final 0.2.0 commit
230 lines
8.7 KiB
Python
230 lines
8.7 KiB
Python
import json
|
|
import NASAPacket
|
|
import NASAMessage
|
|
|
|
|
|
encode_raw = "[50, 0, 17, 16, 0, 0, 176, 0, 255, 192, 20, 143, 1, 128, 49, 0, 157, 7, 52]"
|
|
encode_raw = "[50, 0, 60, 16, 0, 0, 176, 0, 255, 192, 20, 196, 13, 2, 2, 255, 255, 4, 16, 0, 0, 0, 0, 4, 27, 0, 32, 255, 255, 128, 0, 0, 128, 5, 255, 128, 23, 0, 128, 25, 0, 128, 26, 0, 128, 33, 1, 128, 50, 255, 128, 51, 0, 128, 60, 0, 128, 69, 0, 240, 94, 52]"
|
|
encode_raw = "[50, 0, 56, 98, 0, 144, 178, 0, 32, 192, 17, 3, 11, 64, 147, 0, 64, 148, 0, 66, 115, 0, 0, 66, 116, 0, 0, 66, 117, 0, 0, 66, 118, 0, 0, 66, 119, 0, 0, 66, 120, 0, 0, 66, 121, 0, 0, 66, 122, 0, 0, 66, 123, 0, 0, 221, 200, 52]"
|
|
encode_raw = "[50, 0, 56, 98, 0, 144, 178, 0, 32, 192, 17, 240, 11, 64, 147, 0, 64, 148, 0, 66, 115, 0, 0, 66, 116, 0, 0, 66, 117, 0, 0, 66, 118, 0, 0, 66, 119, 0, 0, 66, 120, 0, 0, 66, 121, 0, 0, 66, 122, 0, 0, 66, 123, 0, 0, 76, 33, 52]"
|
|
#encode_raw ="[50, 0, 48, 98, 0, 144, 178, 0, 32, 192, 17, 240, 11, 64, 147, 0, 64, 148, 0, 66, 115, 0, 0, 66, 116, 0, 66, 117, 0, 66, 118, 0, 66, 119, 0, 66, 120, 0, 66, 121, 0, 66, 122, 0, 66, 123, 0, 7, 180, 52]"
|
|
try:
|
|
encode_bytearray = json.loads(encode_raw.strip()) # for [12, 234, 456 ,67]
|
|
except:
|
|
encode_tmp = encode_raw.strip().replace("'", "").replace("[", "").replace("]", "").split(", ") # for ['0x1', '0x2' ..]
|
|
encode_bytearray = [int(value, 16) for value in encode_tmp]
|
|
|
|
|
|
print(f"encode raw: {bytearray(encode_bytearray)}")
|
|
print(f"encode bytearray: {encode_bytearray}")
|
|
print(f"encode bytearray length: {len(encode_bytearray)}")
|
|
|
|
encoded_nasa = NASAPacket.NASAPacket()
|
|
encoded_nasa.parse(encode_bytearray)
|
|
|
|
print(f"encode NASA Object: {encoded_nasa}")
|
|
|
|
# time to reverse that thing!
|
|
decoded_nasa = NASAPacket.NASAPacket()
|
|
decoded_nasa.set_packet_source_address_class(NASAPacket.AddressClassEnum.Outdoor)
|
|
decoded_nasa.set_packet_source_channel(0)
|
|
decoded_nasa.set_packet_source_address(0)
|
|
decoded_nasa.set_packet_dest_address_class(NASAPacket.AddressClassEnum.BroadcastSelfLayer)
|
|
decoded_nasa.set_packet_dest_channel(0)
|
|
decoded_nasa.set_packet_dest_address(255)
|
|
decoded_nasa.set_packet_information(True)
|
|
decoded_nasa.set_packet_version(2)
|
|
decoded_nasa.set_packet_retry_count(0)
|
|
decoded_nasa.set_packet_type(NASAPacket.PacketType.Normal)
|
|
decoded_nasa.set_packet_data_type(NASAPacket.DataType.Notification)
|
|
decoded_nasa.set_packet_number(143)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8031)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
decoded_nasa.set_packet_messages([tmp_msg])
|
|
|
|
decoded_nasa = NASAPacket.NASAPacket()
|
|
decoded_nasa.set_packet_source_address_class(NASAPacket.AddressClassEnum.Outdoor)
|
|
decoded_nasa.set_packet_source_channel(0)
|
|
decoded_nasa.set_packet_source_address(0)
|
|
decoded_nasa.set_packet_dest_address_class(NASAPacket.AddressClassEnum.BroadcastSelfLayer)
|
|
decoded_nasa.set_packet_dest_channel(0)
|
|
decoded_nasa.set_packet_dest_address(255)
|
|
decoded_nasa.set_packet_information(True)
|
|
decoded_nasa.set_packet_version(2)
|
|
decoded_nasa.set_packet_retry_count(0)
|
|
decoded_nasa.set_packet_type(NASAPacket.PacketType.Normal)
|
|
decoded_nasa.set_packet_data_type(NASAPacket.DataType.Notification)
|
|
decoded_nasa.set_packet_number(196)
|
|
lst = []
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x0202)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([255, 255])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x0410)
|
|
tmp_msg.set_packet_message_type(2)
|
|
tmp_msg.set_packet_payload([0, 0, 0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x41b)
|
|
tmp_msg.set_packet_message_type(2)
|
|
tmp_msg.set_packet_payload([0, 32, 255, 255])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8000)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8005)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([255])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8017)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8019)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x801a)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8021)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([1])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8032)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([255])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8033)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x803c)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x8045)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
decoded_nasa.set_packet_messages(lst)
|
|
|
|
#rasw = decoded_nasa.to_raw()
|
|
|
|
decoded_nasa = NASAPacket.NASAPacket()
|
|
decoded_nasa.set_packet_source_address_class(NASAPacket.AddressClassEnum.WiFiKit)
|
|
decoded_nasa.set_packet_source_channel(0)
|
|
decoded_nasa.set_packet_source_address(144)
|
|
decoded_nasa.set_packet_dest_address_class(NASAPacket.AddressClassEnum.BroadcastSetLayer)
|
|
decoded_nasa.set_packet_dest_channel(0)
|
|
decoded_nasa.set_packet_dest_address(32)
|
|
decoded_nasa.set_packet_information(True)
|
|
decoded_nasa.set_packet_version(2)
|
|
decoded_nasa.set_packet_retry_count(0)
|
|
decoded_nasa.set_packet_type(NASAPacket.PacketType.Normal)
|
|
decoded_nasa.set_packet_data_type(NASAPacket.DataType.Read)
|
|
decoded_nasa.set_packet_number(240)
|
|
lst = []
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4093)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4094)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4273)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4274)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4275)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4276)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4277)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4278)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x4279)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x427a)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x427b)
|
|
tmp_msg.set_packet_message_type(1)
|
|
tmp_msg.set_packet_payload([0, 0])
|
|
lst.append(tmp_msg)
|
|
decoded_nasa.set_packet_messages(lst)
|
|
|
|
decoded_nasa = NASAPacket.NASAPacket()
|
|
decoded_nasa.set_packet_source_address_class(NASAPacket.AddressClassEnum.WiFiKit)
|
|
decoded_nasa.set_packet_source_channel(0)
|
|
decoded_nasa.set_packet_source_address(144)
|
|
decoded_nasa.set_packet_dest_address_class(NASAPacket.AddressClassEnum.BroadcastSelfLayer)
|
|
decoded_nasa.set_packet_dest_channel(255)
|
|
decoded_nasa.set_packet_dest_address(255)
|
|
decoded_nasa.set_packet_information(True)
|
|
decoded_nasa.set_packet_version(2)
|
|
decoded_nasa.set_packet_retry_count(0)
|
|
decoded_nasa.set_packet_type(NASAPacket.PacketType.Normal)
|
|
decoded_nasa.set_packet_data_type(NASAPacket.DataType.Notification)
|
|
decoded_nasa.set_packet_number(168)
|
|
tmp_msg = NASAMessage.NASAMessage()
|
|
tmp_msg.set_packet_message(0x0000)
|
|
tmp_msg.set_packet_message_type(0)
|
|
tmp_msg.set_packet_payload([2])
|
|
decoded_nasa.set_packet_messages([tmp_msg])
|
|
|
|
|
|
rasw = decoded_nasa.to_raw()
|
|
|
|
print(f"decoded bytearray: {rasw}")
|
|
print(f"decoded NASA Object: {decoded_nasa}")
|
|
print(f"decoded bytearray: {[int(value) for value in rasw]}")
|
|
|
|
print("Reverse Check:")
|
|
checkback = NASAPacket.NASAPacket()
|
|
checkback.parse(rasw)
|
|
print(checkback) |