Skip to content

Commit

Permalink
Merge branch 'stable7' into wip-develop-7.2-2025
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 authored Dec 28, 2024
2 parents 24161f6 + bfd6892 commit e196ad2
Show file tree
Hide file tree
Showing 27 changed files with 503 additions and 267 deletions.
2 changes: 1 addition & 1 deletion .hidden/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"branch": "wip-develop-7.2-2025", "version": "7.2.106"}
{"branch": "wip-develop-7.2-2025", "version": "7.2.106"}
3 changes: 2 additions & 1 deletion Classes/PluginConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"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, },
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": 1,"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 @@ -552,6 +552,7 @@ def _load_Settings(self):

if dz_timestamp != 0:
Domoticz.Log( "Plugin data loaded where saved on %s" % (time.strftime("%A, %Y-%m-%d %H:%M:%S", time.localtime(dz_timestamp))) )

if not isinstance(_domoticz_pluginConf, dict):
_domoticz_pluginConf = {}

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
223 changes: 112 additions & 111 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
9 changes: 9 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Release Numbering
- Odd numbers --> Stable/7
- Even numbers --> Beta/7 (dev branch)

## Dec. 2024 - stavle7.1.018 (2024.10)

- [WebUI] - disable WebUI analytics as it is replaced by an embedded one in the plugin itself.
- [WebUI] - dedicated REST API for updating device parameters. ( PR #1813 , on request of @wvries)

- [Technical] - Handle PYTHONPATH during the plugin automatic upgrade
- [Technical] - Better error management when reading plugin database from domoticz. (could allow downgrade from futur version storing database in domoticz)


## Dec. 2024 - stable7.1.017 (2024.09)

- [Issue] - Fix an issue with EZSP chipset ( KeyError: <XncpCommandId.undefined_0x03e8: 1000>)
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

0 comments on commit e196ad2

Please sign in to comment.