RZL: Add 3D printer time remaining

This pull request closes #20. It was rewritten because I deemed that the merge
of the stale pull-request  #20 is harder than rewriting the whole thing.
This commit is contained in:
Ranlvor 2018-09-02 03:46:31 +02:00
parent e3c11c19cd
commit 16ac2f0a40
Signed by untrusted user who does not match committer: Ranlvor
GPG key ID: 5E12D04750EF6F8E

View file

@ -145,6 +145,21 @@ const config: Config = {
}, },
defaultValue: "0" defaultValue: "0"
}, },
printer3Dremaining: {
state: {
name: "/service/ultimaker/job",
type: (msg) => {
const json = JSON.parse(msg.toString())
if(!json || !json["time_elapsed"] || !json["time_total"]) {
return ""
} else {
const secondsLeft = json["time_total"] - json["time_elapsed"]
return new Date(secondsLeft * 1000).toISOString().substr(11, 8);
}
}
},
defaultValue: ""
},
nebenraumPowerStatus: { nebenraumPowerStatus: {
state: { state: {
name: "/service/nebenraum-power", name: "/service/nebenraum-power",
@ -383,6 +398,12 @@ const config: Config = {
max: 1, max: 1,
text: "Printing Progress", text: "Printing Progress",
topic: "printer_3d_progress" topic: "printer_3d_progress"
},
{
type: "text",
text: "Time Left",
icon: mdi("clock"),
topic: "printer3Dremaining"
} }
] ]
}, },