Merge 2704d7b356 into 612bd5ddc8
This commit is contained in:
commit
c3890ca225
1 changed files with 34 additions and 0 deletions
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue