RZL: Add 3D printer time remaining (#78)

* RZL: Add 3D printer time remaining

This pull request closes #20.
This commit is contained in:
Ranlvor 2018-09-02 12:45:36 +02:00 committed by uwap
parent 3375c798dc
commit 37c9f524cd

View file

@ -186,6 +186,21 @@ const config: Config = {
},
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 "unavailable";
} else {
const secondsLeft = json["time_total"] - json["time_elapsed"];
return new Date(secondsLeft * 1000).toISOString().substr(11, 8);
}
}
},
defaultValue: "unavailable"
},
nebenraumPowerStatus: {
state: {
name: "/service/nebenraum-power",
@ -472,6 +487,12 @@ const config: Config = {
max: 1,
text: "Printing Progress",
topic: "printer_3d_progress"
},
{
type: "text",
text: "Time Left",
icon: mdi("clock"),
topic: "printer3Dremaining"
}
]
},