Skip to content

Instantly share code, notes, and snippets.

@ChadDevOps
Last active December 20, 2022 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChadDevOps/81d1d78a18490bf8b86a9e0a625dc512 to your computer and use it in GitHub Desktop.
Save ChadDevOps/81d1d78a18490bf8b86a9e0a625dc512 to your computer and use it in GitHub Desktop.
IFTTT Octoprint Notification to Pushover (iPhone and Apple Watch Glances)

Octoprint IFTTT Pushver Over with Glances

Send pushover notification with glances (iPhone - Apple Watch) from Octoprint.

Prerequisites

Getting Started

IFTTT

Connect pushover to your account.

  1. Create a webhook applet (see image in this gist)
  2. Add filter code (see Filter Code section in gist)
  3. Add pushover widget event and update Widget to your iPhone from pushover (leave defaults - updated from filter code)
  4. Add pushover notification event and update device/group (leave defaults - updated from filter code)

Octoprint

Install Octo Plugin and make the following changes:

  1. Add IFTTT Webhook: https://maker.ifttt.com/trigger/{event}/json/with/key/{key} - Replace {event} with your applet slug and {key} with your IFTTT webhook key.
  2. Update the Octo plugin and use template "Full Data Example" (not necessary to have ALL data, useful if additional details are warranted in filter code)
  3. Under DATA, remove: "snapshot": "@snapshot" - also remove previous line's comma.
{
  "deviceIdentifier":"@deviceIdentifier",
  "apiSecret":"@apiSecret",
  "topic":"@topic",
  "message":"@message",
  "extra":"@extra",
  "state": "@state",
  "job": "@job",
  "progress": "@progress",
  "currentZ": "@currentZ",
  "offsets": "@offsets",
  "meta": "@meta",
  "currentTime": "@currentTime"
}
  1. Update the Octo plugin triggers to your preferences.
  2. Update widget, device, or group under the two IFTTT events.

Notes

  • Percentage on Apple Watch only updates on new notifications.
  • Modify filter code as needed.
  • Glances on apple watchOS has a limit of 50 updates per day
// Add your code here. All actions will run unless you explicitly skip them.
// Quick tips!
// Auto-complete is on. Start typing to see ingredient options.
// Hover over any ingredient to see the variable type and an example.
// TypeScript v2.92
/*
Octoprint Webhook Plugin: https://plugins.octoprint.org/plugins/webhooks/
Webhook: https://maker.ifttt.com/trigger/{event}/json/with/key/{key}
Your IFTTT Key: https://ifttt.com/maker_webhooks - Click on Documentation
1. Update octoprint plugin to use the template "Full Data Example"
2. Under DATA, remove: "snapshot": "@snapshot"
{
"deviceIdentifier":"@deviceIdentifier",
"apiSecret":"@apiSecret",
"topic":"@topic",
"message":"@message",
"extra":"@extra",
"state": "@state",
"job": "@job",
"progress": "@progress",
"currentZ": "@currentZ",
"offsets": "@offsets",
"meta": "@meta",
"currentTime": "@currentTime"
}
3. Update the Octoprint plugin triggers to your preferences.
4. Update widget, device, or group under the two IFTTT events.
*/
let payload = JSON.parse(MakerWebhooks.jsonEvent.JsonPayload);
let title = "" + payload.topic;
let text = payload.message + ". ";
let subtext = "";
if (payload.progress.printTimeLeft != null){
subtext = 'Print time left: ' + payload.progress.printTimeLeft + 'seconds. ';
}
let count = "";
let percent = `0`;
if (payload.progress.completion != null){
percent = String(Math.floor(payload.progress.completion));
}
Pushover.glance.setTitle(title);
Pushover.glance.setText(text);
Pushover.glance.setSubtext(subtext);
Pushover.glance.setCount(count);
Pushover.glance.setPercent(`${percent}`)
let message = text + subtext + `Percent Complete: ${percent}%`
Pushover.send.setTitle(title)
Pushover.send.setMessage(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment