Prusalink customapi example for homepage
I've switched to prusalink/prusaconnect recently from octoprint and missed the nice homepage integration so have knocked the following up, you just need to update your IP and api key and you should be sorted. Thought it may be of use to others.
Initially there is no api key generated on a prusalink install and it will be blank, you just need to click reset and it'll create this one. This won't affect the printers connection to prusaconnect if your using that also.
I am using pi zero's but do not have them powered from the printer board so i can power the printers off when not in use. When you do this however the status that then gets returned is ERROR. I've remapped that to show powered off which works in my case but you can always remove that part.
I've used the additional field option so that the target and actual temp of the nozzle and bed are shown on a single line rather than taking up 4 lines. As it's a list you can just append more onto the end.
I've used /api/v1/status rather than /api/v1/job as it returns data even when a job is not running and you also get the extra information such as nozzle temps etc. One point to note is that the temp data will remain even if you power off the printer so if the nozzle was still at say 60 degrees and you power off the printer it won't get an updated value until you power the printer back on so will still show 60 no matter how long after. Not a biggie but just one to be aware of. Interesting also that the target temps don't get updated until it's actually printing so while it's doing the bed leveling etc it shows the target as 0 even though it's already up to temp.
I also posted this in the homepage discussions area which has better formatting of the code. github link
- Prusa MK3s 1:
icon: mdi-printer-3d-nozzle href: http://<printer IP>/ description: Main printer widget: type: customapi url: http://<printer IP>/api/v1/status refreshInterval: 10000 # optional - in milliseconds, defaults to 10s method: GET # optional, e.g. POST headers: X-Api-Key: <api key> display: list mappings: - field: job: progress format: percent label: Progress remap: - value: Null to: 0 - field: printer: state format: text label: Status remap: - value: "ERROR" to: "Powered off" - field: job: time_remaining format: number label: Time Remaining suffix: " minutes" scale: 0.0166667 # Converts seconds to minutes - field: job: time_printing format: number label: Time Printing suffix: " minutes" scale: 0.0166667 # Converts seconds to minutes - field: printer: temp_nozzle label: Nozzle Temp / Target format: number suffix: "c" additionalField: field: printer: target_nozzle format: number suffix: "c" - field: printer: temp_bed label: Nozzle Bed / Target format: number suffix: "c" additionalField: field: printer: target_bed format: number suffix: "c" - field: printer: fan_hotend label: Hotend Fan Speed format: number
suffix: "rpm"
Comments