dbus2mqtt 0.1.0__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 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 fnmatch.fnmatchcase(path, subscription.path):
128
+ if fnmatch.fnmatchcase(bus_name, subscription.bus_name) and path == subscription.path:
129
129
  res.append(subscription)
130
130
  return res
131
131
 
@@ -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
- "bus_name_subscriptions": bus_name_subscriptions,
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.bus_name_subscriptions.bus_name,
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
- calls_done: list[str] = []
398
- properties_set: list[str] = []
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 len(calls_done) == 0 and len(properties_set) == 0:
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:
@@ -15,7 +15,7 @@ def unwrap_dbus_object(o):
15
15
  json_obj = json.loads(res)
16
16
  return json_obj
17
17
 
18
- def unwrap_dbus_objects(*args):
18
+ def unwrap_dbus_objects(args):
19
19
  res = [unwrap_dbus_object(o) for o in args]
20
20
  return res
21
21
 
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
- bus_name_subscriptions: BusNameSubscriptions
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.0
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,10 +9,14 @@ 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
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
14
17
  Classifier: Programming Language :: Python :: 3.12
15
- Requires-Python: >=3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.10
16
20
  Requires-Dist: apscheduler>=3.11.0
17
21
  Requires-Dist: colorlog>=6.9.0
18
22
  Requires-Dist: dbus-next>=0.2.3
@@ -28,8 +32,6 @@ Description-Content-Type: text/markdown
28
32
 
29
33
  # dbus2mqtt
30
34
 
31
- > **⚠️ Warning:** This project has no releases yet. Running from source works. Docker images and Python packages are planned but not yet available.
32
-
33
35
  **dbus2mqtt** is a Python application that bridges **Linux D-Bus** with **MQTT**.
34
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**.
35
37
 
@@ -43,10 +45,15 @@ This makes it easy to integrate Linux desktop services or system signals into MQ
43
45
  * 📡 Expose **D-Bus methods** for remote control via MQTT messages.
44
46
  * 🏠 Includes example configurations for **MPRIS** and **Home Assistant Media Player** integration.
45
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
+
46
55
  TODO list
47
56
 
48
- * Create a release on PyPI
49
- * Release a docker image
50
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)
51
58
  * Property set only works the first time, need to restart after which the first set will work again
52
59
 
@@ -91,17 +98,17 @@ MQTT__USERNAME=
91
98
  MQTT__PASSWORD=
92
99
  ```
93
100
 
94
- ### Running from source
95
-
96
- To run dbus2mqtt from source (requires uv to be installed)
101
+ ### Install and run dbus2mqtt
97
102
 
98
103
  ```bash
99
- uv run main.py --config config.yaml
104
+ python -m pip install dbus2mqtt
105
+ dbus2mqtt --config config.yaml
100
106
  ```
101
107
 
108
+
102
109
  ### Run using docker with auto start behavior
103
110
 
104
- 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.
105
112
 
106
113
  ```bash
107
114
  # setup configuration
@@ -109,9 +116,6 @@ mkdir -p $HOME/.config/dbus2mqtt
109
116
  cp docs/examples/home_assistant_media_player.yaml $HOME/.config/dbus2mqtt/config.yaml
110
117
  cp .env.example $HOME/.config/dbus2mqtt/.env
111
118
 
112
- # build image
113
- docker build -t jwnmulder/dbus2mqtt:latest .
114
-
115
119
  # run image and automatically start on reboot
116
120
  docker run --detach --name dbus2mqtt \
117
121
  --volume "$HOME"/.config/dbus2mqtt:"$HOME"/.config/dbus2mqtt \
@@ -130,7 +134,7 @@ sudo docker logs dbus2mqtt -f
130
134
 
131
135
  ## Examples
132
136
 
133
- This repository contains some examples under [docs/examples](docs/examples.md). The most complete one being [MPRIS to Home Assistant Media Player integration](docs/examples/home_assistant_media_player.md)
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)
134
138
 
135
139
  ## Configuration reference
136
140
 
@@ -213,8 +217,8 @@ dbus:
213
217
 
214
218
  ## Flows
215
219
 
216
- 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
217
221
 
218
222
  ## Jinja templating
219
223
 
220
- 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=zcRP0Q_PHz4ypOhSvvxwlJyT6C3BE1vpjcbiUqXcXDw,4198
4
- dbus2mqtt/event_broker.py,sha256=bFxjrQae87XFWmV6OrYcxpiDPrVQEJv0DJucnI7HZFY,1926
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=Hoa7p9zUyFCPKQtl90gCG8eBuQ8annrQoAsvjAekEMI,21882
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=Lk8w57j8TQxUs8d-DnTcB8wLx-cwkzzHtJY3RbTcXbo,570
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.0.dist-info/METADATA,sha256=-qhv2PDi4q8xdDT3Gi26cdkL38HnNi026T9zOFIzOKc,7496
17
- dbus2mqtt-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- dbus2mqtt-0.1.0.dist-info/entry_points.txt,sha256=pmmacoHCsvTTUB5dIPaY4i0H9gX7BQlpd3rBU-Jbv3A,50
19
- dbus2mqtt-0.1.0.dist-info/licenses/LICENSE,sha256=a4bIEgyA9rrnAfUN90CgbgZ6BQIFHeABkk0JihiBaxM,1074
20
- dbus2mqtt-0.1.0.dist-info/RECORD,,
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,,