Skip to content

Commit

Permalink
reducing logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Nov 11, 2023
1 parent 19a7f64 commit 0308e50
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Classes/ZigpyTransport/AppGeneric.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ def handle_join(self, nwk: t.NWK, ieee: t.EUI64, parent_nwk: t.NWK) -> None:
try:
dev = self.get_device(ieee)
#time.sleep(2.0)
self.log.logging("TransportZigpy", "Log", "Device 0x%04x (%s) joined the network" %(nwk, ieee))
self.log.logging("TransportZigpy", "Debug", "Device 0x%04x (%s) joined the network" %(nwk, ieee))
except KeyError:
dev = self.add_device(ieee, nwk)
#time.sleep(2.0)
self.log.logging("TransportZigpy", "Log", "New device 0x%04x (%s) joined the network" %(nwk, ieee))
self.log.logging("TransportZigpy", "Debug", "New device 0x%04x (%s) joined the network" %(nwk, ieee))

if dev.nwk != nwk:
dev.nwk = nwk
_update_nkdids_if_needed(self, ieee, dev.nwk )
self.log.logging("TransportZigpy", "Log", "Device %s changed id (0x%04x => 0x%04x)" %(ieee, dev.nwk, nwk))
self.log.logging("TransportZigpy", "Debug", "Device %s changed id (0x%04x => 0x%04x)" %(ieee, dev.nwk, nwk))

super(type(self),self).handle_join(nwk, ieee, parent_nwk)

Expand Down
93 changes: 49 additions & 44 deletions Modules/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,24 +2037,23 @@ def Decode8042(self, Devices, MsgData, MsgLQI): # Node Descriptor response


def Decode8043(self, Devices, MsgData, MsgLQI): # Reception Simple descriptor response
# MsgLen = len(MsgData)
"""Decode and process 0x8043 message."""

MsgDataSQN = MsgData[:2]
MsgDataStatus = MsgData[2:4]
MsgDataShAddr = MsgData[4:8]
MsgDataLenght = MsgData[8:10]
self.log.logging(
"Input",
"Debug",
"Decode8043 - Received SQN: %s Addr: %s Len: %s Status: %s Data: %s" % (MsgDataSQN, MsgDataShAddr, MsgDataLenght, MsgDataStatus, MsgData),
)
self.log.logging( "Input", "Debug", "Decode8043 - Received SQN: %s Addr: %s Len: %s Status: %s Data: %s" % (
MsgDataSQN, MsgDataShAddr, MsgDataLenght, MsgDataStatus, MsgData), )
if MsgDataShAddr not in self.ListOfDevices:
self.log.logging( "Input", "Log", "Decode8043 receives a message from a non existing device %s" % MsgDataShAddr, )
return

if "SQN" in self.ListOfDevices[MsgDataShAddr] and MsgDataSQN == self.ListOfDevices[MsgDataShAddr]["SQN"]:
return

inDB_status = self.ListOfDevices[MsgDataShAddr].get("Status", None) == "inDB"

if int(MsgDataLenght, 16) == 0:
return
if MsgDataStatus != '00':
Expand Down Expand Up @@ -2085,13 +2084,13 @@ def Decode8043(self, Devices, MsgData, MsgLQI): # Reception Simple descriptor r
MsgDataProfile, MsgDataDeviceId), )
if MsgDataEp in self.ListOfDevices[MsgDataShAddr]["Ep"]:
del self.ListOfDevices[MsgDataShAddr]["Ep"][MsgDataEp]
if "NbEp" in self.ListOfDevices[MsgDataShAddr]:
if self.ListOfDevices[MsgDataShAddr]["NbEp"] > "1":
self.ListOfDevices[MsgDataShAddr]["NbEp"] = int(self.ListOfDevices[MsgDataShAddr]["NbEp"]) - 1
if "NbEp" in self.ListOfDevices[MsgDataShAddr] and self.ListOfDevices[MsgDataShAddr]["NbEp"] > "1":
self.ListOfDevices[MsgDataShAddr]["NbEp"] = int(self.ListOfDevices[MsgDataShAddr]["NbEp"]) - 1
return

self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Simple Descriptor Response EP: 0x%s LQI: %s" % (
"-", MsgDataShAddr, MsgDataEp, int(MsgLQI, 16)), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Simple Descriptor Response EP: 0x%s LQI: %s" % (
"-", MsgDataShAddr, MsgDataEp, int(MsgLQI, 16)), )

# Endpoint V2 (ProfileID and ZDeviceID)
if "Epv2" not in self.ListOfDevices[MsgDataShAddr]:
Expand All @@ -2109,32 +2108,36 @@ def Decode8043(self, Devices, MsgData, MsgLQI): # Reception Simple descriptor r
if self.ListOfDevices[MsgDataShAddr]["ProfileID"] != MsgDataProfile:
pass
self.ListOfDevices[MsgDataShAddr]["ProfileID"] = MsgDataProfile
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s ProfileID %s" % (
"-", MsgDataShAddr, MsgDataProfile), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s ProfileID %s" % (
"-", MsgDataShAddr, MsgDataProfile), )

if "ZDeviceID" in self.ListOfDevices[MsgDataShAddr]:
if self.ListOfDevices[MsgDataShAddr]["ZDeviceID"] != MsgDataDeviceId:
pass

self.ListOfDevices[MsgDataShAddr]["ZDeviceID"] = MsgDataDeviceId
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s ZDeviceID %s" % (
"-", MsgDataShAddr, MsgDataDeviceId), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s ZDeviceID %s" % (
"-", MsgDataShAddr, MsgDataDeviceId), )

# Decode Bit Field
# Device version: 4 bits (bits 0-4)
# eserved: 4 bits (bits4-7)
DeviceVersion = int(MsgDataBField, 16) & 0x00001111
self.ListOfDevices[MsgDataShAddr]["ZDeviceVersion"] = "%04x" % DeviceVersion
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Application Version %s" % (
"-", MsgDataShAddr, self.ListOfDevices[MsgDataShAddr]["ZDeviceVersion"]), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Application Version %s" % (
"-", MsgDataShAddr, self.ListOfDevices[MsgDataShAddr]["ZDeviceVersion"]), )

configSourceAvailable = False
if "ConfigSource" in self.ListOfDevices[MsgDataShAddr]:
if self.ListOfDevices[MsgDataShAddr]["ConfigSource"] == "DeviceConf":
configSourceAvailable = True
if "ConfigSource" in self.ListOfDevices[MsgDataShAddr] and self.ListOfDevices[MsgDataShAddr]["ConfigSource"] == "DeviceConf":
configSourceAvailable = True

# Decoding Cluster IN
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster IN Count: %s" % (
"-", MsgDataShAddr, MsgDataInClusterCount), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster IN Count: %s" % (
"-", MsgDataShAddr, MsgDataInClusterCount), )
idx = 24
i = 1
if int(MsgDataInClusterCount, 16) > 0:
Expand All @@ -2161,23 +2164,25 @@ def Decode8043(self, Devices, MsgData, MsgLQI): # Reception Simple descriptor r
if MsgDataCluster not in self.ListOfDevices[MsgDataShAddr]["Epv2"][MsgDataEp]["ClusterIn"]:
self.ListOfDevices[MsgDataShAddr]["Epv2"][MsgDataEp]["ClusterIn"][MsgDataCluster] = {}

if MsgDataCluster in ZCL_CLUSTERS_LIST:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster In %s: %s (%s)" % (
"-", MsgDataShAddr, i, MsgDataCluster, ZCL_CLUSTERS_LIST[MsgDataCluster], ), )
else:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster In %s: %s" % (
"-", MsgDataShAddr, i, MsgDataCluster), )
i = i + 1
if not inDB_status:
if MsgDataCluster in ZCL_CLUSTERS_LIST:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster In %s: %s (%s)" % (
"-", MsgDataShAddr, i, MsgDataCluster, ZCL_CLUSTERS_LIST[MsgDataCluster], ), )
else:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster In %s: %s" % (
"-", MsgDataShAddr, i, MsgDataCluster), )
i += 1

# Decoding Cluster Out
idx = 24 + int(MsgDataInClusterCount, 16) * 4
MsgDataOutClusterCount = MsgData[idx : idx + 2]

self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster OUT Count: %s" % (
"-", MsgDataShAddr, MsgDataOutClusterCount), )
if not inDB_status:
self.log.logging( "Input", "Status", "[%s] NEW OBJECT: %s Cluster OUT Count: %s" % (
"-", MsgDataShAddr, MsgDataOutClusterCount), )

idx += 2
i = 1

if int(MsgDataOutClusterCount, 16) > 0:
while i <= int(MsgDataOutClusterCount, 16):
MsgDataCluster = MsgData[idx + ((i - 1) * 4) : idx + (i * 4)]
Expand All @@ -2198,21 +2203,21 @@ def Decode8043(self, Devices, MsgData, MsgLQI): # Reception Simple descriptor r
if MsgDataCluster not in self.ListOfDevices[MsgDataShAddr]["Epv2"][MsgDataEp]["ClusterOut"]:
self.ListOfDevices[MsgDataShAddr]["Epv2"][MsgDataEp]["ClusterOut"][MsgDataCluster] = {}

if MsgDataCluster in ZCL_CLUSTERS_LIST:
self.log.logging("Input","Status","[%s] NEW OBJECT: %s Cluster Out %s: %s (%s)"% (
"-",MsgDataShAddr,i,MsgDataCluster,ZCL_CLUSTERS_LIST[MsgDataCluster],),)
else:
self.log.logging("Input","Status","[%s] NEW OBJECT: %s Cluster Out %s: %s" % (
"-", MsgDataShAddr, i, MsgDataCluster),)
if not inDB_status:
if MsgDataCluster in ZCL_CLUSTERS_LIST:
self.log.logging("Input","Status","[%s] NEW OBJECT: %s Cluster Out %s: %s (%s)"% (
"-",MsgDataShAddr,i,MsgDataCluster,ZCL_CLUSTERS_LIST[MsgDataCluster],),)
else:
self.log.logging("Input","Status","[%s] NEW OBJECT: %s Cluster Out %s: %s" % (
"-", MsgDataShAddr, i, MsgDataCluster),)

MsgDataCluster = ""
i = i + 1
i += 1

# Let's check if there is any other Ep to be disxcovered
if request_next_Ep(self, MsgDataShAddr):
if self.ListOfDevices[MsgDataShAddr]["Status"] != "inDB":
self.ListOfDevices[MsgDataShAddr]["Status"] = "8043"
self.ListOfDevices[MsgDataShAddr]["Heartbeat"] = "0"
if request_next_Ep(self, MsgDataShAddr) and not inDB_status:
self.ListOfDevices[MsgDataShAddr]["Status"] = "8043"
self.ListOfDevices[MsgDataShAddr]["Heartbeat"] = "0"

self.log.logging("Pairing","Debug","Decode8043 - Processed " + MsgDataShAddr + " end results is: " + str(self.ListOfDevices[MsgDataShAddr]),)

Expand Down Expand Up @@ -2406,7 +2411,7 @@ def Decode8048(self, Devices, MsgData, MsgLQI): # Leave indication
# Will set to Leave in order to protect Domoticz Widget, Just need to make sure that we can reconnect at a point of time
self.ListOfDevices[sAddr]["Status"] = "Leave"
self.ListOfDevices[sAddr]["Heartbeat"] = 0
self.log.logging("Input", "Error", "Receiving a leave from %s/%s while device is %s status" % (
self.log.logging("Input", "Error", "Receiving a leave from %s/%s while device is '%s' status." % (
sAddr, MsgExtAddress, self.ListOfDevices[sAddr]["Status"]))

zdevname = ""
Expand Down
6 changes: 3 additions & 3 deletions Modules/pluginModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def plugin_self_identifier( self, model, manufacturer):
return None

def check_found_plugin_model( self, model, manufacturer_name=None, manufacturer_code=None, device_id=None):
self.log.logging( "Pairing", "Log", "check_found_plugin_model - %s %s %s %s" % (
self.log.logging( "Pairing", "Debug", "check_found_plugin_model - %s %s %s %s" % (
model, manufacturer_name, manufacturer_code, device_id))

# Let's check if
Expand All @@ -40,10 +40,10 @@ def check_found_plugin_model( self, model, manufacturer_name=None, manufacturer_
):
continue

self.log.logging( "Pairing", "Log", "check_found_plugin_model - Found %s" % x)
self.log.logging( "Pairing", "Debug", "check_found_plugin_model - Found %s" % x)

if "PluginModelName" in x:
self.log.logging( "Pairing", "Log", "check_found_plugin_model - return %s" % (
self.log.logging( "Pairing", "Debug", "check_found_plugin_model - return %s" % (
x["PluginModelName"]))

return x["PluginModelName"]
Expand Down

0 comments on commit 0308e50

Please sign in to comment.