dbus2mqtt 0.1.1__py3-none-any.whl → 0.1.2__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.py +1 -1
- dbus2mqtt/dbus/dbus_client.py +11 -9
- dbus2mqtt/dbus/dbus_util.py +1 -1
- dbus2mqtt/event_broker.py +1 -2
- {dbus2mqtt-0.1.1.dist-info → dbus2mqtt-0.1.2.dist-info}/METADATA +17 -16
- {dbus2mqtt-0.1.1.dist-info → dbus2mqtt-0.1.2.dist-info}/RECORD +9 -9
- {dbus2mqtt-0.1.1.dist-info → dbus2mqtt-0.1.2.dist-info}/WHEEL +0 -0
- {dbus2mqtt-0.1.1.dist-info → dbus2mqtt-0.1.2.dist-info}/entry_points.txt +0 -0
- {dbus2mqtt-0.1.1.dist-info → dbus2mqtt-0.1.2.dist-info}/licenses/LICENSE +0 -0
dbus2mqtt/config.py
CHANGED
|
@@ -125,7 +125,7 @@ class DbusConfig:
|
|
|
125
125
|
def get_subscription_configs(self, bus_name: str, path: str) -> list[SubscriptionConfig]:
|
|
126
126
|
res: list[SubscriptionConfig] = []
|
|
127
127
|
for subscription in self.subscriptions:
|
|
128
|
-
if fnmatch.fnmatchcase(bus_name, subscription.bus_name) and
|
|
128
|
+
if fnmatch.fnmatchcase(bus_name, subscription.bus_name) and path == subscription.path:
|
|
129
129
|
res.append(subscription)
|
|
130
130
|
return res
|
|
131
131
|
|
dbus2mqtt/dbus/dbus_client.py
CHANGED
|
@@ -124,7 +124,7 @@ class DbusClient:
|
|
|
124
124
|
|
|
125
125
|
on_signal_method_name = "on_" + camel_to_snake(signal_config.signal)
|
|
126
126
|
dbus_signal_state = {
|
|
127
|
-
"
|
|
127
|
+
"bus_name": bus_name,
|
|
128
128
|
"path": path,
|
|
129
129
|
"interface_name": interface.name,
|
|
130
130
|
"subscription_config": subscription_config,
|
|
@@ -354,6 +354,8 @@ class DbusClient:
|
|
|
354
354
|
|
|
355
355
|
async def _handle_on_dbus_signal(self, signal: DbusSignalWithState):
|
|
356
356
|
|
|
357
|
+
logger.debug(f"dbus_signal: signal={signal.signal_config.signal}, args={signal.args}, bus_name={signal.bus_name}, path={signal.path}, interface={signal.interface_name}")
|
|
358
|
+
|
|
357
359
|
for flow in signal.subscription_config.flows:
|
|
358
360
|
for trigger in flow.triggers:
|
|
359
361
|
if trigger.type == "dbus_signal" and signal.signal_config.signal == trigger.signal:
|
|
@@ -366,7 +368,7 @@ class DbusClient:
|
|
|
366
368
|
|
|
367
369
|
if matches_filter:
|
|
368
370
|
context = {
|
|
369
|
-
"bus_name": signal.
|
|
371
|
+
"bus_name": signal.bus_name,
|
|
370
372
|
"path": signal.path,
|
|
371
373
|
"interface": signal.interface_name,
|
|
372
374
|
"args": signal.args
|
|
@@ -394,8 +396,8 @@ class DbusClient:
|
|
|
394
396
|
return
|
|
395
397
|
|
|
396
398
|
logger.debug(f"on_mqtt_msg: topic={msg.topic}, payload={json.dumps(msg.payload)}")
|
|
397
|
-
|
|
398
|
-
|
|
399
|
+
matched_method = False
|
|
400
|
+
matched_property = False
|
|
399
401
|
|
|
400
402
|
payload_method = msg.payload.get("method")
|
|
401
403
|
payload_method_args = msg.payload.get("args") or []
|
|
@@ -417,27 +419,27 @@ class DbusClient:
|
|
|
417
419
|
# filter configured method, configured topic, ...
|
|
418
420
|
if method.method == payload_method:
|
|
419
421
|
interface = proxy_object.get_interface(name=interface_config.interface)
|
|
422
|
+
matched_method = True
|
|
420
423
|
|
|
421
424
|
try:
|
|
422
425
|
logger.info(f"on_mqtt_msg: method={method.method}, args={payload_method_args}, bus_name={bus_name}, path={path}, interface={interface_config.interface}")
|
|
423
426
|
await self.call_dbus_interface_method(interface, method.method, payload_method_args)
|
|
424
|
-
calls_done.append(method.method)
|
|
425
427
|
except Exception as e:
|
|
426
|
-
logger.warning(f"on_mqtt_msg: method={method.method}, bus_name={bus_name} failed, exception={e}")
|
|
428
|
+
logger.warning(f"on_mqtt_msg: method={method.method}, args={payload_method_args}, bus_name={bus_name} failed, exception={e}")
|
|
427
429
|
|
|
428
430
|
for property in interface_config.properties:
|
|
429
431
|
# filter configured property, configured topic, ...
|
|
430
432
|
if property.property == payload_property:
|
|
431
433
|
interface = proxy_object.get_interface(name=interface_config.interface)
|
|
434
|
+
matched_property = True
|
|
432
435
|
|
|
433
436
|
try:
|
|
434
437
|
logger.info(f"on_mqtt_msg: property={property.property}, value={payload_value}, bus_name={bus_name}, path={path}, interface={interface_config.interface}")
|
|
435
438
|
await self.set_dbus_interface_property(interface, property.property, payload_value)
|
|
436
|
-
properties_set.append(property.property)
|
|
437
439
|
except Exception as e:
|
|
438
|
-
logger.warning(f"on_mqtt_msg: property={property.property}, bus_name={bus_name} failed, exception={e}")
|
|
440
|
+
logger.warning(f"on_mqtt_msg: property={property.property}, value={payload_value}, bus_name={bus_name} failed, exception={e}")
|
|
439
441
|
|
|
440
|
-
if
|
|
442
|
+
if not matched_method and not matched_property:
|
|
441
443
|
if payload_method:
|
|
442
444
|
logger.info(f"No configured or active dbus subscriptions for topic={msg.topic}, method={payload_method}, active bus_names={list(self.subscriptions.keys())}")
|
|
443
445
|
if payload_property:
|
dbus2mqtt/dbus/dbus_util.py
CHANGED
dbus2mqtt/event_broker.py
CHANGED
|
@@ -13,7 +13,6 @@ from dbus2mqtt.config import (
|
|
|
13
13
|
SignalConfig,
|
|
14
14
|
SubscriptionConfig,
|
|
15
15
|
)
|
|
16
|
-
from dbus2mqtt.dbus.dbus_types import BusNameSubscriptions
|
|
17
16
|
|
|
18
17
|
logger = logging.getLogger(__name__)
|
|
19
18
|
|
|
@@ -26,7 +25,7 @@ class MqttMessage:
|
|
|
26
25
|
|
|
27
26
|
@dataclass
|
|
28
27
|
class DbusSignalWithState:
|
|
29
|
-
|
|
28
|
+
bus_name: str
|
|
30
29
|
path: str
|
|
31
30
|
interface_name: str
|
|
32
31
|
subscription_config: SubscriptionConfig
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbus2mqtt
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python tool to expose Linux D-Bus signals, methods and properties over MQTT - featuring templating, payload enrichment and Home Assistant-ready examples
|
|
5
5
|
Project-URL: Repository, https://github.com/jwnmulder/dbus2mqtt.git
|
|
6
6
|
Project-URL: Issues, https://github.com/jwnmulder/dbus2mqtt/issues
|
|
@@ -9,6 +9,7 @@ License-File: LICENSE
|
|
|
9
9
|
Keywords: dbus,home-assistant,mpris,mqtt,python
|
|
10
10
|
Classifier: Development Status :: 4 - Beta
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
13
|
Classifier: Operating System :: POSIX :: Linux
|
|
13
14
|
Classifier: Programming Language :: Python :: 3
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -31,8 +32,6 @@ Description-Content-Type: text/markdown
|
|
|
31
32
|
|
|
32
33
|
# dbus2mqtt
|
|
33
34
|
|
|
34
|
-
> **⚠️ Warning:** This project has no releases yet. Running from source works. Docker images and Python packages are planned but not yet available.
|
|
35
|
-
|
|
36
35
|
**dbus2mqtt** is a Python application that bridges **Linux D-Bus** with **MQTT**.
|
|
37
36
|
It lets you forward D-Bus signals and properties to MQTT topics, call D-Bus methods via MQTT messages, and shape payloads using flexible **Jinja2 templating**.
|
|
38
37
|
|
|
@@ -46,10 +45,15 @@ This makes it easy to integrate Linux desktop services or system signals into MQ
|
|
|
46
45
|
* 📡 Expose **D-Bus methods** for remote control via MQTT messages.
|
|
47
46
|
* 🏠 Includes example configurations for **MPRIS** and **Home Assistant Media Player** integration.
|
|
48
47
|
|
|
48
|
+
## Project status
|
|
49
|
+
|
|
50
|
+
**dbus2mqtt** is considered stable for the use-cases it has been tested against, and is actively being developed. Documentation is continuously being improved.
|
|
51
|
+
|
|
52
|
+
Initial testing has focused on MPRIS integration. A table of tested MPRIS players and their supported methods can be found here: [home_assistant_media_player.md](https://github.com/jwnmulder/dbus2mqtt/blob/main/docs/examples/home_assistant_media_player.md)
|
|
53
|
+
|
|
54
|
+
|
|
49
55
|
TODO list
|
|
50
56
|
|
|
51
|
-
* Create a release on PyPI
|
|
52
|
-
* Release a docker image
|
|
53
57
|
* Improve error handling when deleting message with 'retain' set. WARNING:dbus2mqtt.mqtt_client:on_message: Unexpected payload, expecting json, topic=dbus2mqtt/org.mpris.MediaPlayer2/command, payload=, error=Expecting value: line 1 column 1 (char 0)
|
|
54
58
|
* Property set only works the first time, need to restart after which the first set will work again
|
|
55
59
|
|
|
@@ -94,17 +98,17 @@ MQTT__USERNAME=
|
|
|
94
98
|
MQTT__PASSWORD=
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
###
|
|
98
|
-
|
|
99
|
-
To run dbus2mqtt from source (requires uv to be installed)
|
|
101
|
+
### Install and run dbus2mqtt
|
|
100
102
|
|
|
101
103
|
```bash
|
|
102
|
-
|
|
104
|
+
python -m pip install dbus2mqtt
|
|
105
|
+
dbus2mqtt --config config.yaml
|
|
103
106
|
```
|
|
104
107
|
|
|
108
|
+
|
|
105
109
|
### Run using docker with auto start behavior
|
|
106
110
|
|
|
107
|
-
To build and run dbus2mqtt using Docker with the [home_assistant_media_player.yaml](docs/examples/home_assistant_media_player.yaml) example from this repository
|
|
111
|
+
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.
|
|
108
112
|
|
|
109
113
|
```bash
|
|
110
114
|
# setup configuration
|
|
@@ -112,9 +116,6 @@ mkdir -p $HOME/.config/dbus2mqtt
|
|
|
112
116
|
cp docs/examples/home_assistant_media_player.yaml $HOME/.config/dbus2mqtt/config.yaml
|
|
113
117
|
cp .env.example $HOME/.config/dbus2mqtt/.env
|
|
114
118
|
|
|
115
|
-
# build image
|
|
116
|
-
docker build -t jwnmulder/dbus2mqtt:latest .
|
|
117
|
-
|
|
118
119
|
# run image and automatically start on reboot
|
|
119
120
|
docker run --detach --name dbus2mqtt \
|
|
120
121
|
--volume "$HOME"/.config/dbus2mqtt:"$HOME"/.config/dbus2mqtt \
|
|
@@ -133,7 +134,7 @@ sudo docker logs dbus2mqtt -f
|
|
|
133
134
|
|
|
134
135
|
## Examples
|
|
135
136
|
|
|
136
|
-
This repository contains
|
|
137
|
+
This repository contains examples under [docs/examples](https://github.com/jwnmulder/dbus2mqtt/blob/main//docs/examples.md). The most complete one being [MPRIS to Home Assistant Media Player integration](https://github.com/jwnmulder/dbus2mqtt/blob/main/docs/examples/home_assistant_media_player.md)
|
|
137
138
|
|
|
138
139
|
## Configuration reference
|
|
139
140
|
|
|
@@ -216,8 +217,8 @@ dbus:
|
|
|
216
217
|
|
|
217
218
|
## Flows
|
|
218
219
|
|
|
219
|
-
TODO: Document flows, for now see the [MPRIS to Home Assistant Media Player integration](docs/examples/home_assistant_media_player.md) example
|
|
220
|
+
TODO: Document flows, for now see the [MPRIS to Home Assistant Media Player integration](https://github.com/jwnmulder/dbus2mqtt/blob/main/docs/examples/home_assistant_media_player.md) example
|
|
220
221
|
|
|
221
222
|
## Jinja templating
|
|
222
223
|
|
|
223
|
-
TODO: Document Jinja templating, for now see the [MPRIS to Home Assistant Media Player integration](docs/examples/home_assistant_media_player.md) example
|
|
224
|
+
TODO: Document Jinja templating, for now see the [MPRIS to Home Assistant Media Player integration](https://github.com/jwnmulder/dbus2mqtt/blob/main/docs/examples/home_assistant_media_player.md) example
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
dbus2mqtt/__init__.py,sha256=VunubKEH4_lne9Ttd2YRpyXjZMIAzyD2eiJ2sfvvTFU,362
|
|
2
2
|
dbus2mqtt/__main__.py,sha256=NAoa3nwgBSQI22eWzzRx61SIDThDwXmUofWWZU3_4-Q,71
|
|
3
|
-
dbus2mqtt/config.py,sha256=
|
|
4
|
-
dbus2mqtt/event_broker.py,sha256=
|
|
3
|
+
dbus2mqtt/config.py,sha256=wRXT_qYCVRFLioE8H-1sNQiSCRCcE4imGohudZvMEW0,4179
|
|
4
|
+
dbus2mqtt/event_broker.py,sha256=GG7vZZHu08vJgCH5cA-yw3yWU3I2wWHhiEFNMHA4oJk,1836
|
|
5
5
|
dbus2mqtt/main.py,sha256=3-2rorUesggZ9Gv3FksqZw_wapfjNRvjibaX51mVadA,4281
|
|
6
|
-
dbus2mqtt/dbus/dbus_client.py,sha256=
|
|
6
|
+
dbus2mqtt/dbus/dbus_client.py,sha256=3falwDADq9SoLiaQFGGRH6pcm8eD23tujrL2x-CBoyw,22009
|
|
7
7
|
dbus2mqtt/dbus/dbus_types.py,sha256=bUik8LWPnLLJhhJExPuvyn1_MmkUjTn4jxXh3EkYgzI,495
|
|
8
|
-
dbus2mqtt/dbus/dbus_util.py,sha256=
|
|
8
|
+
dbus2mqtt/dbus/dbus_util.py,sha256=kAqA9SPR1N45fzXeXmBXlhulFEIFKrOIvr_LeygO928,569
|
|
9
9
|
dbus2mqtt/flow/__init__.py,sha256=oatdVeBUjAJkUwM9DZsj67Z2rptOHWUn_QFVJrRu2DA,1063
|
|
10
10
|
dbus2mqtt/flow/flow_processor.py,sha256=v5LvcNe-IpEXkWgBW0mK76khrqb5aFkZF0Nw2IvxIEs,7834
|
|
11
11
|
dbus2mqtt/flow/actions/context_set.py,sha256=_XWJ-xHx6nhRYVrd8pBKE3rePc1KL0VU1W0q1pqYRBE,1085
|
|
@@ -13,8 +13,8 @@ dbus2mqtt/flow/actions/mqtt_publish.py,sha256=CmW-CPIYjJ0VldcLjbK6uYDkyE65btQzT1
|
|
|
13
13
|
dbus2mqtt/mqtt/mqtt_client.py,sha256=FxP82_P5mIbiFk5LOYBPRZN7zYp8XQY7xed2HCVXQoo,4071
|
|
14
14
|
dbus2mqtt/template/dbus_template_functions.py,sha256=mSZr4s7XzmMCYnJYV1MlBWOBz71MGEBj6mLJzIapNf8,2427
|
|
15
15
|
dbus2mqtt/template/templating.py,sha256=aBDLW6RaqiivvWjzu3jhTDdZvtZCWMtxGxm_VCaZDKs,4202
|
|
16
|
-
dbus2mqtt-0.1.
|
|
17
|
-
dbus2mqtt-0.1.
|
|
18
|
-
dbus2mqtt-0.1.
|
|
19
|
-
dbus2mqtt-0.1.
|
|
20
|
-
dbus2mqtt-0.1.
|
|
16
|
+
dbus2mqtt-0.1.2.dist-info/METADATA,sha256=syl_84CzV7dH7XUI2fqt-vtQn3w2Dania2gdN989voQ,8090
|
|
17
|
+
dbus2mqtt-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
dbus2mqtt-0.1.2.dist-info/entry_points.txt,sha256=pmmacoHCsvTTUB5dIPaY4i0H9gX7BQlpd3rBU-Jbv3A,50
|
|
19
|
+
dbus2mqtt-0.1.2.dist-info/licenses/LICENSE,sha256=a4bIEgyA9rrnAfUN90CgbgZ6BQIFHeABkk0JihiBaxM,1074
|
|
20
|
+
dbus2mqtt-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|