Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 7.1.018 #1818

Merged
merged 4 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Classes/PluginConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
"Services": {
"Order": 1,
"param": {
"MatomoOptIn": {"type": "bool","default": 1,"current": None,"restart": 0,"hidden": False,"Advanced": False,},
"enablegroupmanagement": { "type": "bool", "default": 0, "current": None, "restart": 1, "hidden": False, "Advanced": False, },
"enableReadAttributes": { "type": "bool", "default": 0, "current": None, "restart": 1, "hidden": True, "Advanced": True, },
"internetAccess": { "type": "bool", "default": 1, "current": None, "restart": 1, "hidden": False, "Advanced": False, },
"CheckSSLCertificateValidity": { "type": "bool", "default": 0, "current": None, "restart": 1, "hidden": False, "Advanced": False, },
"allowOTA": { "type": "bool", "default": 1, "current": None, "restart": 1, "hidden": True, "Advanced": False, },
"pingDevices": { "type": "bool", "default": 1, "current": None, "restart": 1, "hidden": False, "Advanced": True, },
"PluginAnalytics": { "type": "bool", "default": -1, "current": None, "restart": 0, "hidden": False, "Advanced": False, },
"PluginAnalytics": { "type": "bool", "default": -1, "current": None, "restart": 0, "hidden": True, "Advanced": False, },
"DomoticzCustomMenu": { "type": "bool", "default": 1, "current": None, "restart": 1, "hidden": False, "Advanced": False, },
"NightShift": { "type": "bool", "default": 0, "current": None, "restart": 0, "hidden": False, "Advanced": False, }
},
Expand Down Expand Up @@ -202,7 +203,6 @@
"PluginConfiguration": {
"Order": 12,
"param": {
"MatomoOptIn": {"type": "bool","default": 1,"current": None,"restart": 0,"hidden": False,"Advanced": True,},
"PosixPathUpdate": {"type": "bool","default": 1,"current": None,"restart": 0,"hidden": True,"Advanced": True,},
"storeDomoticzDatabase": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,},
"useDomoticzDatabase": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,},
Expand Down Expand Up @@ -547,8 +547,8 @@ def _load_Settings(self):
if is_domoticz_db_available(self):
_domoticz_pluginConf = getConfigItem(Key="PluginConf")
if "TimeStamp" in _domoticz_pluginConf:
dz_timestamp = _domoticz_pluginConf["TimeStamp"]
_domoticz_pluginConf = _domoticz_pluginConf["b64Settings"]
dz_timestamp = _domoticz_pluginConf.get("TimeStamp",0)
_domoticz_pluginConf = _domoticz_pluginConf.get("b64Settings",{})
Domoticz.Log(
"Plugin data loaded where saved on %s"
% (time.strftime("%A, %Y-%m-%d %H:%M:%S", time.localtime(dz_timestamp)))
Expand Down
4 changes: 2 additions & 2 deletions Classes/WebServer/WebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
domoticz_error_api,
domoticz_log_api,
domoticz_status_api)
from Modules.matomo_request import (matomo_opt_in_action,
matomo_opt_out_action)
from Modules.matomo_request import matomo_opt_in_action, matomo_opt_out_action
from Modules.sendZigateCommand import sendZigateCmd
from Modules.tools import get_device_nickname, is_hex
from Modules.txPower import set_TxPower
Expand Down Expand Up @@ -86,6 +85,7 @@ class WebServer(object):
from Classes.WebServer.rest_CfgReporting import (
rest_cfgrpt_ondemand, rest_cfgrpt_ondemand_with_config)
from Classes.WebServer.rest_change_ModelName import rest_change_model_name
from Classes.WebServer.rest_device_params import rest_device_param
from Classes.WebServer.rest_Device_Settings_Help import \
rest_device_settings_help
from Classes.WebServer.rest_Energy import (rest_req_nwk_full,
Expand Down
222 changes: 112 additions & 110 deletions Classes/WebServer/dispatcher.py

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Classes/WebServer/rest_PluginUpgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import subprocess # nosec
from pathlib import Path
import sys

import distro
import z4d_certified_devices
Expand All @@ -35,10 +36,14 @@ def rest_plugin_upgrade(self, verb, data, parameters):
pluginFolder = Path(self.pluginParameters["HomeFolder"])
upgrade_script = str( pluginFolder / PLUGIN_UPGRADE_SCRIPT)

# Identify the current Python version
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
self.logging("Log", f"Current Python version: {python_version}")

self.logging("Log", "Plugin Upgrade starting: %s" %(upgrade_script))

process = subprocess.run(
upgrade_script ,
f"{upgrade_script} {python_version}",
cwd=self.pluginParameters["HomeFolder"],
universal_newlines=True,
text=True,
Expand Down
94 changes: 94 additions & 0 deletions Classes/WebServer/rest_device_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/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
#
# Initial authors: zaraki673 & pipiche38
#
# SPDX-License-Identifier: GPL-3.0 license

import json
from time import time

from Classes.WebServer.headerResponse import (prepResponseMessage,
setupHeadersResponse)
from Modules.paramDevice import sanity_check_of_param


def rest_device_param(self, verb, data, parameters):

self.logging("Log", "rest_update_device_param -->Verb: %s Data: %s Parameters: %s" % (verb, data, parameters))
if verb == "GET":
return rest_get_device_param(self, parameters)

elif verb == "PUT":
return rest_update_device_param(self, data)

return prepResponseMessage(self, setupHeadersResponse())


def rest_get_device_param( self, parameters):

_response = prepResponseMessage(self, setupHeadersResponse())

if len(parameters) != 1:
return _log_and_return_with_error(self, "rest_get_device_param - unexpected parameter: %s", parameters, "unexpected parameter %s ", _response, )

nwkid = parameters[0]
if len(nwkid) == 16:
# We are assuming that is an ieee instead of nwkid
nwkid = self.IEEE2NWK.get( nwkid )

if nwkid not in self.ListOfDevices:
return _log_and_return_with_error(self, "rest_get_device_param - Unknown device %s ", nwkid, "unknown device %s ", _response, )
device_info = self.ListOfDevices.get( nwkid )
device_param = device_info.get("Param", "{}")

_response["Data"] = json.dumps(device_param, sort_keys=False)
return _response


def rest_update_device_param(self, data):

# curl -X PUT -d '{
# "Param": {'Disabled': 0, 'resetMotiondelay': 0, 'ConfigurationReportChunk': 3, 'ReadAttributeChunk': 4},
# "NWKID": "1234"
# }' http://127.0.0.1:9441/rest-z4d/1/device-param

_response = prepResponseMessage(self, setupHeadersResponse())

data = data.decode("utf8")
data = eval(data)
self.logging( "Log", "rest_update_device_param - Data: %s" % data)

parameter = data.get("Param")
nwkid = data.get("NWKID")
ieee = data.get("IEEE")

if nwkid is None and ieee is None:
return _log_and_return_with_error(self, "rest_update_device_param - missing IEEE or NWKID", "unexpected parameter %s ", _response, )

if ieee:
nwkid = self.IEEE2NWK.get( ieee )

if parameter is None or nwkid is None:
return _log_and_return_with_error(self, "rest_update_device_param - unexpected parameter: %s", data, "unexpected parameter %s ", _response, )
if nwkid not in self.ListOfDevices:
return _log_and_return_with_error(self, "rest_update_device_param - Unknown device %s ", nwkid, "unknown device %s ", _response, )
old_parameter = self.ListOfDevices[ nwkid ].get("Param")
_response["Data"] = {"NwkId %s set Param from: %s to %s" % (nwkid, old_parameter, parameter)}

self.ListOfDevices[ nwkid ]["Param"] = parameter

sanity_check_of_param(self, nwkid)

return _response


def _log_and_return_with_error(self, arg0, arg1, arg2, _response):
self.logging("Error", arg0 % arg1)
_response["Data"] = {arg2 % arg1}
return _response
4 changes: 2 additions & 2 deletions Modules/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def _read_DeviceList_Domoticz(self):
ListOfDevices_from_Domoticz = getConfigItem(Key="ListOfDevices", Attribute="Devices")
time_stamp = 0
if "TimeStamp" in ListOfDevices_from_Domoticz:
time_stamp = ListOfDevices_from_Domoticz["TimeStamp"]
ListOfDevices_from_Domoticz = ListOfDevices_from_Domoticz["Devices"]
time_stamp = ListOfDevices_from_Domoticz.get("TimeStamp",0)
ListOfDevices_from_Domoticz = ListOfDevices_from_Domoticz.get("Devices",{})
self.log.logging(
"Database",
"Log",
Expand Down
19 changes: 0 additions & 19 deletions Tools/big-clean-git.sh

This file was deleted.

6 changes: 0 additions & 6 deletions Tools/clean-git.sh

This file was deleted.

50 changes: 50 additions & 0 deletions Tools/cleaning-repository.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# This script performs a cleanup in the local repository to allow a git pull without issues.

# Ensure the script is run from the correct directory
if [ ! -d ".git" ]; then
echo "This script must be run from the root of the git repository."
exit 1
fi

# Warning message
echo "WARNING: This script will remove all local changes and reset the repository."
echo "If you have made any local updates, they will be removed."
read -p "Do you want to continue? (YES/no): " choice

if [ "$choice" != "YES" ]; then
echo "Operation cancelled."
exit 0
fi

echo ""
echo "Removing directories tracked by git, except Data, Conf, and OTAFirmware..."
# Remove directories tracked by git, except Data and Conf
for dir in $(git ls-tree -d --name-only HEAD); do
if [ "$dir" != "Data" ] && [ "$dir" != "Conf" ] && [ "$dir" != "OTAFirmware" ]; then
echo "Removing $dir..."
rm -rf "$dir"
fi
done

echo "Resetting the repository..."
git reset --hard

echo "Pulling the latest changes from the repository..."
git pull

echo ""
echo "Cleanup and update process completed."

echo ""
echo "Repository status:"
git status

echo ""
echo "Current branch:"
git branch --show-current

echo ""
echo "Latest commits:"
git log -n 5 --oneline
Loading
Loading