text device, with api call for updating text

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
alfa001
Posts: 12
Joined: 26 Jan 2021 21:39

text device, with api call for updating text

Post by alfa001 »

In other home automation systems I was always using a simple widget/module/app where text/label/message was updatable using an api call.
For instance an information string with cpu temp/temp/disk space etc (instead of using snmp), or the result of whatever push-button function/macro/script.

I have searched through the apps for text and label, but no app seems to have this.
Is there a better way in this framework perhaps? An app showing a message log?

Looking at the examples, I guess it might not be very tricky to create a new app for this purpose, but I am sure someone already did this.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: text device, with api call for updating text

Post by PoltoS »

You can use the CodeDevice (or HTTPDevice) app to show temp, disc space, etc. You can also use InfoWidget and API to change it's text if you really need text only instead of number + scale units.
alfa001
Posts: 12
Joined: 26 Jan 2021 21:39

Re: text device, with api call for updating text

Post by alfa001 »

Thank you!
I made a module creating a vDev deviceType text. I wanted to use the Virtual Device API, and this seems to work.

// Create vdev
self.vDev = self.controller.devices.create({
deviceId: "LabelDevice_" + this.id,
// contains initial values for UI when module is created
defaults: {
metrics: {
title: self.config.wtitle,
text: self.langFile.v_text
}
}, // defaults
// how module is presented in UI
overlay: {
deviceType: 'text'
}, // overlay
handler: function(command, args) {
if (command === 'on' || command === 'off') {
return;
}
if (command === 'set' && args) {
console.log("command", command);
console.log("args", args);
if (args.title) {
this.set("metrics:title", args.title);
}
if (args.text) {
this.set("metrics:text", args.text);
}
}
}, // handler
moduleId: self.id
}); // self.vDev

Does the text deviceType support html in the text metric? I can see bold text in in the InfoWidget, so I guess some type of markup is supported.
alfa001
Posts: 12
Joined: 26 Jan 2021 21:39

Re: text device, with api call for updating text

Post by alfa001 »

yes, it seems to support html
markup is stripped when using the GUI api information, but it works :-)
Post Reply