Skip to content

Commit

Permalink
Update project setup
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Dec 18, 2024
1 parent 62a7049 commit 093aef1
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ venv
paramsets_db.json
start*
.idea
/build
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions pydevccu/ccu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions pydevccu/get_device_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
{name = "SukramJ", email = "[email protected]"},
]
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"]


2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
url = https://github.com/sukramj/pydevccu
34 changes: 0 additions & 34 deletions setup.py

This file was deleted.

13 changes: 13 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
@@ -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()

13 changes: 13 additions & 0 deletions start_1.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 093aef1

Please sign in to comment.