Skip to content
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
4 changes: 4 additions & 0 deletions bundles/org.openhab.binding.mqtt.homeassistant/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ Parts of this code (src/main/python/) have been forked.
* License: Apache License 2.0
* Project: https://www.home-assistant.io/
* Source: https://github.com/home-assistant/core

Parts of this code (src/main/python/voluptuous/) have been forked:
* License: BSD 3-Clause
* Source: https://github.com/alecthomas/voluptuous
11 changes: 4 additions & 7 deletions bundles/org.openhab.binding.mqtt.homeassistant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<name>openHAB Add-ons :: Bundles :: MQTT HomeAssistant Convention</name>

<properties>
<graalpy.version>24.2.1</graalpy.version>
<!-- define a property to overwrite it on Windows, as venv has a different structure -->
<graalpy.executable>bin/python3</graalpy.executable>
</properties>
Expand All @@ -38,7 +37,7 @@
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>org.graalvm.polyglot.polyglot</artifactId>
<version>${graalpy.version}</version>
<version>${graalvm.version}</version>
<!-- provided as OSGi bundle at runtime, available only at compile time -->
<scope>provided</scope>
</dependency>
Expand All @@ -49,15 +48,15 @@
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>python-community</artifactId>
<version>${graalpy.version}</version>
<version>${graalvm.version}</version>
<type>pom</type>
<!-- provided as OSGi bundle at runtime, available only at compile time -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>org.graalvm.python.python-embedding</artifactId>
<version>${graalpy.version}</version>
<version>${graalvm.version}</version>
<!-- provided as OSGi bundle at runtime, available only at compile time -->
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -131,7 +130,7 @@
<plugin>
<groupId>org.graalvm.python</groupId>
<artifactId>graalpy-maven-plugin</artifactId>
<version>${graalpy.version}</version>
<version>${graalvm.version}</version>
<executions>
<execution>
<id>install-python-packages</id>
Expand All @@ -144,7 +143,6 @@
<package>awesomeversion==24.6.0</package>
<package>Jinja2==3.1.6</package>
<package>python-slugify==8.0.4</package>
<package>voluptuous==0.15.2</package>
</packages>
</configuration>
</execution>
Expand All @@ -160,7 +158,6 @@
<package>awesomeversion==24.6.0</package>
<package>Jinja2==3.1.6</package>
<package>python-slugify==8.0.4</package>
<package>voluptuous==0.15.2</package>
</packages>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-mqtt</feature>
<feature dependency="true">openhab.tp-commons-net</feature>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.llvm.llvm-api/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.polyglot.polyglot/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.python.python-embedding/24.2.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.python.python-language/24.2.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.python.python-resources/24.2.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.regex.regex/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.collections/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.jniutils/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.nativeimage/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.word/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.icu4j/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.json/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.xz/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.tools.profiler-tool/24.2.1</bundle>
<bundle dependency="true" start-level="79">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-api/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-compiler/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-nfi/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-runtime/24.2.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.llvm.llvm-api/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.polyglot.polyglot/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.python.python-embedding/25.0.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.python.python-language/25.0.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.python.python-resources/25.0.1</bundle>
<bundle dependency="true" start-level="78">mvn:org.openhab.osgiify/org.graalvm.regex.regex/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.collections/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.jniutils/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.nativeimage/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.word/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.icu4j/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.json/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.xz/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.tools.profiler-tool/25.0.1</bundle>
<bundle dependency="true" start-level="79">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-api/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-compiler/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-nfi/25.0.1</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-runtime/25.0.1</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version}</bundle>
<bundle start-level="81">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.generic/${project.version}</bundle>
<bundle start-level="82">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.homeassistant/${project.version}</bundle>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""Schema validation for Python data structures.

Given eg. a nested data structure like this:

{
'exclude': ['Users', 'Uptime'],
'include': [],
'set': {
'snmp_community': 'public',
'snmp_timeout': 15,
'snmp_version': '2c',
},
'targets': {
'localhost': {
'exclude': ['Uptime'],
'features': {
'Uptime': {
'retries': 3,
},
'Users': {
'snmp_community': 'monkey',
'snmp_port': 15,
},
},
'include': ['Users'],
'set': {
'snmp_community': 'monkeys',
},
},
},
}

A schema like this:

>>> settings = {
... 'snmp_community': str,
... 'retries': int,
... 'snmp_version': All(Coerce(str), Any('3', '2c', '1')),
... }
>>> features = ['Ping', 'Uptime', 'Http']
>>> schema = Schema({
... 'exclude': features,
... 'include': features,
... 'set': settings,
... 'targets': {
... 'exclude': features,
... 'include': features,
... 'features': {
... str: settings,
... },
... },
... })

Validate like so:

>>> schema({
... 'set': {
... 'snmp_community': 'public',
... 'snmp_version': '2c',
... },
... 'targets': {
... 'exclude': ['Ping'],
... 'features': {
... 'Uptime': {'retries': 3},
... 'Users': {'snmp_community': 'monkey'},
... },
... },
... }) == {
... 'set': {'snmp_version': '2c', 'snmp_community': 'public'},
... 'targets': {
... 'exclude': ['Ping'],
... 'features': {'Uptime': {'retries': 3},
... 'Users': {'snmp_community': 'monkey'}}}}
True
"""

# flake8: noqa
# fmt: off
from voluptuous.schema_builder import *
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import pollutes the enclosing namespace, as the imported module voluptuous.schema_builder does not define 'all'.

Suggested change
from voluptuous.schema_builder import *
from voluptuous.schema_builder import Schema, All, Any, Optional, Required, Exclusive, Inclusive, PREVENT_EXTRA, REMOVE_EXTRA, ALLOW_EXTRA, Extra, Invalid, MultipleInvalid

Copilot uses AI. Check for mistakes.
from voluptuous.util import *
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import pollutes the enclosing namespace, as the imported module voluptuous.util does not define 'all'.

Suggested change
from voluptuous.util import *
from voluptuous.util import is_sequence, iter_sequence, flatten # Replace with actual used symbols

Copilot uses AI. Check for mistakes.
from voluptuous.validators import *
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import pollutes the enclosing namespace, as the imported module voluptuous.validators does not define 'all'.

Suggested change
from voluptuous.validators import *
from voluptuous.validators import (
All, Any, Coerce, ExactSequence, In, Length, Lower, Match, Maybe, Msg, NotIn, Number, Optional, Range, Required, Schema, Self, Upper, ALLOW_EXTRA, REMOVE_EXTRA, PREVENT_EXTRA
)

Copilot uses AI. Check for mistakes.

from voluptuous.error import * # isort: skip
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import pollutes the enclosing namespace, as the imported module voluptuous.error does not define 'all'.

Suggested change
from voluptuous.error import * # isort: skip
from voluptuous.error import Error, MultipleInvalid, Invalid # isort: skip

Copilot uses AI. Check for mistakes.

# fmt: on

__version__ = '0.15.2'
__author__ = 'alecthomas'
Loading