From 093aef1dc1729a1d1083fb99bd9b21b7229dd57e Mon Sep 17 00:00:00 2001 From: SukramJ Date: Wed, 18 Dec 2024 11:29:53 +0100 Subject: [PATCH] Update project setup --- .gitignore | 1 + README.md | 2 +- pydevccu/ccu.py | 13 ++++++------ pydevccu/get_device_data.py | 4 ++-- pyproject.toml | 41 +++++++++++++++++++++++++++++++++++++ setup.cfg | 2 ++ setup.py | 34 ------------------------------ start.py | 13 ++++++++++++ start_1.py | 13 ++++++++++++ 9 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 start.py create mode 100644 start_1.py diff --git a/.gitignore b/.gitignore index b22d45f..9b4b0b2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ venv paramsets_db.json start* .idea +/build diff --git a/README.md b/README.md index eef1a90..a77b758 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The main objective is to provide you access to all available devices without own The `init` method used to subscribe to events is available and functional. Events will be fired when you use the `setValue` or `putParamset` methods to change parameters of a device. -When adding the `logic` argument while creating the server-object, modules found in _device\_logic_ will be loaded depending on which devices are enabled. For example: the module [HM_Sec_SC_2.py](https://github.com/danielperna84/pydevccu/blob/master/pydevccu/device_logic/HM_Sec_SC_2.py) fires two events at the specified _interval_. The `STATE` toggles with every event, and `LOWBAT` gets toggled every 5 events. +When adding the `logic` argument while creating the server-object, modules found in _device\_logic_ will be loaded depending on which devices are enabled. For example: the module [HM_Sec_SC_2.py](https://github.com/sukramj/pydevccu/blob/master/pydevccu/device_logic/HM_Sec_SC_2.py) fires two events at the specified _interval_. The `STATE` toggles with every event, and `LOWBAT` gets toggled every 5 events. The _startupdelay_ randomizes when the eventloop will initially start from 0 to _startupdelay_ seconds. This is to prevent multiple devices from firing their events at the same time. ## Methods diff --git a/pydevccu/ccu.py b/pydevccu/ccu.py index 3f7b15e..ce15bdd 100644 --- a/pydevccu/ccu.py +++ b/pydevccu/ccu.py @@ -251,12 +251,13 @@ def putParamset(self, address, paramset_key, paramset, force=False): if param_type == const.PARAMSET_TYPE_FLOAT: value = float(value) if param_type == const.PARAMSET_TYPE_ENUM: - if value > float(param_data[const.PARAMSET_ATTR_MAX]): - LOG.warning("RPCFunctions.putParamset: address=%s, value_key=%s: value too high", address, value_key) - raise Exception - if value < float(param_data[const.PARAMSET_ATTR_MIN]): - LOG.warning("RPCFunctions.putParamset: address=%s, value_key=%s: value too low", address, value_key) - raise Exception + if not isinstance(param_data[const.PARAMSET_ATTR_MAX], str): + if value > float(param_data[const.PARAMSET_ATTR_MAX]): + LOG.warning("RPCFunctions.putParamset: address=%s, value_key=%s: value too high", address, value_key) + raise Exception + if value < float(param_data[const.PARAMSET_ATTR_MIN]): + LOG.warning("RPCFunctions.putParamset: address=%s, value_key=%s: value too low", address, value_key) + raise Exception if param_type in [const.PARAMSET_TYPE_FLOAT, const.PARAMSET_TYPE_INTEGER]: special = param_data.get(const.PARAMSET_ATTR_SPECIAL, []) valid = [] diff --git a/pydevccu/get_device_data.py b/pydevccu/get_device_data.py index 3c2d4ea..b8b0231 100644 --- a/pydevccu/get_device_data.py +++ b/pydevccu/get_device_data.py @@ -7,8 +7,8 @@ - paramset_descriptions Post these files at https://gist.github.com/ to assist device implementation -for pyhomematic (https://github.com/danielperna84/pyhomematic) and / or create -a pull request at https://github.com/danielperna84/pydevccu to increase +for hahomematic (https://github.com/sukramj/hahomematic) and / or create +a pull request at https://github.com/sukramj/pydevccu to increase device coverage if data for your device is not yet available in the repository. Set CCU_IP to the IP address of your CCU. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..252ee8e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,41 @@ +[build-system] +requires = ["setuptools==75.6.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "pydevccu" +version = "0.1.9" +license = {text = "MIT License"} +description = "Virtual HomeMatic CCU XML-RPC backend." +readme = "README.md" +authors = [ + {name = "Daniel Perna", email = "danielperna84@gmail.com"}, + {name = "SukramJ", email = "sukramj@icloud.com"}, +] +keywords = ["homematic", "ccu", "xml-rpc"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Home Automation", +] +requires-python = ">=3.12.0" + +[project.urls] +"Source Code" = "https://github.com/sukramj/pydevccu" +"Bug Reports" = "https://github.com/sukramj/pydevccu/issues" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +include = ["pydevccu*"] +exclude = ["tests", "tests.*", "dist", "build"] + +[tool.setuptools.package-data] +pydevccu = ["py.typed", "*/*.json"] + + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6554091 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +url = https://github.com/sukramj/pydevccu diff --git a/setup.py b/setup.py deleted file mode 100644 index 62fd3a2..0000000 --- a/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -import os -from setuptools import setup, find_packages - -PACKAGE_NAME = 'pydevccu' -HERE = os.path.abspath(os.path.dirname(__file__)) -VERSION = '0.1.8' - -PACKAGES = find_packages(exclude=['tests', 'tests.*', 'dist', 'build']) - -REQUIRES = [] - -setup( - name=PACKAGE_NAME, - version=VERSION, - license='MIT License', - url='https://github.com/danielperna84/pydevccu', - download_url='https://github.com/danielperna84/pydevccu/tarball/'+VERSION, - author='Daniel Perna', - author_email='danielperna84@gmail.com', - description='Virtual HomeMatic CCU XML-RPC backend', - packages=PACKAGES, - include_package_data=True, - zip_safe=False, - platforms='any', - install_requires=REQUIRES, - keywords=['homematic', 'ccu', 'xml-rpc'], - classifiers=[ - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.5', - 'Topic :: Home Automation' - ], -) diff --git a/start.py b/start.py new file mode 100644 index 0000000..1cdf3a2 --- /dev/null +++ b/start.py @@ -0,0 +1,13 @@ +import pydevccu +# Create server that listens on 127.0.0.1:2001 +# To listen on another address initialize with ("1.2.3.4", 1234) as first argument +# Add optional list of device names to only load these devices +# Enable paramset persistance (will be saved to paramset_db.json) +# Enable automated device logic (only if module for device is available), firing events at intervals of 30 seconds +#s = pydevccu.Server(devices=['HM-Sec-WDS'], persistance=True, logic={"startupdelay": 5, "interval": 30}) + +s = pydevccu.Server(persistance=True, logic={"startupdelay": 5, "interval": 30}) +# devices=['HmIP-DLD'] +# Start server +s.start() + diff --git a/start_1.py b/start_1.py new file mode 100644 index 0000000..7d26b4d --- /dev/null +++ b/start_1.py @@ -0,0 +1,13 @@ +import pydevccu +# Create server that listens on 127.0.0.1:2001 +# To listen on another address initialize with ("1.2.3.4", 1234) as first argument +# Add optional list of device names to only load these devices +# Enable paramset persistance (will be saved to paramset_db.json) +# Enable automated device logic (only if module for device is available), firing events at intervals of 30 seconds +#s = pydevccu.Server(devices=['HM-Sec-WDS'], persistance=True, logic={"startupdelay": 5, "interval": 30}) + +s = pydevccu.Server(devices=['HmIP-RGBW', 'HM-TC-IT-WM-W-EU', 'HBW-LC-RGBWW-IN6-DR'], persistance=True, logic={"startupdelay": 5, "interval": 30}) +# devices=['HmIP-DLD'] +# Start server +s.start() +