dbus2mqtt 0.3.1__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.

@@ -1,5 +1,6 @@
1
1
  import fnmatch
2
2
  import uuid
3
+ import warnings
3
4
 
4
5
  from dataclasses import dataclass, field
5
6
  from typing import Annotated, Any, Literal
@@ -65,15 +66,29 @@ class FlowTriggerDbusSignalConfig:
65
66
  @dataclass
66
67
  class FlowTriggerBusNameAddedConfig:
67
68
  type: Literal["bus_name_added"] = "bus_name_added"
68
- # filter: str | None = None
69
+
70
+ def __post_init__(self):
71
+ warnings.warn(f"{self.type} flow trigger may be removed in a future version.", DeprecationWarning, stacklevel=2)
69
72
 
70
73
  @dataclass
71
74
  class FlowTriggerBusNameRemovedConfig:
72
75
  type: Literal["bus_name_removed"] = "bus_name_removed"
76
+
77
+ def __post_init__(self):
78
+ warnings.warn(f"{self.type} flow trigger may be removed in a future version.", DeprecationWarning, stacklevel=2)
79
+
80
+ @dataclass
81
+ class FlowTriggerObjectAddedConfig:
82
+ type: Literal["object_added"] = "object_added"
83
+ # filter: str | None = None
84
+
85
+ @dataclass
86
+ class FlowTriggerObjectRemovedConfig:
87
+ type: Literal["object_removed"] = "object_removed"
73
88
  # filter: str | None = None
74
89
 
75
90
  FlowTriggerConfig = Annotated[
76
- FlowTriggerMqttConfig | FlowTriggerScheduleConfig | FlowTriggerDbusSignalConfig | FlowTriggerBusNameAddedConfig | FlowTriggerBusNameRemovedConfig,
91
+ FlowTriggerMqttConfig | FlowTriggerScheduleConfig | FlowTriggerDbusSignalConfig | FlowTriggerBusNameAddedConfig | FlowTriggerBusNameRemovedConfig | FlowTriggerObjectAddedConfig | FlowTriggerObjectRemovedConfig,
77
92
  Field(discriminator="type")
78
93
  ]
79
94
 
@@ -117,6 +132,7 @@ class SubscriptionConfig:
117
132
  @dataclass
118
133
  class DbusConfig:
119
134
  subscriptions: list[SubscriptionConfig]
135
+ bus_type: Literal["SESSION", "SYSTEM"] = "SESSION"
120
136
 
121
137
  def is_bus_name_configured(self, bus_name: str) -> bool:
122
138
 
@@ -125,11 +141,14 @@ class DbusConfig:
125
141
  return True
126
142
  return False
127
143
 
128
- def get_subscription_configs(self, bus_name: str, path: str) -> list[SubscriptionConfig]:
144
+ def get_subscription_configs(self, bus_name: str, path: str|None = None) -> list[SubscriptionConfig]:
129
145
  res: list[SubscriptionConfig] = []
130
146
  for subscription in self.subscriptions:
131
- if fnmatch.fnmatchcase(bus_name, subscription.bus_name) and path == subscription.path:
132
- res.append(subscription)
147
+ if fnmatch.fnmatchcase(bus_name, subscription.bus_name):
148
+ if not path or path == subscription.path:
149
+ res.append(subscription)
150
+ elif fnmatch.fnmatchcase(path, subscription.path):
151
+ res.append(subscription)
133
152
  return res
134
153
 
135
154
  @dataclass