forked from SpotlightKid/osc2mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osc2mqtt.ini
145 lines (131 loc) · 5.92 KB
/
osc2mqtt.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
[options]
; Comma-separated list of MQTT topic filters to subscribe to, e.g.
# subscriptions = licht/+/+, schalter/+/+, +/xy/+
subscriptions = #
osc_port = 9001
; OSC reveiver host[:port], supports UDP multicast too
osc_receiver =
; MQTT broker host[:port]
mqtt_broker = localhost:1883
verbose = false
; Defaults for conversion rules sections below
[DEFAULT]
; Plain string or regular expression matching MQTT topic or OSC address.
; If a regular expression, may contain named or unnamed substring groups.
; See the comments for the 'address_groups' and 'topic_groups' settings below.
; In the example here, everything after the optional slash prefix is group 1
match = ^/?(.*)
; OSC address, a plain string, optionally with string formatting placeholders.
; Placeholders may reference groups from the regular expression set with
; 'match' above and will be replaced with what the respective group matched to.
; Matches by unnamed regular expression groups are passed as positional
; arguments to the formatting function and named groups as keyword arguments.
; Additionally, values decoded from the MQTT payload are passed as a tuple via
; the '_values' keyword argument and thus can be inserted in to the OSC address
; with e.g. '{_values[0]}'.
; See the conversion rules below for a usage example.
; The default value here in combination with 'match' regular expression above
; adds a slash prefix to the MQTT topic, if there wasn't one already.
address = /{0}
; MQTT topic, a plain string, optionally with string formatting placeholders.
; Placeholders may reference groups from the regular expression set with
; 'match' above and will be replaced the what the respective group matched to.
; Matches by unnamed regular expression groups are passed as positional
; arguments to the formatting function and named groups as keyword arguments.
; Additionally, values from the OSC message are passed as a tuple via the
; '_values' keyword argument and thus can be inserted in to the MQTT topic with
; e.g. '{_values[0]}'.
; See the conversion rules below for a usage example.
; The default value here in combination with 'match' regular expression above
; removes the slash prefix from the OSC address.
topic = {0}
; Comma-separated list of group names (unnamed groups are not supported).
; Values in the OSC message's address string matched by the named regex
; groups listed here will be appended to the OSC values of the message
; before encoding the values to the MQTT message payload.
; Only the values matched by the groups listed here will be appended
; and in the order given here. The value for groups with no matches will
; be None.
address_groups =
; Comma-separated list of group names (unnamed groups are not supported).
; Values in the MQTT message's topic string matched by the named regex
; groups listed here will be appended to the values decoded from the
; the MQTT message payload before converting them to OSC values;
; Only the values matched by the groups listed here will be appended
; and in the order given here. The value for groups with no matches will
; be None.
topic_groups =
; MQTT payload encoding type.
; One of: array, json, string, struct
type = struct
; MQTT payload encoding format.
;
; When type = struct, must be a struct.unpack() format string, e.g.:
# format = B ; one unsigned byte
# format = <ffhh ; two floats and two shorts (two-bytes), little-endian
;
; When type = array, must be an array element type char, e.g.
# format = d ; double
;
; When type = json or string, must be the string encoding (default: utf-8)
# format = ascii
format = B
; Comma-separated list of conversion functions to apply to values decoded
; from the MQTT message payload or extracted from the MQTT topic via named
; regex groups. The values matched by the regex groups are appended to the
; values decoded from the MQTT payload in the order they are listed by the
; 'topic_groups' setting.
; Available functions (you can also use the short form in parentheses):
; int (i), float (f), bool (b), str (s)
; Any other function name or an empty string will leave the value as is.
; Leaving this option empty also applies no conversion to any values.
; Example:
# from_mqtt = int, float, , i
from_mqtt =
; Comma-separated list of conversion functions to apply to arguments decoded
; from the OSC message or extracted from the OSC address via named regex
; groups. The values matched by the regex groups are appended to the
; OSC values in the order they are listed by the 'adress_groups' setting.
; Same format as the from_mqtt option.
from_osc =
; List of OSC type tags as a string with no separator
; This is only necessary if the internal Python type representation
; of the values can not be converted into OSC types automatically.
; See the conversion table in the pyliblo documentation for details.
osctags =
; Conversion rules sections
; Section names MUST start with a colon (":").
; Conversion rules are matched in the order defined here, so put likely
; matches first for better performance.
[:light]
match = ^/?(licht/.*)
from_mqtt = float
from_osc = int
[:schalter]
match = ^/?(schalter/.*)
osctags = T
[:xypad]
match = ^/?(?P<page>\w+)/xy(?P<pad>/?\d+)?
topic = {page}/xy{pad}
address = /{page}/xy{pad}
format = >ff
[:button]
; An example for extracting values for the MQTT payload from the OSC address
; and setting the OSC address based on values from the MQTT payload:
;
; OSC address:/page1/button1/1 values:[]
; --> MQTT topicpage1/button payload:'\x01'
; OSC address:/page1/button1/2 values:[]
; --> MQTT topic:page1/button payload:'\x02'
; etc.
match = ^/?(?P<page>\w+)/(?P<button>\w+)(/(?P<value>\d+))?
address = /{page}/{button}/{_values[0]}
topic = {page}/{button}
; Extract the value from the OSC address.
address_groups = value
; Convert the match for the 'value' group to an int forthe MQTT payload.
from_osc = int
; Setting this to a comma will yield an empty list and drop all values decoded
; from the MQTT payload, since we will encode the single value we expect in the
; OSC address.
from_mqtt = ,