dbus2mqtt 0.4.0__py3-none-any.whl → 0.4.1__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/dbus/dbus_client.py +43 -42
- dbus2mqtt/mqtt/mqtt_client.py +1 -1
- {dbus2mqtt-0.4.0.dist-info → dbus2mqtt-0.4.1.dist-info}/METADATA +14 -4
- {dbus2mqtt-0.4.0.dist-info → dbus2mqtt-0.4.1.dist-info}/RECORD +7 -7
- {dbus2mqtt-0.4.0.dist-info → dbus2mqtt-0.4.1.dist-info}/WHEEL +0 -0
- {dbus2mqtt-0.4.0.dist-info → dbus2mqtt-0.4.1.dist-info}/entry_points.txt +0 -0
- {dbus2mqtt-0.4.0.dist-info → dbus2mqtt-0.4.1.dist-info}/licenses/LICENSE +0 -0
dbus2mqtt/dbus/dbus_client.py
CHANGED
|
@@ -745,12 +745,13 @@ class DbusClient:
|
|
|
745
745
|
path = message.body[0]
|
|
746
746
|
await self._handle_interfaces_removed(bus_name, path)
|
|
747
747
|
|
|
748
|
-
|
|
749
748
|
async def _on_mqtt_msg(self, msg: MqttMessage):
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
749
|
+
"""Executes dbus method calls or property updates on objects when messages have
|
|
750
|
+
1. a matching subscription configured
|
|
751
|
+
2. a matching method
|
|
752
|
+
3. a matching bus_name (if provided)
|
|
753
|
+
4. a matching path (if provided)
|
|
754
|
+
"""
|
|
754
755
|
|
|
755
756
|
found_matching_topic = False
|
|
756
757
|
for subscription_configs in self.config.subscriptions:
|
|
@@ -766,6 +767,9 @@ class DbusClient:
|
|
|
766
767
|
matched_method = False
|
|
767
768
|
matched_property = False
|
|
768
769
|
|
|
770
|
+
payload_bus_name = msg.payload.get("bus_name") or "*"
|
|
771
|
+
payload_path = msg.payload.get("path") or "*"
|
|
772
|
+
|
|
769
773
|
payload_method = msg.payload.get("method")
|
|
770
774
|
payload_method_args = msg.payload.get("args") or []
|
|
771
775
|
|
|
@@ -773,47 +777,44 @@ class DbusClient:
|
|
|
773
777
|
payload_value = msg.payload.get("value")
|
|
774
778
|
|
|
775
779
|
if payload_method is None and (payload_property is None or payload_value is None):
|
|
776
|
-
|
|
780
|
+
if msg.payload:
|
|
781
|
+
logger.info(f"on_mqtt_msg: Unsupported payload, missing 'method' or 'property/value', got method={payload_method}, property={payload_property}, value={payload_value} from {msg.payload}")
|
|
777
782
|
return
|
|
778
783
|
|
|
779
784
|
for [bus_name, bus_name_subscription] in self.subscriptions.items():
|
|
780
|
-
|
|
781
|
-
for
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
785
|
+
if fnmatch.fnmatchcase(bus_name, payload_bus_name):
|
|
786
|
+
for [path, proxy_object] in bus_name_subscription.path_objects.items():
|
|
787
|
+
if fnmatch.fnmatchcase(path, payload_path):
|
|
788
|
+
for subscription_configs in self.config.get_subscription_configs(bus_name=bus_name, path=path):
|
|
789
|
+
for interface_config in subscription_configs.interfaces:
|
|
790
|
+
|
|
791
|
+
for method in interface_config.methods:
|
|
792
|
+
|
|
793
|
+
# filter configured method, configured topic, ...
|
|
794
|
+
if method.method == payload_method:
|
|
795
|
+
interface = proxy_object.get_interface(name=interface_config.interface)
|
|
796
|
+
matched_method = True
|
|
797
|
+
|
|
798
|
+
try:
|
|
799
|
+
logger.info(f"on_mqtt_msg: method={method.method}, args={payload_method_args}, bus_name={bus_name}, path={path}, interface={interface_config.interface}")
|
|
800
|
+
await self.call_dbus_interface_method(interface, method.method, payload_method_args)
|
|
801
|
+
except Exception as e:
|
|
802
|
+
logger.warning(f"on_mqtt_msg: method={method.method}, args={payload_method_args}, bus_name={bus_name} failed, exception={e}")
|
|
803
|
+
|
|
804
|
+
for property in interface_config.properties:
|
|
805
|
+
# filter configured property, configured topic, ...
|
|
806
|
+
if property.property == payload_property:
|
|
807
|
+
interface = proxy_object.get_interface(name=interface_config.interface)
|
|
808
|
+
matched_property = True
|
|
809
|
+
|
|
810
|
+
try:
|
|
811
|
+
logger.info(f"on_mqtt_msg: property={property.property}, value={payload_value}, bus_name={bus_name}, path={path}, interface={interface_config.interface}")
|
|
812
|
+
await self.set_dbus_interface_property(interface, property.property, payload_value)
|
|
813
|
+
except Exception as e:
|
|
814
|
+
logger.warning(f"on_mqtt_msg: property={property.property}, value={payload_value}, bus_name={bus_name} failed, exception={e}")
|
|
808
815
|
|
|
809
816
|
if not matched_method and not matched_property:
|
|
810
817
|
if payload_method:
|
|
811
|
-
logger.info(f"No configured or active dbus subscriptions for topic={msg.topic}, method={payload_method}, active bus_names={list(self.subscriptions.keys())}")
|
|
818
|
+
logger.info(f"No configured or active dbus subscriptions for topic={msg.topic}, method={payload_method}, bus_name={payload_bus_name}, path={payload_path or '*'}, active bus_names={list(self.subscriptions.keys())}")
|
|
812
819
|
if payload_property:
|
|
813
|
-
logger.info(f"No configured or active dbus subscriptions for topic={msg.topic}, property={payload_property}, active bus_names={list(self.subscriptions.keys())}")
|
|
814
|
-
|
|
815
|
-
# raw mode, payload contains: bus_name (specific or wildcard), path, interface_name
|
|
816
|
-
# topic: dbus2mqtt/raw (with allowlist check)
|
|
817
|
-
|
|
818
|
-
# predefined mode with topic matching from configuration
|
|
819
|
-
# topic: dbus2mqtt/MediaPlayer/command
|
|
820
|
+
logger.info(f"No configured or active dbus subscriptions for topic={msg.topic}, property={payload_property}, bus_name={payload_bus_name}, path={payload_path or '*'}, active bus_names={list(self.subscriptions.keys())}")
|
dbus2mqtt/mqtt/mqtt_client.py
CHANGED
|
@@ -117,7 +117,7 @@ class MqttClient:
|
|
|
117
117
|
return
|
|
118
118
|
|
|
119
119
|
try:
|
|
120
|
-
json_payload = json.loads(payload)
|
|
120
|
+
json_payload = json.loads(payload) if payload else {}
|
|
121
121
|
logger.debug(f"on_message: msg.topic={msg.topic}, msg.payload={json.dumps(json_payload)}")
|
|
122
122
|
self.event_broker.on_mqtt_receive(MqttMessage(msg.topic, json_payload))
|
|
123
123
|
except json.JSONDecodeError as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbus2mqtt
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
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
|
|
@@ -173,21 +173,31 @@ dbus:
|
|
|
173
173
|
|
|
174
174
|
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`.
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
Some examples that call methods on **all** bus_names matching the configured pattern
|
|
177
177
|
|
|
178
178
|
```json
|
|
179
179
|
{
|
|
180
|
-
"method"
|
|
180
|
+
"method": "Play",
|
|
181
181
|
}
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
```json
|
|
185
185
|
{
|
|
186
|
-
"method"
|
|
186
|
+
"method": "OpenUri",
|
|
187
187
|
"args": []
|
|
188
188
|
}
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
To specifically target objects the properties `bus_name` and/or `path` can be used. Both properties support wildcards
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"method": "Play",
|
|
196
|
+
"bus_name": "*.firefox",
|
|
197
|
+
"path": "/org/mpris/MediaPlayer2"
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
191
201
|
### Exposing dbus signals
|
|
192
202
|
|
|
193
203
|
Publishing signals to MQTT topics works by subscribing to the relevant signal and using flows for publishing
|
|
@@ -4,7 +4,7 @@ dbus2mqtt/event_broker.py,sha256=Hp5yurhP8FkAO-y0l2grygHxR2e37ZQ7QScjcQDA2UU,133
|
|
|
4
4
|
dbus2mqtt/main.py,sha256=Kr2LRVxWcPDtNwCj8Eqz9TxtGLAVrV4q0nizKh1pLXc,4539
|
|
5
5
|
dbus2mqtt/config/__init__.py,sha256=LXQg2cZ_vMvhAl7_cC6G3gxCaLCq9uaTfZqw7OEXkPQ,5104
|
|
6
6
|
dbus2mqtt/config/jsonarparse.py,sha256=VJGFeyQJcOE6bRXlSRr3FClvN_HnmiIlEGmOgNM0oCc,1214
|
|
7
|
-
dbus2mqtt/dbus/dbus_client.py,sha256=
|
|
7
|
+
dbus2mqtt/dbus/dbus_client.py,sha256=zWz9V0lbGzbb3AifqWrwkOaC9OdZtQbfHhkSSJfXMi8,39690
|
|
8
8
|
dbus2mqtt/dbus/dbus_types.py,sha256=NmPD9um499e49Pk8DWH4IrIPQh1BinHYQgoXllCNiDw,777
|
|
9
9
|
dbus2mqtt/dbus/dbus_util.py,sha256=h-1Y8Mvz9bj9X7mPZ8LghkvXDrujdJHK0__AOW373hE,697
|
|
10
10
|
dbus2mqtt/dbus/introspection_patches/mpris_playerctl.py,sha256=q93d_Yp93u3Y-9q0dRdKW5hrij9GK3CFqKhUWVE8uw4,5883
|
|
@@ -13,11 +13,11 @@ dbus2mqtt/flow/__init__.py,sha256=tAL-CjXQHq_tGTKctIdOZ5teVKBtcJs6Astq_RdruV8,15
|
|
|
13
13
|
dbus2mqtt/flow/flow_processor.py,sha256=-fJ5JPFcFqz1RokKaqjdHoU-EPg5McAERKYFwIkMzgU,8749
|
|
14
14
|
dbus2mqtt/flow/actions/context_set.py,sha256=dIT39MJJVb0wuRI_ZM3ssnXYfa-iyB4o_UZD-1BZL2g,1087
|
|
15
15
|
dbus2mqtt/flow/actions/mqtt_publish.py,sha256=psNkTvaR3JZwAwpM4AqiZTDnA5UQX9r4CUZ1LA7iRW4,2366
|
|
16
|
-
dbus2mqtt/mqtt/mqtt_client.py,sha256=
|
|
16
|
+
dbus2mqtt/mqtt/mqtt_client.py,sha256=R0ZNUmOr8Lg8s2TuUcjH3BvEPPlNK731tzO0tNVvqqs,5167
|
|
17
17
|
dbus2mqtt/template/dbus_template_functions.py,sha256=UEoXK2PqDKF6jR4vTFHQwq58f5APnOJr7B1_I1zW8yM,2449
|
|
18
18
|
dbus2mqtt/template/templating.py,sha256=ZLp1A8PFAs_-Bndx4yGqyppaDfh8marHlK7P3bFInu4,4144
|
|
19
|
-
dbus2mqtt-0.4.
|
|
20
|
-
dbus2mqtt-0.4.
|
|
21
|
-
dbus2mqtt-0.4.
|
|
22
|
-
dbus2mqtt-0.4.
|
|
23
|
-
dbus2mqtt-0.4.
|
|
19
|
+
dbus2mqtt-0.4.1.dist-info/METADATA,sha256=LR9PxxTxJ6TcxHpa8YKg9E6uWRDWYRBbpQ5-o5QGTxQ,8114
|
|
20
|
+
dbus2mqtt-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
21
|
+
dbus2mqtt-0.4.1.dist-info/entry_points.txt,sha256=pmmacoHCsvTTUB5dIPaY4i0H9gX7BQlpd3rBU-Jbv3A,50
|
|
22
|
+
dbus2mqtt-0.4.1.dist-info/licenses/LICENSE,sha256=a4bIEgyA9rrnAfUN90CgbgZ6BQIFHeABkk0JihiBaxM,1074
|
|
23
|
+
dbus2mqtt-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|