This commit is contained in:
Ranlvor 2018-01-20 16:13:15 +00:00 committed by GitHub
commit c3890ca225

View file

@ -147,6 +147,35 @@ const config : Config = {
return msg.toString()
}
}
},
printer_3d_remaining: {
state: "/service/ultimaker/job",
command: "",
defaultValue: "",
values: {},
parseState: msg => {
var job = JSON.parse(msg.toString());
if(!job["time_elapsed"] || ! job["time_total"]) {
return "";
} else {
var secondsLeft = job["time_total"] - job["time_elapsed"];
var hours = Math.floor(secondsLeft / (60*60));
var minutes = Math.round(secondsLeft % (60*60) / 60);
var result = "";
if(hours > 1) {
result += hours+" Hours ";
} else if (hours === 1) {
result += hours+" Hour ";
}
if(minutes === 1) {
result += minutes+" Minute";
} else {
result += minutes+" Minutes";
}
return result;
}
}
}
},
utils.esper_topics("afba40", "flyfry"),
@ -452,6 +481,11 @@ const config : Config = {
type: "link",
link: "http://ultimaker.rzl/",
text: "Open Webinterface"
}, {
type: "text",
text: "Time Left",
icon: "clock",
topic: "printer_3d_remaining"
}
]
},