dbus2mqtt 0.5.1__tar.gz → 0.5.2__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.

Files changed (100) hide show
  1. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/ci.yml +1 -1
  2. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/deploy-docs.yml +1 -1
  3. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/docker-dev.yml +1 -1
  4. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/pre-commit.yml +1 -1
  5. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/publish.yml +1 -1
  6. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/trivy.yml +1 -1
  7. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.pre-commit-config.yaml +3 -3
  8. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/PKG-INFO +8 -8
  9. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/README.md +7 -7
  10. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docker/Dockerfile.dev +1 -1
  11. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docker/Dockerfile.pypi +1 -1
  12. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/bluez.md +2 -1
  13. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/dbus2mqtt_internal_state.yaml +1 -0
  14. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/home_assistant_media_player/mqtt_mediaplayer.yaml +3 -3
  15. dbus2mqtt-0.5.2/docs/templating/index.md +20 -0
  16. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/dbus/dbus_client.py +2 -2
  17. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/flow/flow_processor.py +1 -1
  18. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/mqtt/mqtt_client.py +2 -2
  19. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/template/templating.py +27 -3
  20. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/template/test_templating.py +20 -0
  21. dbus2mqtt-0.5.1/docs/templating/index.md +0 -14
  22. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.dockerignore +0 -0
  23. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.env.example +0 -0
  24. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  25. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  26. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/release-drafter.yml +0 -0
  27. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/scripts/release-versions.py +0 -0
  28. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/docker-stable.yml +0 -0
  29. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.github/workflows/release-drafter.yml +0 -0
  30. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.gitignore +0 -0
  31. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.markdownlint.json +0 -0
  32. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.python-version +0 -0
  33. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.vscode/launch.json +0 -0
  34. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.vscode/settings.json +0 -0
  35. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/.yamllint.yml +0 -0
  36. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/LICENSE +0 -0
  37. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/favicon.svg +0 -0
  38. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/logo-dark-img.svg +0 -0
  39. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/logo-dark-text.png +0 -0
  40. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/logo-dark-text.svg +0 -0
  41. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/logo-light-img.svg +0 -0
  42. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/assets/logo-light-text.svg +0 -0
  43. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/developer/debugging_dbus.md +0 -0
  44. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/developer/index.md +0 -0
  45. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/bluez.yaml +0 -0
  46. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/connman-config.md +0 -0
  47. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/connman-config.yaml +0 -0
  48. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/dbus2mqtt_internal_state.md +0 -0
  49. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/home_assistant_media_player.md +0 -0
  50. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/home_assistant_media_player.yaml +0 -0
  51. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/index.md +0 -0
  52. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/linux_desktop/notify.json +0 -0
  53. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/linux_desktop/notify_with_actions_and_hints.json +0 -0
  54. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/linux_desktop.md +0 -0
  55. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/examples/linux_desktop.yaml +0 -0
  56. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/flows/flow_actions.md +0 -0
  57. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/flows/flow_triggers.md +0 -0
  58. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/flows/index.md +0 -0
  59. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/hooks.py +0 -0
  60. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/index.md +0 -0
  61. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/overrides/main.html +0 -0
  62. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/setup.md +0 -0
  63. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/stylesheets/extra.css +0 -0
  64. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/docs/subscriptions.md +0 -0
  65. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/mkdocs.yml +0 -0
  66. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/pyproject.toml +0 -0
  67. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/renovate.json +0 -0
  68. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/__init__.py +0 -0
  69. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/__main__.py +0 -0
  70. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/config/__init__.py +0 -0
  71. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/config/jsonarparse.py +0 -0
  72. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/dbus/dbus_types.py +0 -0
  73. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/dbus/dbus_util.py +0 -0
  74. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/dbus/introspection_patches/mpris_playerctl.py +0 -0
  75. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/dbus/introspection_patches/mpris_vlc.py +0 -0
  76. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/event_broker.py +0 -0
  77. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/flow/__init__.py +0 -0
  78. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/flow/actions/context_set.py +0 -0
  79. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/flow/actions/log_action.py +0 -0
  80. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/flow/actions/mqtt_publish.py +0 -0
  81. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/main.py +0 -0
  82. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/src/dbus2mqtt/template/dbus_template_functions.py +0 -0
  83. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/__init__.py +0 -0
  84. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/config/fixtures/payload_template_jinja_expressions.yaml +0 -0
  85. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/config/fixtures/payload_template_off.yaml +0 -0
  86. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/config/fixtures/schedule_cron_trigger.yaml +0 -0
  87. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/config/test_config.py +0 -0
  88. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/config/test_examples.py +0 -0
  89. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/conftest.py +0 -0
  90. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/dbus/test_dbus_client.py +0 -0
  91. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/dbus/test_dbus_client_mqtt_command.py +0 -0
  92. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/dbus/test_dbus_utils.py +0 -0
  93. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/actions/test_context_set.py +0 -0
  94. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/actions/test_log.py +0 -0
  95. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/actions/test_mqtt_publish.py +0 -0
  96. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/test_flow_processor.py +0 -0
  97. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/triggers/test_dbus_client_triggers.py +0 -0
  98. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/flow/triggers/test_mqtt_client_triggers.py +0 -0
  99. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/tests/template/test_templating_config.py +0 -0
  100. {dbus2mqtt-0.5.1 → dbus2mqtt-0.5.2}/uv.lock +0 -0
@@ -25,7 +25,7 @@ jobs:
25
25
  - uses: actions/checkout@v5
26
26
 
27
27
  - name: Install uv
28
- uses: astral-sh/setup-uv@v6
28
+ uses: astral-sh/setup-uv@v7
29
29
  with:
30
30
  activate-environment: true
31
31
  enable-cache: true
@@ -20,7 +20,7 @@ jobs:
20
20
  git config user.name github-actions[bot]
21
21
  git config user.email 41898282+github-actions[bot]@users.noreply.github.com
22
22
  - name: Install uv
23
- uses: astral-sh/setup-uv@v6
23
+ uses: astral-sh/setup-uv@v7
24
24
  with:
25
25
  activate-environment: true
26
26
  enable-cache: true
@@ -23,7 +23,7 @@ jobs:
23
23
  uses: actions/checkout@v5
24
24
 
25
25
  - name: Install uv
26
- uses: astral-sh/setup-uv@v6
26
+ uses: astral-sh/setup-uv@v7
27
27
  with:
28
28
  enable-cache: true
29
29
 
@@ -16,7 +16,7 @@ jobs:
16
16
  - uses: actions/checkout@v5
17
17
 
18
18
  - name: Install uv
19
- uses: astral-sh/setup-uv@v6
19
+ uses: astral-sh/setup-uv@v7
20
20
  with:
21
21
  activate-environment: true
22
22
  enable-cache: true
@@ -17,7 +17,7 @@ jobs:
17
17
  persist-credentials: false
18
18
 
19
19
  - name: Install uv
20
- uses: astral-sh/setup-uv@v6
20
+ uses: astral-sh/setup-uv@v7
21
21
  with:
22
22
  activate-environment: true
23
23
  enable-cache: true
@@ -30,6 +30,6 @@ jobs:
30
30
  ignore-unfixed: true
31
31
 
32
32
  - name: Upload Trivy scan results to GitHub Security tab
33
- uses: github/codeql-action/upload-sarif@v3
33
+ uses: github/codeql-action/upload-sarif@v4
34
34
  with:
35
35
  sarif_file: 'trivy-results.sarif'
@@ -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.12
36
+ rev: v0.14.0
37
37
  hooks:
38
38
  - id: ruff
39
39
  args:
@@ -42,12 +42,12 @@ repos:
42
42
  - I
43
43
 
44
44
  - repo: https://github.com/astral-sh/uv-pre-commit
45
- rev: 0.8.15
45
+ rev: 0.9.2
46
46
  hooks:
47
47
  - id: uv-lock
48
48
 
49
49
  - repo: https://github.com/RobertCraigie/pyright-python
50
- rev: v1.1.405
50
+ rev: v1.1.406
51
51
  hooks:
52
52
  - id: pyright
53
53
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbus2mqtt
3
- Version: 0.5.1
3
+ Version: 0.5.2
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
@@ -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 on [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player.html)
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/)
55
55
 
56
56
  ## Getting started with dbus2mqtt
57
57
 
@@ -101,16 +101,16 @@ python -m pip install dbus2mqtt
101
101
  dbus2mqtt --config config.yaml
102
102
  ```
103
103
 
104
- See [setup](https://jwnmulder.github.io/dbus2mqtt/setup.html) for more installation options and configuration details.
104
+ See [setup](https://jwnmulder.github.io/dbus2mqtt/setup/) for more installation options and configuration details.
105
105
 
106
106
  ## Examples
107
107
 
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)
108
+ More dbus2mqtt examples can be found in the [examples](https://jwnmulder.github.io/dbus2mqtt/examples/) section.
109
+ The most complete one being [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player/)
110
110
 
111
111
  ## Exposing dbus methods, properties and signals
112
112
 
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
113
+ See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions/) 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
114
114
 
115
115
  ```json
116
116
  {
@@ -120,6 +120,6 @@ See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions.html) fo
120
120
 
121
121
  ## Flows and Jinja based templating
122
122
 
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)
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/)
124
124
 
125
- Jinja templating documentation can be found here: [templating](https://jwnmulder.github.io/dbus2mqtt/templating/index.html)
125
+ Jinja templating documentation can be found here: [templating](https://jwnmulder.github.io/dbus2mqtt/templating/)
@@ -17,7 +17,7 @@ This makes it easy to integrate Linux desktop services or system signals into MQ
17
17
 
18
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
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)
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/)
21
21
 
22
22
  ## Getting started with dbus2mqtt
23
23
 
@@ -67,16 +67,16 @@ python -m pip install dbus2mqtt
67
67
  dbus2mqtt --config config.yaml
68
68
  ```
69
69
 
70
- See [setup](https://jwnmulder.github.io/dbus2mqtt/setup.html) for more installation options and configuration details.
70
+ See [setup](https://jwnmulder.github.io/dbus2mqtt/setup/) for more installation options and configuration details.
71
71
 
72
72
  ## Examples
73
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)
74
+ More dbus2mqtt examples can be found in the [examples](https://jwnmulder.github.io/dbus2mqtt/examples/) section.
75
+ The most complete one being [Mediaplayer integration with Home Assistant](https://jwnmulder.github.io/dbus2mqtt/examples/home_assistant_media_player/)
76
76
 
77
77
  ## Exposing dbus methods, properties and signals
78
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
79
+ See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions/) 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
80
 
81
81
  ```json
82
82
  {
@@ -86,6 +86,6 @@ See [subscriptions](https://jwnmulder.github.io/dbus2mqtt/subscriptions.html) fo
86
86
 
87
87
  ## Flows and Jinja based templating
88
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)
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/)
90
90
 
91
- Jinja templating documentation can be found here: [templating](https://jwnmulder.github.io/dbus2mqtt/templating/index.html)
91
+ Jinja templating documentation can be found here: [templating](https://jwnmulder.github.io/dbus2mqtt/templating/)
@@ -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:9b8102b7b3a61db24fe58f335b526173e5aeaaf7d13b2fbfb514e20f84f5e386
28
+ FROM python:3.13-slim-bookworm@sha256:adafcc17694d715c905b4c7bebd96907a1fd5cf183395f0ebc4d3428bd22d92d
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.
@@ -1,4 +1,4 @@
1
- FROM python:3.13-slim-bookworm@sha256:9b8102b7b3a61db24fe58f335b526173e5aeaaf7d13b2fbfb514e20f84f5e386
1
+ FROM python:3.13-slim-bookworm@sha256:adafcc17694d715c905b4c7bebd96907a1fd5cf183395f0ebc4d3428bd22d92d
2
2
 
3
3
  WORKDIR /app
4
4
 
@@ -40,4 +40,5 @@ Dbus methods can be invoked by sendig the JSON payload to MQTT topic `dbus2mqtt/
40
40
 
41
41
  ## References
42
42
 
43
- * <https://manpages.ubuntu.com/manpages/noble/man5/org.bluez>
43
+ * <https://manpages.ubuntu.com/manpages/noble/man5/org.bluez.Adapter.5.html>
44
+ * <https://manpages.ubuntu.com/manpages/noble/man5/org.bluez.Device.5.html>
@@ -39,6 +39,7 @@ flows:
39
39
  payload_type: json
40
40
  payload_template:
41
41
  now: "{{ now().isoformat() }}"
42
+ dbus2mqtt: " {{ dbus2mqtt }}"
42
43
  dbus_list_res: "{{ dbus_list('*') }}"
43
44
  - type: log
44
45
  level: INFO
@@ -21,7 +21,7 @@ media_player:
21
21
 
22
22
  current_volume_template: "{{ state_attr('sensor.mpris_media_player', 'Volume') }}"
23
23
  current_is_muted_template: "{{ state_attr('sensor.mpris_media_player', 'Volume') == 0 }}"
24
- current_position_template: "{{ state_attr('sensor.mpris_media_player', 'Position') }}"
24
+ current_position_template: "{{ (state_attr('sensor.mpris_media_player', 'Position') / 1000000) | int }}"
25
25
 
26
26
  # title: 'xesam:title' or filename without extension from 'xesam:url'
27
27
  title_template: >-
@@ -33,7 +33,7 @@ media_player:
33
33
  {{ title }}
34
34
 
35
35
  media_content_type_template: music # needed to show 'artist'
36
- media_duration_template: "{{ (state_attr('sensor.mpris_media_player', 'Metadata') or {}).get('mpris:length', 0) }}"
36
+ media_duration_template: "{{ ((state_attr('sensor.mpris_media_player', 'Metadata') or {}).get('mpris:length', 0) / 1000000) | int }}"
37
37
  album_template: "{{ (state_attr('sensor.mpris_media_player', 'Metadata') or {}).get('xesam:album', '') }}"
38
38
  artist_template: >-
39
39
  {% set artist = (state_attr('sensor.mpris_media_player', 'Metadata') or {}).get('xesam:artist', '') %}
@@ -102,7 +102,7 @@ media_player:
102
102
  data:
103
103
  topic: dbus2mqtt/org.mpris.MediaPlayer2/command
104
104
  payload: >
105
- { "method": "SetPosition", "args": ["{{ state_attr('sensor.mpris_media_player', 'Metadata')['mpris:trackid'] }}", {{ position | int }}] }
105
+ { "method": "SetPosition", "args": ["{{ state_attr('sensor.mpris_media_player', 'Metadata')['mpris:trackid'] }}", {{ (position * 1000000) | int }}] }
106
106
  set_volume:
107
107
  service: mqtt.publish
108
108
  data:
@@ -0,0 +1,20 @@
1
+ # Templating
2
+
3
+ **dbus2mqtt** leverages Jinja to allow formatting MQTT messages, D-Bus responses or advanced configuration use-cases. If you are not familiar with Jinja based expressions, have a look at Jinjas own [Template Designer Documentation](https://jinja.palletsprojects.com/en/stable/templates/).
4
+
5
+ Templating is used in these areas of dbus2mqtt:
6
+
7
+ * [subscriptions](../subscriptions.md)
8
+ * [flow actions](../flows/flow_actions.md)
9
+
10
+ Besides the filters and functions Jinja provides out of the box, additional extensions are available.
11
+
12
+ All filters from [jinja2-ansible-filters](https://pypi.org/project/jinja2-ansible-filters/) are included as well as the following global functions, variables and filters:
13
+
14
+ | Name | Type | Description |
15
+ |---------------------|-----------|-----------------------------------------------------------------------------|
16
+ | `now` | function | Returns the current date and time as a `datetime` object. |
17
+ | `urldecode` | function | Decodes a URL-encoded string. |
18
+ | `dbus2mqtt.version` | string | The current version of the `dbus2mqtt` package. |
19
+
20
+ More documentation to be added, for now see the [Mediaplayer integration with Home Assistant](../examples/home_assistant_media_player.md) example for inspiration.
@@ -686,7 +686,7 @@ class DbusClient:
686
686
  try:
687
687
  await self._on_mqtt_msg(msg, hints)
688
688
  except Exception as e:
689
- logger.warning(f"mqtt_receive_queue_processor_task: Exception {e}", exc_info=True)
689
+ logger.warning(f"mqtt_receive_queue_processor_task: Exception: {e}", exc_info=True)
690
690
  finally:
691
691
  self.event_broker.mqtt_receive_queue.async_q.task_done()
692
692
 
@@ -735,7 +735,7 @@ class DbusClient:
735
735
 
736
736
  await self.event_broker.flow_trigger_queue.async_q.put(trigger_message)
737
737
  except Exception as e:
738
- logger.warning(f"dbus_signal_queue_processor_task: Exception {e}", exc_info=True)
738
+ logger.warning(f"dbus_signal_queue_processor_task: Exception: {e}", exc_info=True)
739
739
 
740
740
  async def _handle_dbus_object_lifecycle_signal(self, message: dbus_message.Message):
741
741
 
@@ -187,7 +187,7 @@ class FlowProcessor:
187
187
  if "was not provided by any .service files" in str(e):
188
188
  log_level = logging.DEBUG
189
189
 
190
- logger.log(log_level, f"flow_processor_task: Exception {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
190
+ logger.log(log_level, f"flow_processor_task: Exception: {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
191
191
  finally:
192
192
  self.event_broker.flow_trigger_queue.async_q.task_done()
193
193
 
@@ -84,7 +84,7 @@ class MqttClient:
84
84
  except Exception as e:
85
85
  # In case failing uri reads, we still publish an empty msg to avoid stale data
86
86
  payload = None
87
- logger.warning(f"mqtt_publish_queue_processor_task: Exception {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
87
+ logger.warning(f"mqtt_publish_queue_processor_task: Exception: {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
88
88
 
89
89
  payload_log_msg = payload if isinstance(payload, str) else msg.payload
90
90
  logger.debug(f"mqtt_publish_queue_processor_task: topic={msg.topic}, type={payload.__class__}, payload={payload_log_msg}")
@@ -107,7 +107,7 @@ class MqttClient:
107
107
  first_message = False
108
108
 
109
109
  except Exception as e:
110
- logger.warning(f"mqtt_publish_queue_processor_task: Exception {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
110
+ logger.warning(f"mqtt_publish_queue_processor_task: Exception: {e}", exc_info=logger.isEnabledFor(logging.DEBUG))
111
111
  finally:
112
112
  self.event_broker.mqtt_publish_queue.async_q.task_done()
113
113
 
@@ -1,9 +1,16 @@
1
1
  import urllib.parse
2
2
 
3
3
  from datetime import datetime
4
+ from importlib.metadata import version
4
5
  from typing import Any, TypeVar
5
6
 
6
- from jinja2 import BaseLoader, StrictUndefined, TemplateError
7
+ from jinja2 import (
8
+ BaseLoader,
9
+ StrictUndefined,
10
+ TemplateError,
11
+ TemplateRuntimeError,
12
+ UndefinedError,
13
+ )
7
14
  from jinja2.nativetypes import NativeEnvironment
8
15
  from jinja2_ansible_filters import AnsibleCoreFiltersExtension
9
16
 
@@ -18,6 +25,9 @@ class TemplateEngine:
18
25
  engine_globals = {}
19
26
  engine_globals['now'] = datetime.now
20
27
  engine_globals['urldecode'] = urldecode
28
+ engine_globals['dbus2mqtt'] = {
29
+ 'version': version('dbus2mqtt')
30
+ }
21
31
 
22
32
  engine_filters = {}
23
33
  engine_filters['urldecode'] = urldecode
@@ -69,10 +79,17 @@ class TemplateEngine:
69
79
 
70
80
  if isinstance(templatable, str):
71
81
  try:
72
- return self.jinja2_env.from_string(templatable).render(**context)
82
+ template = self.jinja2_env.from_string(templatable)
73
83
  except TemplateError as e:
74
84
  raise TemplateError(f"Error compiling template, template={templatable}: {e}") from e
75
85
 
86
+ try:
87
+ res = template.render(**context)
88
+ str(res) # access value to trigger jinja UndefinedError
89
+ return res
90
+ except UndefinedError as e:
91
+ raise TemplateRuntimeError(f"Error rendering template, template={templatable}: {e}") from e
92
+
76
93
  elif isinstance(templatable, dict):
77
94
  res = {}
78
95
  for k, v in templatable.items():
@@ -95,10 +112,17 @@ class TemplateEngine:
95
112
 
96
113
  if isinstance(templatable, str):
97
114
  try:
98
- return await self.jinja2_async_env.from_string(templatable).render_async(**context)
115
+ template = self.jinja2_async_env.from_string(templatable)
99
116
  except TemplateError as e:
100
117
  raise TemplateError(f"Error compiling template, template={templatable}: {e}") from e
101
118
 
119
+ try:
120
+ res = await template.render_async(**context)
121
+ str(res) # access value to trigger jinja UndefinedError
122
+ return res
123
+ except UndefinedError as e:
124
+ raise TemplateRuntimeError(f"Error rendering template, template={templatable}: {e}") from e
125
+
102
126
  elif isinstance(templatable, dict):
103
127
  res = {}
104
128
  for k, v in templatable.items():
@@ -1,3 +1,6 @@
1
+ import pytest
2
+
3
+ from jinja2 import TemplateError
1
4
 
2
5
  from dbus2mqtt.template.templating import TemplateEngine
3
6
 
@@ -143,3 +146,20 @@ def test_nested_list_values():
143
146
  res = templating.render_template(template, dict, context)
144
147
 
145
148
  assert res["res"]["plain_args"] == ["first-item", "second-item"]
149
+
150
+ def test_strict_undefined_error_handling():
151
+
152
+ template = {"res": "{{ nonexisting_variable }}"}
153
+
154
+ templating = TemplateEngine()
155
+ with pytest.raises(TemplateError):
156
+ templating.render_template(template, dict)
157
+
158
+ @pytest.mark.asyncio
159
+ async def test_async_strict_undefined_error_handling():
160
+
161
+ template = {"res": "{{ nonexisting_variable }}"}
162
+
163
+ templating = TemplateEngine()
164
+ with pytest.raises(TemplateError):
165
+ await templating.async_render_template(template, dict)
@@ -1,14 +0,0 @@
1
- # Templating
2
-
3
- **dbus2mqtt** leverages Jinja to allow formatting MQTT messages, D-Bus responses or advanced configuration use-cases. If you are not familiar with Jinja based expressions, have a look at Jinjas own [Template Designer Documentation](https://jinja.palletsprojects.com/en/stable/templates/).
4
-
5
- Besides the filters and functions Jinja provides out of the box, the following extensions are available:
6
-
7
- * [jinja2-ansible-filters](https://pypi.org/project/jinja2-ansible-filters/)
8
-
9
- More documentation to be added, for now see the [Mediaplayer integration with Home Assistant](../examples/home_assistant_media_player.md) example for inspiration.
10
-
11
- Templating is used in these areas of dbus2mqtt:
12
-
13
- * [subscriptions](../subscriptions.md)
14
- * [flow actions](../flows/flow_actions.md)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes