MQTT Dash scripting manual (JavaScript)


Text metric ⇒ On Receive handler called when payload received for the metric. You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (parseInt(event.payload) > 90) {

    app.publish('messages/alert', 'HOT', false, 0);

}


Text metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.text - (String) Main text to display.

 

event.textColor - (HEX String) Main text color. E.g. "#ffffcc".

 

Example:

if (parseInt(event.getLastPayload()) > 90) {

    event.text = 'HOT';

    event.textColor = '#ffcccc';

} else {

    event.textColor = '#ffffff';

}


Text metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/alert', event.data, false, 0);

}


Switch metric ⇒ On Receive handler called when payload received for the metric. You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (event.payload == '1') {

    app.publish('messages/alert', 'ON', false, 0);

} else {

    app.publish('messages/alert', 'OFF', false, 0);

}


Switch metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.on - (Boolean) You can set this property in order to change the switch status to ON or OFF.

 

event.iconColor - (HEX String) Icon color. E.g. "#ffffcc".

 

Example:

if (parseInt(event.getLastPayload()) == 1) {

    event.iconColor = '#ffcccc';

} else {

    event.iconColor = '#ffffff';

}


Switch metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/alert', event.data, false, 0);

}


Range/progress metric ⇒ On Receive handler called when payload received for the metric. You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (parseInt(event.payload) > 90) {

    app.publish('messages/alert', 'TOO HOT', false, 0);

} else {

    app.publish('messages/status', 'NORMAL', false, 0);

}


Range/progress metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.progressColor - (HEX String) Main text color. E.g. "#ffffcc".

 

Example:

if (parseInt(event.getLastPayload()) > 90) {

    event.progressColor = '#ffcccc';

} else {

    event.progressColor = '#ffffff';

}


Range/progress metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/status', event.data, false, 0);

}


Multi choice metric ⇒ On Receive handler called when payload received for the metric. You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (parseInt(event.payload) > 90) {

    app.publish('messages/alert', 'HOT', false, 0);

}


Multi choice metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.text - (String) Main text to display.

 

event.textColor - (HEX String) Main text color. E.g. "#ffffcc".

 

Example:

if (parseInt(event.getLastPayload()) > 90) {

    event.textColor = '#ffcccc';

} else {

    event.textColor = '#ffffff';

}


Multi choice metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/alert', event.data, false, 0);

}


Image metric ⇒ On Receive handler called when payload received for the metric (called only if you've selected "Image URL in payload" setting). You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (parseInt(event.payload) == 'rain') {

    event.payload = 'http://example.com/rainy.png';

} else if (parseInt(event.payload) == 'sun') {

    event.payload = 'http://example.com/sunny.png';

}


Image metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.url - (String) Image URL to download and display.

 

Example:

if (event.getLastPayload() == '') {

    event.url = 'http://example.com/rainy.png';

} else {

    event.url = 'http://example.com/sunny.png';

}


Image metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/alert', event.data, false, 0);

}


Color metric ⇒ On Receive handler called when payload received for the metric. You can use:

app.publish(topic, payload, retained, qos); - Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.payload - (String) Received raw payload string. You can modify/transform it before it'll be processed and displayed.

 

event.topic - (String) Topic, to which payload was received.

 

Example:

if (event.payload == 'red') {

    event.payload = '#FF0000';

} else if (event.payload == 'green') {

    event.payload = '#2AFF00';

} else if (event.payload == 'blue') {

    event.payload = '#002BFF';

}


Color metric ⇒ On Display handler called when tile needs to be updated/re-rendered, e.g. contents or last activity time changed. Usually it happens once per second for all visible tiles. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.getSecondsSinceLastActivity() - (Integer) Returns number of seconds, elapsed since last payload was received.

 

event.lastActivityString - (String) Text to display at the bottom of tile.

 

event.blink - (Boolean) Tile will blink if value of the property is true.

 

event.name - (String) Text to be shown at the top of tile.

 

event.getLastPayload() - (String) Returns last received raw payload.

 

event.color - (HEX String) Icon color. E.g. "#ffffcc".

 

Example:

if (event.getLastPayload() == 'red') {

    event.color = '#FF0000';

} else if (event.getLastPayload() == 'green') {

    event.color = '#2AFF00';

} else if (event.getLastPayload() == 'blue') {

    event.color = '#002BFF';

}


Color metric ⇒ On Click handler called when user taps/clicks on the tile. You can use:

app.publish(topic, payload, retained, qos); - Publish to payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer).

 

app.openUri(uri); - Open specified uri (String) in an external app. uri examples: http://www.example.com/page.html, tel:123content://contacts/people/

 

event.data - (Any type) Custom runtime data. You can get/set any data, which you need to be preserved between calls. The data shared between On Receive, On Display, On Tap. So you can set data in On Receive and use this data later in On Display. The data not preserved between app launches.

 

event.preventDefault - (Boolean) False by default. If True, default tap event behavoiur will be disabled.

 

Example:

event.preventDefault = true;

if (event.data) {

    app.publish('messages/alert', event.data, false, 0);

}