mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 13:48:40 +00:00
allow duration and cps metadata to be added to mqtt messages (#1279)
This commit is contained in:
parent
981ad1e242
commit
8bde61fa27
@ -35,6 +35,7 @@ Pattern.prototype.mqtt = function (
|
|||||||
host = 'wss://localhost:8883/',
|
host = 'wss://localhost:8883/',
|
||||||
client = undefined,
|
client = undefined,
|
||||||
latency = 0,
|
latency = 0,
|
||||||
|
add_meta = true,
|
||||||
) {
|
) {
|
||||||
const key = host + '-' + client;
|
const key = host + '-' + client;
|
||||||
let connected = false;
|
let connected = false;
|
||||||
@ -88,7 +89,12 @@ Pattern.prototype.mqtt = function (
|
|||||||
}
|
}
|
||||||
let message = '';
|
let message = '';
|
||||||
if (typeof hap.value === 'object') {
|
if (typeof hap.value === 'object') {
|
||||||
message = JSON.stringify(hap.value);
|
let value = hap.value;
|
||||||
|
if (add_meta) {
|
||||||
|
const duration = hap.duration.div(cps);
|
||||||
|
value = { ...value, duration: duration.valueOf(), cps: cps };
|
||||||
|
}
|
||||||
|
message = JSON.stringify(value);
|
||||||
} else {
|
} else {
|
||||||
message = hap.value;
|
message = hap.value;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user