dbus2mqtt 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dbus2mqtt might be problematic. Click here for more details.
- dbus2mqtt/config/jsonarparse.py +2 -1
- dbus2mqtt/mqtt/mqtt_client.py +7 -7
- dbus2mqtt/template/templating.py +3 -2
- {dbus2mqtt-0.4.2.dist-info → dbus2mqtt-0.4.4.dist-info}/METADATA +16 -12
- {dbus2mqtt-0.4.2.dist-info → dbus2mqtt-0.4.4.dist-info}/RECORD +8 -8
- {dbus2mqtt-0.4.2.dist-info → dbus2mqtt-0.4.4.dist-info}/WHEEL +0 -0
- {dbus2mqtt-0.4.2.dist-info → dbus2mqtt-0.4.4.dist-info}/entry_points.txt +0 -0
- {dbus2mqtt-0.4.2.dist-info → dbus2mqtt-0.4.4.dist-info}/licenses/LICENSE +0 -0
dbus2mqtt/config/jsonarparse.py
CHANGED
|
@@ -13,7 +13,8 @@ def _custom_yaml_load(stream):
|
|
|
13
13
|
# Anoyingly, values starting with {{ and ending with }} are working with the default yaml_loader
|
|
14
14
|
# from jsonargparse. Somehow its not when we use the custom yaml loader.
|
|
15
15
|
# This fixes it
|
|
16
|
-
|
|
16
|
+
first_line = v.splitlines()[0].strip()
|
|
17
|
+
if "#" not in first_line and ("{{" in first_line or first_line.startswith("{%")):
|
|
17
18
|
return stream
|
|
18
19
|
|
|
19
20
|
# Delegate to default yaml loader from jsonargparse
|
dbus2mqtt/mqtt/mqtt_client.py
CHANGED
|
@@ -122,21 +122,21 @@ class MqttClient:
|
|
|
122
122
|
|
|
123
123
|
def on_message(self, client: mqtt.Client, userdata: Any, msg: mqtt.MQTTMessage):
|
|
124
124
|
|
|
125
|
-
# Skip retained messages
|
|
126
|
-
payload = msg.payload.decode()
|
|
127
|
-
if msg.retain:
|
|
128
|
-
logger.info(f"on_message: skipping msg with retain=True, topic={msg.topic}, payload={payload}")
|
|
129
|
-
return
|
|
130
|
-
|
|
131
125
|
# Skip messages being sent by other dbus2mqtt clients
|
|
132
126
|
if msg.properties:
|
|
133
127
|
user_properties: list[tuple[str, object]] = getattr(msg.properties, "UserProperty", [])
|
|
134
128
|
client_id = next((str(v) for k, v in user_properties if k == "client_id"), None)
|
|
135
129
|
if client_id and client_id != self.client_id:
|
|
136
|
-
logger.
|
|
130
|
+
logger.debug(f"on_message: skipping msg from another dbus2mqtt client, topic={msg.topic}, client_id={client_id}")
|
|
137
131
|
if client_id and client_id.startswith(self.client_id_prefix):
|
|
138
132
|
return
|
|
139
133
|
|
|
134
|
+
# Skip retained messages
|
|
135
|
+
payload = msg.payload.decode()
|
|
136
|
+
if msg.retain:
|
|
137
|
+
logger.info(f"on_message: skipping msg with retain=True, topic={msg.topic}, payload={payload}")
|
|
138
|
+
return
|
|
139
|
+
|
|
140
140
|
try:
|
|
141
141
|
json_payload = json.loads(payload) if payload else {}
|
|
142
142
|
logger.debug(f"on_message: msg.topic={msg.topic}, msg.payload={json.dumps(json_payload)}")
|
dbus2mqtt/template/templating.py
CHANGED
|
@@ -5,6 +5,7 @@ from typing import Any, TypeVar
|
|
|
5
5
|
|
|
6
6
|
from jinja2 import BaseLoader, StrictUndefined, TemplateError
|
|
7
7
|
from jinja2.nativetypes import NativeEnvironment
|
|
8
|
+
from jinja2_ansible_filters import AnsibleCoreFiltersExtension
|
|
8
9
|
|
|
9
10
|
TemplateResultType = TypeVar('TemplateResultType')
|
|
10
11
|
|
|
@@ -23,14 +24,14 @@ class TemplateEngine:
|
|
|
23
24
|
|
|
24
25
|
self.jinja2_env = NativeEnvironment(
|
|
25
26
|
loader=BaseLoader(),
|
|
26
|
-
extensions=[
|
|
27
|
+
extensions=[AnsibleCoreFiltersExtension],
|
|
27
28
|
undefined=StrictUndefined,
|
|
28
29
|
keep_trailing_newline=False
|
|
29
30
|
)
|
|
30
31
|
|
|
31
32
|
self.jinja2_async_env = NativeEnvironment(
|
|
32
33
|
loader=BaseLoader(),
|
|
33
|
-
extensions=[
|
|
34
|
+
extensions=[AnsibleCoreFiltersExtension],
|
|
34
35
|
undefined=StrictUndefined,
|
|
35
36
|
enable_async=True
|
|
36
37
|
)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbus2mqtt
|
|
3
|
-
Version: 0.4.
|
|
4
|
-
Summary:
|
|
5
|
-
Project-URL:
|
|
3
|
+
Version: 0.4.4
|
|
4
|
+
Summary: General purpose DBus to MQTT bridge - expose signals, methods and properties over MQTT - featuring jinja based templating, payload enrichment and MPRIS / BlueZ / Home Assistant ready examples
|
|
5
|
+
Project-URL: Documentation, https://jwnmulder.github.io/dbus2mqtt
|
|
6
|
+
Project-URL: Source, https://github.com/jwnmulder/dbus2mqtt
|
|
6
7
|
Project-URL: Issues, https://github.com/jwnmulder/dbus2mqtt/issues
|
|
7
8
|
License-Expression: MIT
|
|
8
9
|
License-File: LICENSE
|
|
9
|
-
Keywords: dbus,home-assistant,mpris,mqtt,python
|
|
10
|
-
Classifier: Development Status ::
|
|
10
|
+
Keywords: bluez,bridge,dbus,home-assistant,jinja2,mpris,mqtt,python
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
14
|
Classifier: Operating System :: POSIX :: Linux
|
|
@@ -16,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Home Automation
|
|
19
21
|
Requires-Python: >=3.10
|
|
20
22
|
Requires-Dist: apscheduler>=3.11.0
|
|
21
23
|
Requires-Dist: colorlog>=6.9.0
|
|
@@ -27,7 +29,7 @@ Requires-Dist: jsonargparse>=4.38.0
|
|
|
27
29
|
Requires-Dist: paho-mqtt>=2.1.0
|
|
28
30
|
Requires-Dist: pydantic>=2.11.3
|
|
29
31
|
Requires-Dist: python-dotenv>=1.1.0
|
|
30
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
31
33
|
Description-Content-Type: text/markdown
|
|
32
34
|
|
|
33
35
|
# dbus2mqtt
|
|
@@ -37,7 +39,7 @@ It lets you forward Linux D-Bus signals and properties to MQTT topics, call D-Bu
|
|
|
37
39
|
|
|
38
40
|
This makes it easy to integrate Linux desktop services or system signals into MQTT-based workflows - including **Home Assistant**.
|
|
39
41
|
|
|
40
|
-
##
|
|
42
|
+
## Features
|
|
41
43
|
|
|
42
44
|
* 🔗 Forward **D-Bus signals** to MQTT topics.
|
|
43
45
|
* 🧠 Enrich or transform **MQTT payloads** using Jinja2 templates and additional D-Bus calls.
|
|
@@ -49,11 +51,11 @@ This makes it easy to integrate Linux desktop services or system signals into MQ
|
|
|
49
51
|
|
|
50
52
|
**dbus2mqtt** is considered stable for the use-cases it has been tested against, and is actively being developed. Documentation is continuously being improved.
|
|
51
53
|
|
|
52
|
-
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found here: [
|
|
54
|
+
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found here: [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player/)
|
|
53
55
|
|
|
54
56
|
## Getting started with dbus2mqtt
|
|
55
57
|
|
|
56
|
-
Create a `config.yaml` file with the contents shown below. This configuration will expose all bus properties from the `org.mpris.MediaPlayer2.Player` interface to MQTT on the `dbus2mqtt/org.mpris.MediaPlayer2/state` topic.
|
|
58
|
+
Create a `config.yaml` file with the contents shown below. This configuration will expose all bus properties from the `org.mpris.MediaPlayer2.Player` interface to MQTT on the `dbus2mqtt/org.mpris.MediaPlayer2/state` topic.
|
|
57
59
|
|
|
58
60
|
```yaml
|
|
59
61
|
dbus:
|
|
@@ -92,6 +94,7 @@ MQTT__USERNAME=
|
|
|
92
94
|
MQTT__PASSWORD=
|
|
93
95
|
```
|
|
94
96
|
|
|
97
|
+
|
|
95
98
|
### Install and run dbus2mqtt
|
|
96
99
|
|
|
97
100
|
```bash
|
|
@@ -129,7 +132,8 @@ sudo docker logs dbus2mqtt -f
|
|
|
129
132
|
|
|
130
133
|
## Examples
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
More dbus2mqtt examples can be found here: [examples](https://jwnmulder.github.io/dbus2mqtt/examples/).
|
|
136
|
+
The most complete one being [MPRIS to Home Assistant Media Player integration](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player/)
|
|
133
137
|
|
|
134
138
|
## Configuration reference
|
|
135
139
|
|
|
@@ -226,8 +230,8 @@ dbus:
|
|
|
226
230
|
|
|
227
231
|
## Flows
|
|
228
232
|
|
|
229
|
-
A reference of all supported flow triggers and actions can be found on [Flows](https://github.
|
|
233
|
+
A reference of all supported flow triggers and actions can be found on [Flows](https://jwnmulder.github.io/dbus2mqtt/flows/)
|
|
230
234
|
|
|
231
235
|
## Jinja templating
|
|
232
236
|
|
|
233
|
-
TODO: Document Jinja templating, for now see the [MPRIS to Home Assistant Media Player integration](https://github.
|
|
237
|
+
TODO: Document Jinja templating, for now see the [MPRIS to Home Assistant Media Player integration](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player/) example
|
|
@@ -3,7 +3,7 @@ dbus2mqtt/__main__.py,sha256=NAoa3nwgBSQI22eWzzRx61SIDThDwXmUofWWZU3_4-Q,71
|
|
|
3
3
|
dbus2mqtt/event_broker.py,sha256=Hp5yurhP8FkAO-y0l2grygHxR2e37ZQ7QScjcQDA2UU,1334
|
|
4
4
|
dbus2mqtt/main.py,sha256=Kr2LRVxWcPDtNwCj8Eqz9TxtGLAVrV4q0nizKh1pLXc,4539
|
|
5
5
|
dbus2mqtt/config/__init__.py,sha256=947_dLVt8qq7P3p15jGIy5Vf1jUUMGrh1xr_DVhZclQ,5372
|
|
6
|
-
dbus2mqtt/config/jsonarparse.py,sha256=
|
|
6
|
+
dbus2mqtt/config/jsonarparse.py,sha256=XK7CrMCGiHZK2tq1IqSpzJ3hdV0gCOixJq3LXUDiEjg,1298
|
|
7
7
|
dbus2mqtt/dbus/dbus_client.py,sha256=WHsmOiaJ5SY6zk-C99m83MEpycnUyGpsYmGopJJbPE8,39690
|
|
8
8
|
dbus2mqtt/dbus/dbus_types.py,sha256=NmPD9um499e49Pk8DWH4IrIPQh1BinHYQgoXllCNiDw,777
|
|
9
9
|
dbus2mqtt/dbus/dbus_util.py,sha256=h-1Y8Mvz9bj9X7mPZ8LghkvXDrujdJHK0__AOW373hE,697
|
|
@@ -14,11 +14,11 @@ dbus2mqtt/flow/flow_processor.py,sha256=N-btGap1wqnM4zKyulH_5KQhGi0IRlsK2cHrrnom
|
|
|
14
14
|
dbus2mqtt/flow/actions/context_set.py,sha256=dIT39MJJVb0wuRI_ZM3ssnXYfa-iyB4o_UZD-1BZL2g,1087
|
|
15
15
|
dbus2mqtt/flow/actions/log_action.py,sha256=2_-YEKkX5kvFzK6x4v-Hx3u2PEM8fip_4buMg_ij-oI,1156
|
|
16
16
|
dbus2mqtt/flow/actions/mqtt_publish.py,sha256=psNkTvaR3JZwAwpM4AqiZTDnA5UQX9r4CUZ1LA7iRW4,2366
|
|
17
|
-
dbus2mqtt/mqtt/mqtt_client.py,sha256=
|
|
17
|
+
dbus2mqtt/mqtt/mqtt_client.py,sha256=bVAPbjgIi8ZQZlYVLe-Mo_A6NW6oQYEw1EYMOJYoS7w,6057
|
|
18
18
|
dbus2mqtt/template/dbus_template_functions.py,sha256=UEoXK2PqDKF6jR4vTFHQwq58f5APnOJr7B1_I1zW8yM,2449
|
|
19
|
-
dbus2mqtt/template/templating.py,sha256=
|
|
20
|
-
dbus2mqtt-0.4.
|
|
21
|
-
dbus2mqtt-0.4.
|
|
22
|
-
dbus2mqtt-0.4.
|
|
23
|
-
dbus2mqtt-0.4.
|
|
24
|
-
dbus2mqtt-0.4.
|
|
19
|
+
dbus2mqtt/template/templating.py,sha256=QLar09NinZO8rYGbVs9EThX-SOyTeBVCOppueU7VYdo,4483
|
|
20
|
+
dbus2mqtt-0.4.4.dist-info/METADATA,sha256=aEi1sQg8JVDc6A1_uavQC6lsQljSnIoQuxUUgwsj8bI,8069
|
|
21
|
+
dbus2mqtt-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
22
|
+
dbus2mqtt-0.4.4.dist-info/entry_points.txt,sha256=pmmacoHCsvTTUB5dIPaY4i0H9gX7BQlpd3rBU-Jbv3A,50
|
|
23
|
+
dbus2mqtt-0.4.4.dist-info/licenses/LICENSE,sha256=a4bIEgyA9rrnAfUN90CgbgZ6BQIFHeABkk0JihiBaxM,1074
|
|
24
|
+
dbus2mqtt-0.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|