Feature/v0.2.0 (#7)
* 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
This commit is contained in:
@@ -48,12 +48,53 @@ class NASAMessage:
|
||||
self.packet_message_type: int = packet_message_type
|
||||
self.packet_payload: bytes = bytes([int(hex(x), 16) for x in packet_payload])
|
||||
|
||||
|
||||
def set_packet_message(self, value: int):
|
||||
self.packet_message = value
|
||||
|
||||
def set_packet_message_type(self, value: int):
|
||||
self.packet_message_type = value
|
||||
|
||||
def set_packet_payload(self, value: list):
|
||||
self.packet_payload = bytes([int(hex(x), 16) for x in value])
|
||||
|
||||
def to_raw(self) -> bytearray:
|
||||
|
||||
message_number_reconstructed = (self.packet_message_type << 9) | (self.packet_message & 0x1FF)
|
||||
|
||||
# Extract the original bytes from message_number
|
||||
msg_rest_0 = (self.packet_message >> 8) & 0xFF # Upper 8 bits
|
||||
msg_rest_1 = self.packet_message & 0xFF # Lower 8 bits
|
||||
msgpayload = int.from_bytes(self.packet_payload, byteorder='big', signed=True)
|
||||
if self.packet_message_type == 0:
|
||||
return [
|
||||
msg_rest_0,
|
||||
msg_rest_1,
|
||||
msgpayload & 0xFF
|
||||
]
|
||||
elif self.packet_message_type == 1:
|
||||
return [
|
||||
msg_rest_0,
|
||||
msg_rest_1,
|
||||
(msgpayload >> 8) & 0xFF,
|
||||
msgpayload & 0xFF
|
||||
]
|
||||
elif self.packet_message_type == 2:
|
||||
return [
|
||||
msg_rest_0,
|
||||
msg_rest_1,
|
||||
(msgpayload >> 24) & 0xFF,
|
||||
(msgpayload >> 16) & 0xFF,
|
||||
(msgpayload >> 8) & 0xFF,
|
||||
msgpayload & 0xFF
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
f"NASAMessage(\n"
|
||||
f" packet_message={self.packet_message} ({hex(self.packet_message)}),\n"
|
||||
f" packet_message={self.packet_message} ({hex(self.packet_message)}) ({[x for x in bytearray(self.packet_message.to_bytes(2))]}),\n"
|
||||
f" packet_message_type={self.packet_message_type} ({hex(self.packet_message_type)}),\n"
|
||||
f" packet_payload={self.packet_payload} ({self.packet_payload.hex()})\n"
|
||||
f" packet_payload={self.packet_payload} ({self.packet_payload.hex()}) ({[int(x) for x in self.packet_payload]})\n"
|
||||
f")"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user