diff options
author | Zach Russell <zachatrocity@gmail.com> | 2023-05-02 01:27:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 09:27:27 +0200 |
commit | 6d2d9baf35b1772409162e86f6d4b7f9374edb2e (patch) | |
tree | 4c843a75f992a360b5cf0ba4fd84afe681e087d3 | |
parent | 1707f5adaddb90a126be4b60284921facb6d37ff (diff) | |
download | homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.tar.gz homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.tar.zst homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.zip |
Fixed OctoPrint ‘text’ display when idle. (#607)
* Added moonraker support and temperature when idle
* removed config change
* Delete package-lock.json
-rw-r--r-- | docs/customservices.md | 12 | ||||
-rw-r--r-- | dummy-data/octoprint/api/printer | 27 | ||||
-rw-r--r-- | src/components/services/OctoPrint.vue | 20 |
3 files changed, 53 insertions, 6 deletions
diff --git a/docs/customservices.md b/docs/customservices.md index 31d302b..665c6f5 100644 --- a/docs/customservices.md +++ b/docs/customservices.md | |||
@@ -31,7 +31,7 @@ within Homer: | |||
31 | - [Speedtest Tracker](#SpeedtestTracker) | 31 | - [Speedtest Tracker](#SpeedtestTracker) |
32 | - [What's Up Docker](#whats-up-docker) | 32 | - [What's Up Docker](#whats-up-docker) |
33 | - [SABnzbd](#sabnzbd) | 33 | - [SABnzbd](#sabnzbd) |
34 | - [OctoPrint](#sabnzbd) | 34 | - [OctoPrint](#octoprint) |
35 | - [Tdarr](#tdarr) | 35 | - [Tdarr](#tdarr) |
36 | 36 | ||
37 | If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page. | 37 | If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page. |
@@ -384,15 +384,17 @@ the "Config" > "General" section of the SABnzbd config in the SABnzbd web UI. | |||
384 | downloadInterval: 5000 # (Optional) Interval (in ms) for updating the download count | 384 | downloadInterval: 5000 # (Optional) Interval (in ms) for updating the download count |
385 | ``` | 385 | ``` |
386 | 386 | ||
387 | ## OctoPrint | 387 | ## OctoPrint/Moonraker |
388 | 388 | ||
389 | The OctoPrint service only needs an `apikey` & `url` and optionally a `display` option. | 389 | The OctoPrint/Moonraker service only needs an `apikey` & `endpoint` and optionally a `display` or `url` option. `url` can be used when you click on the service it will launch the `url` |
390 | |||
391 | Moonraker's API mimmicks a few of OctoPrint's endpoints which makes these services compatible. See https://moonraker.readthedocs.io/en/latest/web_api/#octoprint-api-emulation for details. | ||
390 | 392 | ||
391 | ```yaml | 393 | ```yaml |
392 | - name: "Octoprint" | 394 | - name: "Octoprint" |
393 | logo: "https://cdn-icons-png.flaticon.com/512/3112/3112529.png" | 395 | logo: "https://cdn-icons-png.flaticon.com/512/3112/3112529.png" |
394 | apikey: "xxxxxxxxxxxx" # insert your own API key here. Request one from https://openweathermap.org/api. | 396 | apikey: "xxxxxxxxxxxx" # insert your own API key here. |
395 | url: "http://192.168.0.151:8080" | 397 | endpoint: "http://192.168.0.151:8080" |
396 | display: "text" # 'text' or 'bar'. Default to `text`. | 398 | display: "text" # 'text' or 'bar'. Default to `text`. |
397 | type: "OctoPrint" | 399 | type: "OctoPrint" |
398 | ``` | 400 | ``` |
diff --git a/dummy-data/octoprint/api/printer b/dummy-data/octoprint/api/printer new file mode 100644 index 0000000..b8bbe98 --- /dev/null +++ b/dummy-data/octoprint/api/printer | |||
@@ -0,0 +1,27 @@ | |||
1 | { | ||
2 | "temperature": { | ||
3 | "bed": { | ||
4 | "actual": 20.52, | ||
5 | "offset": 0, | ||
6 | "target": 0.0 | ||
7 | }, | ||
8 | "tool0": { | ||
9 | "actual": 20.44, | ||
10 | "offset": 0, | ||
11 | "target": 0.0 | ||
12 | } | ||
13 | }, | ||
14 | "state": { | ||
15 | "text": "Operational", | ||
16 | "flags": { | ||
17 | "operational": true, | ||
18 | "paused": false, | ||
19 | "printing": false, | ||
20 | "cancelling": false, | ||
21 | "pausing": false, | ||
22 | "error": false, | ||
23 | "ready": true, | ||
24 | "closedOrError": false | ||
25 | } | ||
26 | } | ||
27 | } \ No newline at end of file | ||
diff --git a/src/components/services/OctoPrint.vue b/src/components/services/OctoPrint.vue index c5da8d9..1428d9a 100644 --- a/src/components/services/OctoPrint.vue +++ b/src/components/services/OctoPrint.vue | |||
@@ -6,7 +6,7 @@ | |||
6 | <template v-if="item.subtitle && !state"> | 6 | <template v-if="item.subtitle && !state"> |
7 | {{ item.subtitle }} | 7 | {{ item.subtitle }} |
8 | </template> | 8 | </template> |
9 | <template v-if="!error && display == 'text'"> | 9 | <template v-if="!error && display == 'text' && statusClass == 'in-progress'"> |
10 | <i class="fa-solid fa-gear mr-1"></i> | 10 | <i class="fa-solid fa-gear mr-1"></i> |
11 | <b v-if="completion">{{ completion.toFixed() }}%</b> | 11 | <b v-if="completion">{{ completion.toFixed() }}%</b> |
12 | <span class="separator mx-1"> | </span> | 12 | <span class="separator mx-1"> | </span> |
@@ -15,6 +15,12 @@ | |||
15 | {{ toTime(printTime) }} | 15 | {{ toTime(printTime) }} |
16 | </span> | 16 | </span> |
17 | </template> | 17 | </template> |
18 | <template v-if="!error && display == 'text' && statusClass == 'ready'"> | ||
19 | <i class="fa-solid fa-temperature-half mr-1"></i> | ||
20 | <b v-if="printer.temperature.bed">{{ printer.temperature.bed.actual.toFixed() }} C</b> | ||
21 | <span class="separator mx-1"> | </span> | ||
22 | <b v-if="printer.temperature.tool0">{{ printer.temperature.tool0.actual.toFixed() }} C</b> | ||
23 | </template> | ||
18 | <template v-if="!error && display == 'bar'"> | 24 | <template v-if="!error && display == 'bar'"> |
19 | <progress | 25 | <progress |
20 | v-if="completion" | 26 | v-if="completion" |
@@ -55,6 +61,7 @@ export default { | |||
55 | printTimeLeft: null, | 61 | printTimeLeft: null, |
56 | completion: null, | 62 | completion: null, |
57 | state: null, | 63 | state: null, |
64 | printer: null, | ||
58 | error: null, | 65 | error: null, |
59 | }), | 66 | }), |
60 | computed: { | 67 | computed: { |
@@ -73,6 +80,7 @@ export default { | |||
73 | }, | 80 | }, |
74 | created() { | 81 | created() { |
75 | this.display = this.item.display == "bar" ? this.item.display : "text"; | 82 | this.display = this.item.display == "bar" ? this.item.display : "text"; |
83 | this.fetchPrinterStatus(); | ||
76 | this.fetchStatus(); | 84 | this.fetchStatus(); |
77 | }, | 85 | }, |
78 | methods: { | 86 | methods: { |
@@ -89,6 +97,16 @@ export default { | |||
89 | console.error(e); | 97 | console.error(e); |
90 | } | 98 | } |
91 | }, | 99 | }, |
100 | fetchPrinterStatus: async function () { | ||
101 | try { | ||
102 | const response = await this.fetch(`api/printer?apikey=${this.item.apikey}`); | ||
103 | this.printer = response; | ||
104 | this.error = response.error; | ||
105 | } catch (e) { | ||
106 | this.error = `Fail to fetch octoprint data (${e.message})`; | ||
107 | console.error(e); | ||
108 | } | ||
109 | }, | ||
92 | toTime: function (timastamp) { | 110 | toTime: function (timastamp) { |
93 | return new Date(timastamp * 1000).toTimeString().substring(0, 5); | 111 | return new Date(timastamp * 1000).toTimeString().substring(0, 5); |
94 | }, | 112 | }, |