Skip to content

Commit

Permalink
Add (C) header and sort import
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Oct 29, 2024
1 parent 3289525 commit c84b12f
Show file tree
Hide file tree
Showing 72 changed files with 742 additions and 123 deletions.
28 changes: 13 additions & 15 deletions Classes/AdminWidgets.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
"""
Class: AdminWidget.py
Description: Manage the Admistration Widget available on Domoticz
"""
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

from Modules.domoticzAbstractLayer import (
FreeUnit, domo_create_api, domo_read_nValue_sValue, domo_update_api,
Expand All @@ -32,11 +32,11 @@ def _get_switch_selector_options(self, ):
}

return {
"LevelActions": "|||||||",
"LevelNames": "Off|Purge Reports|Soft Reset|One Time Enrolmennt|Perm. Enrollment|Interf Scan|LQI Report",
"LevelOffHidden": "true",
"SelectorStyle": "0",
}
"LevelActions": "|||||||",
"LevelNames": "Off|Purge Reports|Soft Reset|One Time Enrolmennt|Perm. Enrollment|Interf Scan|LQI Report",
"LevelOffHidden": "true",
"SelectorStyle": "0",
}

class AdminWidgets:
def __init__(self, log, PluginConf, pluginParameters, ListOfDomoticzWidget, Devices, ListOfDevices, HardwareID, IEEE2NWK):
Expand Down Expand Up @@ -146,5 +146,3 @@ def updateNotificationWidget(self, Devices, notification):

def handleCommand(self, Command):
return


20 changes: 10 additions & 10 deletions Classes/DomoticzDB.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
"""
Module: z_DomoticzDico.py
Description: Retreive & Build Domoticz Dictionary
"""
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license


import base64
import binascii
import json
import socket
import ssl
import time
import urllib.request
import ssl

from Modules.restartPlugin import restartPluginViaDomoticzJsonApi
from Classes.LoggingManagement import LoggingManagement
from Modules.restartPlugin import restartPluginViaDomoticzJsonApi
from Modules.tools import is_domoticz_new_API

CACHE_TIMEOUT = (15 * 60) + 15 # num seconds
Expand Down
14 changes: 8 additions & 6 deletions Classes/IAS.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
"""
Module: z_IAS.py
Description: IAS Zone management
"""
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license


import struct
Expand Down
11 changes: 9 additions & 2 deletions Classes/NetworkEnergy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

#
# Module: NetworkEnergy.py
#
Expand Down
16 changes: 11 additions & 5 deletions Classes/NetworkMap.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

# Module: NetworkMap.py
#
# Description: Network Mapping based on LQI
Expand All @@ -26,12 +32,12 @@

import json
import os.path
from pathlib import Path
import time
from datetime import datetime
from pathlib import Path

from Modules.zb_tables_management import (mgmt_rtg, start_new_table_scan,
update_merge_new_device_to_last_entry)
from Modules.zb_tables_management import (
mgmt_rtg, start_new_table_scan, update_merge_new_device_to_last_entry)
from Zigbee.zdpCommands import zdp_NWK_address_request, zdp_nwk_lqi_request


Expand Down
1 change: 1 addition & 0 deletions Classes/OTA.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
Expand Down
11 changes: 9 additions & 2 deletions Classes/PluginConf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license


"""
Class PluginConf
Expand Down
11 changes: 8 additions & 3 deletions Classes/TransportStats.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#

# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import json
from time import time
Expand Down
13 changes: 10 additions & 3 deletions Classes/WebServer/WebServer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license


import json
import mimetypes
Expand All @@ -25,7 +32,7 @@
domoticz_log_api,
domoticz_status_api)
from Modules.sendZigateCommand import sendZigateCmd
from Modules.tools import is_hex, get_device_nickname
from Modules.tools import get_device_nickname, is_hex
from Modules.txPower import set_TxPower
from Modules.zigateCommands import zigate_set_mode
from Modules.zigateConsts import (CERTIFICATION_CODE, ZCL_CLUSTERS_LIST,
Expand Down
17 changes: 12 additions & 5 deletions Classes/WebServer/rest_recreateWidget.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: zaraki673 & pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
from time import time
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import json
from time import time

from Classes.WebServer.headerResponse import (prepResponseMessage,
setupHeadersResponse)
Expand Down Expand Up @@ -42,13 +49,13 @@ def rest_recreate_widgets(self, verb, data, parameters):
domoticz_error_api("rest_recreate_widgets - Unknown device %s " % key)
return _response
nwkid = self.IEEE2NWK[key]
_response["Data"] = json.dumps({"Status": "Ok", "Status": "IEEE %s set to Provisioning Requested at %s" % (key, int(time()))})
_response["Data"] = json.dumps({"Status": "Ok", "ExtraInfo": "IEEE %s set to Provisioning Requested at %s" % (key, int(time()))})
else:
nwkid = data["NWKID"]
if nwkid not in self.ListOfDevices:
domoticz_error_api("rest_recreate_widgets - Unknown device %s " % nwkid)
return _response
_response["Data"] = json.dumps({"Status": "Ok", "Status": "NwkId %s set to Provisioning Requested at %s" % (nwkid, int(time()))})
_response["Data"] = json.dumps({"Status": "Ok", "ExtraInfo": "NwkId %s set to Provisioning Requested at %s" % (nwkid, int(time()))})

over_write_type_from_deviceconf( self, self.Devices, nwkid)
self.ListOfDevices[nwkid]["Status"] = "CreateDB"
Expand Down
2 changes: 1 addition & 1 deletion Classes/ZigpyTopology.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import json
import os.path
import time
import traceback
from pathlib import Path
import time

import zigpy.types as t

Expand Down
13 changes: 10 additions & 3 deletions Classes/ZigpyTransport/Transport.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# coding: utf-8 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author: pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import json
import time
Expand Down Expand Up @@ -156,4 +163,4 @@ def loadTransmit(self):
_queue = sum(self._currently_waiting_requests_list[device] + 1 for device in list(self._currently_waiting_requests_list) if self._concurrent_requests_semaphores_list[device].locked())
_ret_value = max(_queue - 1, 0) + self.writer_queue.qsize()
self.log.logging("Transport", "Debug", "Load: PluginQueue: %3s ZigpyQueue: %3s => %s" %(self.writer_queue.qsize(), _queue, _ret_value ))
return _ret_value
return _ret_value
10 changes: 8 additions & 2 deletions Classes/ZigpyTransport/forwarderThread.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env python3
# coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Author: pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import queue
from threading import Thread
Expand Down
13 changes: 10 additions & 3 deletions Classes/ZigpyTransport/instrumentation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# coding: utf-8 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author: pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import time
import os.path
import time
from pathlib import Path

instrument_time = True
Expand Down
12 changes: 10 additions & 2 deletions Classes/ZigpyTransport/plugin_encoders.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# coding: utf-8 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author: pipiche38
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import binascii
import time

import zigpy.types as t

from Zigbee.encoder_tools import encapsulate_plugin_frame


Expand Down
32 changes: 9 additions & 23 deletions Classes/ZigpyTransport/tools.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@

# coding: utf-8 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Implementation of Zigbee for Domoticz plugin.
#
# This file is part of Zigbee for Domoticz plugin. https://github.com/zigbeefordomoticz/Domoticz-Zigbee
# (C) 2015-2024
#
# Author: pipiche38
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import traceback

#def handle_thread_error(self, e, data=""):
# trace = []
# tb = e.__traceback__
# self.log.logging("TransportWrter", "Error", "Issue in request, dumping stack")
# self.log.logging("TransportWrter", "Error", "==> %s" % data)
# self.log.logging("TransportWrter", "Error", "'%s' failed '%s'" % (tb.tb_frame.f_code.co_name, str(e)))
# while tb is not None:
# self.log.logging(
# "TransportWrter",
# "Error",
# "----> Line %s in '%s', function %s"
# % (
# tb.tb_lineno,
# tb.tb_frame.f_code.co_filename,
# tb.tb_frame.f_code.co_name,
# ),
# )
# tb = tb.tb_next


def handle_thread_error(self, e, data=""):

context = {
Expand Down
Loading

0 comments on commit c84b12f

Please sign in to comment.