dbus2mqtt 0.4.3__tar.gz → 0.5.0__tar.gz
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-0.4.3 → dbus2mqtt-0.5.0}/.github/release-drafter.yml +2 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/ci.yml +1 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/deploy-docs.yml +1 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/docker-dev.yml +1 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/docker-stable.yml +2 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/pre-commit.yml +8 -6
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/publish.yml +2 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/trivy.yml +2 -2
- dbus2mqtt-0.5.0/.markdownlint.json +4 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.pre-commit-config.yaml +15 -4
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/PKG-INFO +12 -124
- dbus2mqtt-0.5.0/README.md +91 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docker/Dockerfile.dev +1 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docker/Dockerfile.pypi +1 -1
- dbus2mqtt-0.5.0/docs/assets/favicon.svg +22 -0
- dbus2mqtt-0.5.0/docs/assets/logo-dark-img.svg +11 -0
- dbus2mqtt-0.5.0/docs/assets/logo-dark-text.png +0 -0
- dbus2mqtt-0.5.0/docs/assets/logo-dark-text.svg +22 -0
- dbus2mqtt-0.5.0/docs/assets/logo-light-img.svg +11 -0
- dbus2mqtt-0.5.0/docs/assets/logo-light-text.svg +22 -0
- dbus2mqtt-0.5.0/docs/developer/index.md +56 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/bluez.md +0 -2
- dbus2mqtt-0.5.0/docs/examples/connman-config.md +20 -0
- dbus2mqtt-0.5.0/docs/examples/connman-config.yaml +186 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/dbus2mqtt_internal_state.md +3 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/home_assistant_media_player.md +2 -5
- dbus2mqtt-0.5.0/docs/examples/linux_desktop.md +82 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/linux_desktop.yaml +30 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/flows/flow_actions.md +4 -6
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/flows/flow_triggers.md +42 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/flows/index.md +21 -4
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/hooks.py +1 -1
- dbus2mqtt-0.5.0/docs/overrides/main.html +8 -0
- dbus2mqtt-0.5.0/docs/setup.md +80 -0
- dbus2mqtt-0.5.0/docs/stylesheets/extra.css +4 -0
- dbus2mqtt-0.5.0/docs/subscriptions.md +199 -0
- dbus2mqtt-0.5.0/docs/templating/index.md +14 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/mkdocs.yml +20 -21
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/pyproject.toml +6 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/renovate.json +8 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/config/__init__.py +17 -6
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/config/jsonarparse.py +2 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/dbus/dbus_client.py +126 -16
- dbus2mqtt-0.5.0/src/dbus2mqtt/dbus/dbus_util.py +182 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/event_broker.py +7 -3
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/flow/flow_processor.py +6 -3
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/mqtt/mqtt_client.py +57 -9
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/template/dbus_template_functions.py +1 -1
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/template/templating.py +3 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/__init__.py +27 -20
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/config/fixtures/payload_template_jinja_expressions.yaml +7 -2
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/config/test_config.py +5 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/dbus/test_dbus_client_mqtt_command.py +3 -2
- dbus2mqtt-0.5.0/tests/dbus/test_dbus_utils.py +407 -0
- dbus2mqtt-0.5.0/tests/flow/triggers/test_mqtt_client_triggers.py +101 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/uv.lock +222 -171
- dbus2mqtt-0.4.3/README.md +0 -203
- dbus2mqtt-0.4.3/docs/developer/index.md +0 -15
- dbus2mqtt-0.4.3/docs/examples/linux_desktop.md +0 -30
- dbus2mqtt-0.4.3/src/dbus2mqtt/dbus/dbus_util.py +0 -24
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.dockerignore +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.env.example +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/scripts/release-versions.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.github/workflows/release-drafter.yml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.gitignore +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.python-version +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.vscode/launch.json +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.vscode/settings.json +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/.yamllint.yml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/LICENSE +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/developer/debugging_dbus.md +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/bluez.yaml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/dbus2mqtt_internal_state.yaml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/home_assistant_media_player.yaml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/examples/index.md +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/docs/index.md +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/__init__.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/__main__.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/dbus/dbus_types.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/dbus/introspection_patches/mpris_playerctl.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/dbus/introspection_patches/mpris_vlc.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/flow/__init__.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/flow/actions/context_set.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/flow/actions/log_action.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/flow/actions/mqtt_publish.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/src/dbus2mqtt/main.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/config/fixtures/payload_template_off.yaml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/config/fixtures/schedule_cron_trigger.yaml +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/config/test_examples.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/conftest.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/dbus/test_dbus_client.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/flow/actions/test_context_set.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/flow/actions/test_log.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/flow/actions/test_mqtt_publish.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/flow/test_flow_processor.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/flow/triggers/test_dbus_client_triggers.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/template/test_templating.py +0 -0
- {dbus2mqtt-0.4.3 → dbus2mqtt-0.5.0}/tests/template/test_templating_config.py +0 -0
|
@@ -27,7 +27,7 @@ autolabeler:
|
|
|
27
27
|
- label: enhancement
|
|
28
28
|
branch:
|
|
29
29
|
- '/feature\/.+/'
|
|
30
|
-
- label:
|
|
30
|
+
- label: bugfix
|
|
31
31
|
branch:
|
|
32
32
|
- '/fix\/.+/'
|
|
33
33
|
title:
|
|
@@ -46,6 +46,6 @@ version-resolver:
|
|
|
46
46
|
- feature # patch until we are on 1.x
|
|
47
47
|
- enhancement # patch until we are on 1.x
|
|
48
48
|
default: patch
|
|
49
|
-
change-template: '* $TITLE (#$NUMBER)'
|
|
49
|
+
change-template: '* $TITLE (#$NUMBER) by @$AUTHOR'
|
|
50
50
|
template: |
|
|
51
51
|
$CHANGES
|
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
versions_matrix: ${{ steps.supported_release_versions.outputs.versions_matrix }}
|
|
20
20
|
steps:
|
|
21
21
|
- name: Checkout
|
|
22
|
-
uses: actions/checkout@
|
|
22
|
+
uses: actions/checkout@v5
|
|
23
23
|
with:
|
|
24
24
|
fetch-depth: 0
|
|
25
25
|
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
|
|
47
47
|
steps:
|
|
48
48
|
- name: Checkout
|
|
49
|
-
uses: actions/checkout@
|
|
49
|
+
uses: actions/checkout@v5
|
|
50
50
|
|
|
51
51
|
- name: Docker meta
|
|
52
52
|
id: meta
|
|
@@ -13,15 +13,17 @@ jobs:
|
|
|
13
13
|
pre-commit:
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
17
|
|
|
18
18
|
- name: Install uv
|
|
19
19
|
uses: astral-sh/setup-uv@v6
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
with:
|
|
21
|
+
activate-environment: true
|
|
22
|
+
enable-cache: true
|
|
23
|
+
cache-dependency-glob: |
|
|
24
|
+
**/uv.lock
|
|
25
|
+
**/pyproject.toml
|
|
26
|
+
**/.pre-commit-config.yaml
|
|
25
27
|
|
|
26
28
|
- name: Uv sync
|
|
27
29
|
run: uv sync
|
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/checkout@
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
16
|
with:
|
|
17
17
|
persist-credentials: false
|
|
18
18
|
|
|
@@ -48,7 +48,7 @@ jobs:
|
|
|
48
48
|
|
|
49
49
|
steps:
|
|
50
50
|
- name: Retrieve release distributions
|
|
51
|
-
uses: actions/download-artifact@
|
|
51
|
+
uses: actions/download-artifact@v5
|
|
52
52
|
with:
|
|
53
53
|
name: release-dists
|
|
54
54
|
path: dist/
|
|
@@ -18,10 +18,10 @@ jobs:
|
|
|
18
18
|
runs-on: ubuntu-latest
|
|
19
19
|
steps:
|
|
20
20
|
- name: Checkout code
|
|
21
|
-
uses: actions/checkout@
|
|
21
|
+
uses: actions/checkout@v5
|
|
22
22
|
|
|
23
23
|
- name: Run Trivy vulnerability scanner
|
|
24
|
-
uses: aquasecurity/trivy-action@0.
|
|
24
|
+
uses: aquasecurity/trivy-action@0.33.0
|
|
25
25
|
with:
|
|
26
26
|
image-ref: ghcr.io/jwnmulder/dbus2mqtt:latest
|
|
27
27
|
format: 'sarif'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
repos:
|
|
2
2
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
-
rev:
|
|
3
|
+
rev: v6.0.0
|
|
4
4
|
hooks:
|
|
5
5
|
- id: check-case-conflict
|
|
6
6
|
- id: check-executables-have-shebangs
|
|
@@ -33,7 +33,7 @@ repos:
|
|
|
33
33
|
- --strict
|
|
34
34
|
|
|
35
35
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
36
|
-
rev: v0.12.
|
|
36
|
+
rev: v0.12.11
|
|
37
37
|
hooks:
|
|
38
38
|
- id: ruff
|
|
39
39
|
args:
|
|
@@ -42,11 +42,22 @@ repos:
|
|
|
42
42
|
- I
|
|
43
43
|
|
|
44
44
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
45
|
-
rev: 0.
|
|
45
|
+
rev: 0.8.14
|
|
46
46
|
hooks:
|
|
47
47
|
- id: uv-lock
|
|
48
48
|
|
|
49
49
|
- repo: https://github.com/RobertCraigie/pyright-python
|
|
50
|
-
rev: v1.1.
|
|
50
|
+
rev: v1.1.404
|
|
51
51
|
hooks:
|
|
52
52
|
- id: pyright
|
|
53
|
+
|
|
54
|
+
- repo: local
|
|
55
|
+
hooks:
|
|
56
|
+
- id: deptry
|
|
57
|
+
name: deptry
|
|
58
|
+
entry: uv run deptry .
|
|
59
|
+
language: python
|
|
60
|
+
additional_dependencies:
|
|
61
|
+
- uv
|
|
62
|
+
always_run: true
|
|
63
|
+
pass_filenames: false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbus2mqtt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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
5
|
Project-URL: Documentation, https://jwnmulder.github.io/dbus2mqtt
|
|
6
6
|
Project-URL: Source, https://github.com/jwnmulder/dbus2mqtt
|
|
@@ -29,7 +29,7 @@ Requires-Dist: jsonargparse>=4.38.0
|
|
|
29
29
|
Requires-Dist: paho-mqtt>=2.1.0
|
|
30
30
|
Requires-Dist: pydantic>=2.11.3
|
|
31
31
|
Requires-Dist: python-dotenv>=1.1.0
|
|
32
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
|
|
35
35
|
# dbus2mqtt
|
|
@@ -51,7 +51,7 @@ This makes it easy to integrate Linux desktop services or system signals into MQ
|
|
|
51
51
|
|
|
52
52
|
**dbus2mqtt** is considered stable for the use-cases it has been tested against, and is actively being developed. Documentation is continuously being improved.
|
|
53
53
|
|
|
54
|
-
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found
|
|
54
|
+
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found on [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player.html)
|
|
55
55
|
|
|
56
56
|
## Getting started with dbus2mqtt
|
|
57
57
|
|
|
@@ -94,7 +94,6 @@ MQTT__USERNAME=
|
|
|
94
94
|
MQTT__PASSWORD=
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
|
|
98
97
|
### Install and run dbus2mqtt
|
|
99
98
|
|
|
100
99
|
```bash
|
|
@@ -102,136 +101,25 @@ python -m pip install dbus2mqtt
|
|
|
102
101
|
dbus2mqtt --config config.yaml
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
### Run using docker with auto start behavior
|
|
107
|
-
|
|
108
|
-
To build and run dbus2mqtt using Docker with the [home_assistant_media_player.yaml](https://github.com/jwnmulder/dbus2mqtt/blob/main/docs/examples/home_assistant_media_player.yaml) example from this repository.
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
# setup configuration
|
|
112
|
-
mkdir -p $HOME/.config/dbus2mqtt
|
|
113
|
-
cp docs/examples/home_assistant_media_player.yaml $HOME/.config/dbus2mqtt/config.yaml
|
|
114
|
-
cp .env.example $HOME/.config/dbus2mqtt/.env
|
|
115
|
-
|
|
116
|
-
# run image and automatically start on reboot
|
|
117
|
-
sudo docker pull jwnmulder/dbus2mqtt
|
|
118
|
-
sudo docker run --detach --name dbus2mqtt \
|
|
119
|
-
--volume "$HOME"/.config/dbus2mqtt:"$HOME"/.config/dbus2mqtt \
|
|
120
|
-
--volume /run/user:/run/user \
|
|
121
|
-
--env DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
|
|
122
|
-
--env-file "$HOME"/.config/dbus2mqtt/.env \
|
|
123
|
-
--user $(id -u):$(id -g) \
|
|
124
|
-
--privileged \
|
|
125
|
-
--restart unless-stopped \
|
|
126
|
-
jwnmulder/dbus2mqtt \
|
|
127
|
-
--config "$HOME"/.config/dbus2mqtt/config.yaml
|
|
128
|
-
|
|
129
|
-
# view logs
|
|
130
|
-
sudo docker logs dbus2mqtt -f
|
|
131
|
-
```
|
|
104
|
+
See [setup](https://jwnmulder.github.io/dbus2mqtt/setup.html) for more installation options and configuration details.
|
|
132
105
|
|
|
133
106
|
## Examples
|
|
134
107
|
|
|
135
|
-
More dbus2mqtt examples can be found
|
|
136
|
-
The most complete one being [
|
|
137
|
-
|
|
138
|
-
## Configuration reference
|
|
139
|
-
|
|
140
|
-
dbus2mqtt leverages [jsonargparse](https://jsonargparse.readthedocs.io/en/stable/) which allows configuration via either yaml configuration, CLI or environment variables. Until this is fully documented have a look at the examples in this repository.
|
|
141
|
-
|
|
142
|
-
### MQTT and D-Bus connection details
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# dbus_fast configuration
|
|
146
|
-
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
|
|
147
|
-
|
|
148
|
-
# dbus2mqtt configuration
|
|
149
|
-
MQTT__HOST=localhost
|
|
150
|
-
MQTT__PORT=1883
|
|
151
|
-
MQTT__USERNAME=
|
|
152
|
-
MQTT__PASSWORD=
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
or
|
|
156
|
-
|
|
157
|
-
```yaml
|
|
158
|
-
mqtt:
|
|
159
|
-
host: localhost
|
|
160
|
-
port: 1883
|
|
161
|
-
subscription_topics:
|
|
162
|
-
- dbus2mqtt/#
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Exposing dbus methods
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
dbus:
|
|
169
|
-
subscriptions:
|
|
170
|
-
- bus_name: org.mpris.MediaPlayer2.*
|
|
171
|
-
path: /org/mpris/MediaPlayer2
|
|
172
|
-
interfaces:
|
|
173
|
-
- interface: org.mpris.MediaPlayer2.Player
|
|
174
|
-
mqtt_command_topic: dbus2mqtt/org.mpris.MediaPlayer2/command
|
|
175
|
-
methods:
|
|
176
|
-
- method: Pause
|
|
177
|
-
- method: Play
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
This configuration will expose 2 methods. Triggering methods can be done by publishing json messages to the `dbus2mqtt/org.mpris.MediaPlayer2/command` MQTT topic. Arguments can be passed along in `args`.
|
|
108
|
+
More dbus2mqtt examples can be found in the [examples](https://jwnmulder.github.io/dbus2mqtt/examples/index.html) section.
|
|
109
|
+
The most complete one being [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player.html)
|
|
181
110
|
|
|
182
|
-
|
|
111
|
+
## Exposing dbus methods, properties and signals
|
|
183
112
|
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
"method": "Play",
|
|
187
|
-
}
|
|
188
|
-
```
|
|
113
|
+
See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions.html) for documentation on calling methods, setting properties and exposing D-Bus signals to MQTT. When configured, D-Bus methods can be invoked by publishing a message like
|
|
189
114
|
|
|
190
115
|
```json
|
|
191
116
|
{
|
|
192
|
-
"method": "
|
|
193
|
-
"args": []
|
|
117
|
+
"method": "Play"
|
|
194
118
|
}
|
|
195
119
|
```
|
|
196
120
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```json
|
|
200
|
-
{
|
|
201
|
-
"method": "Play",
|
|
202
|
-
"bus_name": "*.firefox",
|
|
203
|
-
"path": "/org/mpris/MediaPlayer2"
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Exposing dbus signals
|
|
208
|
-
|
|
209
|
-
Publishing signals to MQTT topics works by subscribing to the relevant signal and using flows for publishing
|
|
210
|
-
|
|
211
|
-
```yaml
|
|
212
|
-
dbus:
|
|
213
|
-
subscriptions:
|
|
214
|
-
- bus_name: org.mpris.MediaPlayer2.*
|
|
215
|
-
path: /org/mpris/MediaPlayer2
|
|
216
|
-
interfaces:
|
|
217
|
-
- interface: org.freedesktop.DBus.Properties
|
|
218
|
-
signals:
|
|
219
|
-
- signal: PropertiesChanged
|
|
220
|
-
|
|
221
|
-
flows:
|
|
222
|
-
- name: "Property Changed flow"
|
|
223
|
-
triggers:
|
|
224
|
-
- type: on_signal
|
|
225
|
-
actions:
|
|
226
|
-
- type: mqtt_publish
|
|
227
|
-
topic: dbus2mqtt/org.mpris.MediaPlayer2/signals/PropertiesChanged
|
|
228
|
-
payload_type: json
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Flows
|
|
232
|
-
|
|
233
|
-
A reference of all supported flow triggers and actions can be found on [Flows](https://jwnmulder.github.io/dbus2mqtt/flows/)
|
|
121
|
+
## Flows and Jinja based templating
|
|
234
122
|
|
|
235
|
-
|
|
123
|
+
For more advanced use-cases, dbus2mqtt has support for flows and Jinja2 based templates. A reference of all supported flow triggers and actions can be found on [flows](https://jwnmulder.github.io/dbus2mqtt/flows/index.html)
|
|
236
124
|
|
|
237
|
-
|
|
125
|
+
Jinja templating documentation can be found here: [templating](templating/index.md)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# dbus2mqtt
|
|
2
|
+
|
|
3
|
+
**dbus2mqtt** is a Python application that bridges **DBus** with **MQTT**.
|
|
4
|
+
It lets you forward Linux D-Bus signals and properties to MQTT topics, call D-Bus methods via MQTT messages, and shape payloads using flexible **Jinja2 templating**.
|
|
5
|
+
|
|
6
|
+
This makes it easy to integrate Linux desktop services or system signals into MQTT-based workflows - including **Home Assistant**.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
* 🔗 Forward **D-Bus signals** to MQTT topics.
|
|
11
|
+
* 🧠 Enrich or transform **MQTT payloads** using Jinja2 templates and additional D-Bus calls.
|
|
12
|
+
* ⚡ Trigger message publishing via **signals, timers, property changes, or startup events**.
|
|
13
|
+
* 📡 Expose **D-Bus methods** for remote control via MQTT messages.
|
|
14
|
+
* 🏠 Includes example configurations for **MPRIS** and **Home Assistant Media Player** integration.
|
|
15
|
+
|
|
16
|
+
## Project status
|
|
17
|
+
|
|
18
|
+
**dbus2mqtt** is considered stable for the use-cases it has been tested against, and is actively being developed. Documentation is continuously being improved.
|
|
19
|
+
|
|
20
|
+
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found on [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player.html)
|
|
21
|
+
|
|
22
|
+
## Getting started with dbus2mqtt
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
dbus:
|
|
28
|
+
subscriptions:
|
|
29
|
+
- bus_name: org.mpris.MediaPlayer2.*
|
|
30
|
+
path: /org/mpris/MediaPlayer2
|
|
31
|
+
interfaces:
|
|
32
|
+
- interface: org.freedesktop.DBus.Properties
|
|
33
|
+
methods:
|
|
34
|
+
- method: GetAll
|
|
35
|
+
|
|
36
|
+
flows:
|
|
37
|
+
- name: "Publish MPRIS state"
|
|
38
|
+
triggers:
|
|
39
|
+
- type: object_added
|
|
40
|
+
- type: schedule
|
|
41
|
+
interval: {seconds: 5}
|
|
42
|
+
actions:
|
|
43
|
+
- type: context_set
|
|
44
|
+
context:
|
|
45
|
+
mpris_bus_name: '{{ dbus_list("org.mpris.MediaPlayer2.*") | first }}'
|
|
46
|
+
path: /org/mpris/MediaPlayer2
|
|
47
|
+
- type: mqtt_publish
|
|
48
|
+
topic: dbus2mqtt/org.mpris.MediaPlayer2/state
|
|
49
|
+
payload_type: json
|
|
50
|
+
payload_template: |
|
|
51
|
+
{{ dbus_call(mpris_bus_name, path, 'org.freedesktop.DBus.Properties', 'GetAll', ['org.mpris.MediaPlayer2.Player']) }}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
MQTT connection details can be configured in that same `config.yaml` file or via environment variables. For now create a `.env` file with the following contents.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
MQTT__HOST=localhost
|
|
58
|
+
MQTT__PORT=1883
|
|
59
|
+
MQTT__USERNAME=
|
|
60
|
+
MQTT__PASSWORD=
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Install and run dbus2mqtt
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m pip install dbus2mqtt
|
|
67
|
+
dbus2mqtt --config config.yaml
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
See [setup](https://jwnmulder.github.io/dbus2mqtt/setup.html) for more installation options and configuration details.
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
More dbus2mqtt examples can be found in the [examples](https://jwnmulder.github.io/dbus2mqtt/examples/index.html) section.
|
|
75
|
+
The most complete one being [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player.html)
|
|
76
|
+
|
|
77
|
+
## Exposing dbus methods, properties and signals
|
|
78
|
+
|
|
79
|
+
See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions.html) for documentation on calling methods, setting properties and exposing D-Bus signals to MQTT. When configured, D-Bus methods can be invoked by publishing a message like
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"method": "Play"
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Flows and Jinja based templating
|
|
88
|
+
|
|
89
|
+
For more advanced use-cases, dbus2mqtt has support for flows and Jinja2 based templates. A reference of all supported flow triggers and actions can be found on [flows](https://jwnmulder.github.io/dbus2mqtt/flows/index.html)
|
|
90
|
+
|
|
91
|
+
Jinja templating documentation can be found here: [templating](templating/index.md)
|
|
@@ -25,7 +25,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|
|
25
25
|
uv sync --frozen --no-dev
|
|
26
26
|
|
|
27
27
|
# Then, use a final image without uv
|
|
28
|
-
FROM python:3.13-slim-bookworm@sha256:
|
|
28
|
+
FROM python:3.13-slim-bookworm@sha256:9b8102b7b3a61db24fe58f335b526173e5aeaaf7d13b2fbfb514e20f84f5e386
|
|
29
29
|
# It is important to use the image that matches the builder, as the path to the
|
|
30
30
|
# Python executable must be the same, e.g., using `python:3.12-slim-bookworm`
|
|
31
31
|
# will fail.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 47" role="img" aria-label="dbus2 MQTT logo">
|
|
2
|
+
<defs>
|
|
3
|
+
<style>
|
|
4
|
+
.word {
|
|
5
|
+
font-family: Inter, Roboto, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
|
|
6
|
+
font-size: 64px;
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
fill: #1F2937;
|
|
9
|
+
}
|
|
10
|
+
.num {
|
|
11
|
+
font-family: Inter, Roboto, system-ui, sans-serif;
|
|
12
|
+
font-size: 64px;
|
|
13
|
+
font-weight: 700;
|
|
14
|
+
fill: #7B1FA2;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</defs>
|
|
18
|
+
|
|
19
|
+
<!-- <text x="0" y="50" class="word">dbus</text> -->
|
|
20
|
+
<text x="0" y="46" class="num">2</text>
|
|
21
|
+
<!-- <text x="0" y="105" class="word">MQTT</text> -->
|
|
22
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 80">
|
|
2
|
+
|
|
3
|
+
<!-- Connection (angular polyline) behind, vertical in the middle of the dots -->
|
|
4
|
+
<polyline points="20,40 50,10 50,70 80,40" stroke="#1F2937" stroke-width="10" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
|
|
6
|
+
<!-- DBus node in purple -->
|
|
7
|
+
<circle cx="20" cy="40" r="14" fill="#7B1FA2"/>
|
|
8
|
+
|
|
9
|
+
<!-- MQTT node in purple -->
|
|
10
|
+
<circle cx="80" cy="40" r="14" fill="#7B1FA2"/>
|
|
11
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 110" role="img" aria-label="dbus2 MQTT logo">
|
|
2
|
+
<defs>
|
|
3
|
+
<style>
|
|
4
|
+
.word {
|
|
5
|
+
font-family: Inter, Roboto, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
|
|
6
|
+
font-size: 64px;
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
fill: #1F2937;
|
|
9
|
+
}
|
|
10
|
+
.num {
|
|
11
|
+
font-family: Inter, Roboto, system-ui, sans-serif;
|
|
12
|
+
font-size: 64px;
|
|
13
|
+
font-weight: 700;
|
|
14
|
+
fill: #7B1FA2;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</defs>
|
|
18
|
+
|
|
19
|
+
<text x="0" y="50" class="word">dbus</text>
|
|
20
|
+
<text x="143" y="50" class="num">2</text>
|
|
21
|
+
<text x="0" y="105" class="word">MQTT</text>
|
|
22
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 80">
|
|
2
|
+
|
|
3
|
+
<!-- Connection (angular polyline) behind, vertical in the middle of the dots -->
|
|
4
|
+
<polyline points="20,40 50,10 50,70 80,40" stroke="#FFFFFF" stroke-width="10" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
|
|
6
|
+
<!-- DBus node in purple -->
|
|
7
|
+
<circle cx="20" cy="40" r="14" fill="#BE90FF"/>
|
|
8
|
+
|
|
9
|
+
<!-- MQTT node in purple -->
|
|
10
|
+
<circle cx="80" cy="40" r="14" fill="#BE90FF"/>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 110" role="img" aria-label="dbus2 MQTT logo">
|
|
2
|
+
<defs>
|
|
3
|
+
<style>
|
|
4
|
+
.word {
|
|
5
|
+
font-family: Inter, Roboto, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
|
|
6
|
+
font-size: 64px;
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
fill: #FFFFFF;
|
|
9
|
+
}
|
|
10
|
+
.num {
|
|
11
|
+
font-family: Inter, Roboto, system-ui, sans-serif;
|
|
12
|
+
font-size: 64px;
|
|
13
|
+
font-weight: 700;
|
|
14
|
+
fill: #BE90FF;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</defs>
|
|
18
|
+
|
|
19
|
+
<text x="0" y="50" class="word">dbus</text>
|
|
20
|
+
<text x="143" y="50" class="num">2</text>
|
|
21
|
+
<text x="0" y="105" class="word">MQTT</text>
|
|
22
|
+
</svg>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Developer guide
|
|
2
|
+
|
|
3
|
+
## Specifications
|
|
4
|
+
|
|
5
|
+
Generic DBus specifications:
|
|
6
|
+
|
|
7
|
+
* [D-Bus Tutorial](https://dbus.freedesktop.org/doc/dbus-tutorial.html)
|
|
8
|
+
* [D-Bus Specification](https://dbus.freedesktop.org/doc/dbus-specification.html)
|
|
9
|
+
|
|
10
|
+
## Running from source
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uv run main.py --config config.yaml
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Activate Python virtual env
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv sync
|
|
20
|
+
source .venv/bin/activate
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Linting
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# run pre-commit linters
|
|
27
|
+
uv run pre-commit run --all-files
|
|
28
|
+
|
|
29
|
+
# setup pre-commit to automatically run linters via git hooks
|
|
30
|
+
uv run pre-commit install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Publishing and subscribing to MQTT messages
|
|
34
|
+
|
|
35
|
+
Multiple MQTT client exist that can be used for testing, e.g.
|
|
36
|
+
|
|
37
|
+
* [MQTT Explorer](https://mqtt-explorer.com/)
|
|
38
|
+
* [github.com/RISE-Maritime/mqtt-cli](https://github.com/RISE-Maritime/mqtt-cli)
|
|
39
|
+
|
|
40
|
+
### Using mqtt-cli
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
source .env
|
|
44
|
+
|
|
45
|
+
mqtt() {
|
|
46
|
+
uvx --from mqtt-cli mqtt \
|
|
47
|
+
--host "$MQTT__HOST" \
|
|
48
|
+
--user "$MQTT__USERNAME" \
|
|
49
|
+
--password "$MQTT__PASSWORD" \
|
|
50
|
+
"$@"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
mqtt --help
|
|
54
|
+
mqtt subscribe --topic 'dbus2mqtt/#'
|
|
55
|
+
mqtt publish -t dbus2mqtt/org.mpris.MediaPlayer2/command -m '{ "method": "Play" }'
|
|
56
|
+
```
|
|
@@ -5,8 +5,6 @@ hide:
|
|
|
5
5
|
|
|
6
6
|
# Bluez
|
|
7
7
|
|
|
8
|
-
## Introduction
|
|
9
|
-
|
|
10
8
|
This configuration file demonstrates how to use dbus2mqtt to bridge D-Bus events from BlueZ (the official Linux Bluetooth protocol stack) to MQTT topics. It subscribes to relevant D-Bus signals and properties for both the Bluetooth adapter (`hci0`) and all Bluetooth devices managed by BlueZ. The configuration defines flows that:
|
|
11
9
|
|
|
12
10
|
* Monitor property changes and object lifecycle events (added/removed) for the Bluetooth adapter and devices.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
hide:
|
|
3
|
+
- toc
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Connman (WIP)
|
|
7
|
+
|
|
8
|
+
Using dbus2mqtt, you can control you network configuration using connman through mqtt topics.
|
|
9
|
+
|
|
10
|
+
## Setup activities
|
|
11
|
+
|
|
12
|
+
Trying out this example
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
uv run dbus2mqtt --config docs/examples/connman-config.yaml
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
This configuration is a passthrough of the D-BUS architecture of connman. refer to connman D-BUS API.
|