diff --git a/packages/mqtt/mqtt.mjs b/packages/mqtt/mqtt.mjs index 96659c67b..a84628567 100644 --- a/packages/mqtt/mqtt.mjs +++ b/packages/mqtt/mqtt.mjs @@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see . */ -import { Pattern, isPattern } from '@strudel/core'; +import { Pattern, isPattern, createParams } from '@strudel/core'; import Paho from 'paho-mqtt'; const connections = {}; @@ -118,3 +118,11 @@ Pattern.prototype.mqtt = function ( return hap.setContext({ ...hap.context, onTrigger, dominantTrigger: true }); }); }; + + +// This adds the 'move' and 'motor' commands to strudel +export const { move, motor } = createParams('move', 'motor'); window.move = move; window.motor = motor; +// This adds the 'robot' command +Pattern.prototype.robot = function (robot_id, address = 'ws://192.168.8.248:9001/mqtt') { + return this.mqtt(undefined, undefined, '/move/' + robot_id, address); +};