Jump to content

HOWTO: Pushover notifications for completed prints to your phone


DennisM

Recommended Posts

So, I finally figured out why I had @geekandi's method working for print events, but not for an arbitrary gcode macro.   It turns out I had made some assumptions about what I could, and couldn't, send to apprise.  You can send a message, but can't send a title.  So my final, working, macros look like this:

 

[gcode_macro PUSHOVER_UP_TO_TEMP]
gcode:
  {action_call_remote_method("notify",
                             name="gcode_pushover",
                             message="Chamber is up to temp.")}

# send pushover for actually starting to print the part, not for pre-warmup stuff
[gcode_macro PUSHOVER_PRINTING_NOW]
gcode:
  {action_call_remote_method("notify",
                             name="gcode_pushover",
                             message="Starting Print Now")}

 

I have a macro for each arbitrary printing event I want to send, with whatever Message I want in it.   The method it's calling is in moonraker.conf:

[notifier gcode_pushover]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}
events: gcode
title: rue: {event_message}
body: rue: {event_message}
attach: http://localhost/webcam/?action=snapshot

 

And this works.  W00t.  Now I can alert for any arbitrary message I want to actually message on.....

 

 

 

  • Like 2
Link to comment
Share on other sites

Paul, thanks for sorting that out, I'm going to give it a try for my PAUSE macro. I couldn't get the moonraker version to work (even after changing the event to "pause" vs "paused") so I implemented my shell script version which works perfectly.

But I'd rather use moonraker so I'll add the config to moonraker and try calling it from my PAUSE macro to see if that works; if so then I'll remove my shell script version.

Link to comment
Share on other sites

  • 3 months later...
1 hour ago, airlinetycoon said:

I tried to config the pushover notifications, but I was not successful.

can someone give me a step-by-step guidance?

Hi there, and welcome to the forum.

Can you paste your code and describe the issues you've been having. Providing a bit of context will help others gauge how to help you.

I invite you to post an introduction: https://www.teamfdm.com/forums/forum/39-introductions/

Cheers.

  • Like 1
Link to comment
Share on other sites

16 hours ago, Simon2.4 said:

Hi there, and welcome to the forum.

Can you paste your code and describe the issues you've been having. Providing a bit of context will help others gauge how to help you.

I invite you to post an introduction: https://www.teamfdm.com/forums/forum/39-introductions/

Cheers.

I am a complete Klipper beginner.

What did I do:
I created a moonraker_notoifications.conf.

image.thumb.png.c379beecf6d82301b941a7a4e9886990.png

I have added these lines to moonraker.conf.

image.png.0b0478447a83ea88e0dbefcf6d8d0bfa.pngimage.png.0b0478447a83ea88e0dbefcf6d8d0bfa.png

I have created a moonraker_secrets (what is the correct file extension?).

I have entered the pushover information there as described.

image.thumb.png.4ebe3d2d68f15be7a66997c2e52f5b4c.png

 

 

I hope someone can put it in the right order because I don't think I got it right. Thank you very much!

 

Link to comment
Share on other sites

@airlinetycoon

Also a Klipper novice, but as I was browsing the discussion I assumed the moonraker_secrets file would be copied directly to the pi/computer you're running Klipper on. I assumed that because there is a "path" setting for it. Different than the modifications to the existing "conf" files and the new moonraker-notifications.conf file that is created. 

 

secrets_path: ~/.moonraker_secrets

 

Although since I am a noob on this stuff, the chance I'm quite wrong is probably quite high... 😉

OK, confirmed it works w/the secrets file on the pi, but there have been some changes that affect the setup. The biggest is that the path and file name of the secrets file are no longer configurable - the file must be in specific location on your pi/computer, and name must be moonraker.secrets. If you use the original suggested secrets line in moonraker.conf: 

secrets_path: ~/.moonraker_secrets

...you will get a warning in Klipper.

image.png.35b37454a01017a34ce64a3bc9816cd9.png

From https://moonraker.readthedocs.io/en/latest/configuration/

image.thumb.png.90d6e21c5b9e6ca774af0c2c0734e0ca.png

Following above instructions: 

1. Create the file named moonraker.secrets w/the contents as specified by @geekandi 

2. Copy that file to the printer_data folder on your pi/computer

Once that's done things boot up normally and all the magic works! 

Edited by Danabw
Tried it out and confirmed.
  • Like 1
Link to comment
Share on other sites

  • 9 months later...

I've probably made a beginner's mistake, but I can't find the information to get out of it.
My test is on a Neptune 4 Pro, but the klipper should be configurable in the same way and in any case, apprise is added in the pip environment packages.
I used the examples of gcode presented above and I have the following error in the klipper log:

Remote Call Error
Traceback (most recent call last):
  File "/home/mks/klipper/klippy/extras/gcode_macro.py", line 93, in _action_call_remote_method
    webhooks.call_remote_method(method, **kwargs)
  File "/home/mks/klipper/klippy/webhooks.py", line 391, in call_remote_method
    "Remote method '%s' not registered" % (method))
CommandError: Remote method 'notify' not registered

Can anyone point me in the direction of a solution?
Thanks in advance!

Link to comment
Share on other sites

  • 1 month later...

Since I did all of the stuff in this thread last year, I had to rebuild my Pi / Klipper setup since the SD card failed on the printer.

I started over and reflashed a new card, used kiauh to install things, and then copied my config files over to the new setup. But the thing that's not working is this notifier part. Moonraker gives me an error:

 

Moonraker warning

Failed to load notifier[notifier pushover_complete]
Error rending Jinja2 Template

Moonraker warning

Failed to load notifier[notifier pushover_complete]
Error rending Jinja2 Template

Looking through it....

 

Link to comment
Share on other sites

OK, basically gave up trying to make this work and will move on to the next phase of notifications from my Voron.

I found a mainsail integration that works with Home Assistant and it grabs all kinds of data from the printer, so I'll just create some automations that fire when certain events occur on the printer.

This will be much easier for me than trying to figure out why the "notify" parts are no longer working for me.

Link to comment
Share on other sites

Agreed. The HA integration is fairly easy to set up, and HA has TONS of ways to grab triggers and send you notifications. I have it send me a job complete notification with a snapshot from the webcam for example. Another really nice thing is if you are subscribed to Nabu Casa for access to HA outside of your own network (or have set that up yourself), Moonraker comes along for the ride; no complicated setup to drill secure tunnels through your firewall.

Link to comment
Share on other sites

13 hours ago, claudermilk said:

Agreed. The HA integration is fairly easy to set up, and HA has TONS of ways to grab triggers and send you notifications. I have it send me a job complete notification with a snapshot from the webcam for example. Another really nice thing is if you are subscribed to Nabu Casa for access to HA outside of your own network (or have set that up yourself), Moonraker comes along for the ride; no complicated setup to drill secure tunnels through your firewall.

Could you point to some ressources on the Net for discovering this marvelous world meeting Home Assistant and 3D Printers please ?

Link to comment
Share on other sites

Ughh.... I'm going to get rid of the moonraker / HA stuff and go back to trying to make pushover work locally. The main reason is that when my printer is off the HA logs get FILLED up with this crap:

2024-02-14 05:51:23.296 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]
2024-02-14 05:51:53.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting
2024-02-14 05:51:56.290 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]
2024-02-14 05:52:26.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting
2024-02-14 05:52:29.281 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]
2024-02-14 05:52:59.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting
2024-02-14 05:53:02.305 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]
2024-02-14 05:53:32.225 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting
2024-02-14 05:53:35.297 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]
2024-02-14 05:54:05.222 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting
2024-02-14 05:54:08.292 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]

I am manually disabling / enabling the moonraker integration, but at this point it's not working out for me since all I use it for is print pause & completed pushover messages.

 

https://github.com/marcolivierarsenault/moonraker-home-assistant

if you want to use it -- you install via HACS first, then enable the integration in the settings.

Link to comment
Share on other sites

  • 4 weeks later...

OK this whole notifier thing has become quite frustrating - I wish things worked like they used to. Here' a quick summary of my stuff recently:

  1. I had a failed SD card in my Voron so I replaced it and had to rebuild everything. Wasn't a big deal.
  2. Since then everything updated and broke the pushover notifications.
  3. Tried the Homeassistant Moonraker integration and that worked but generated too many log errors when the printer was off.
  4. Tried going back to this moonraker setup and it's not working. I get errors like:
Moonraker warning

Failed to load notifier[notifier print_complete]
Error rending Jinja2 Template
Moonraker warning

Failed to load notifier[notifier print_paused]
Error rending Jinja2 Template
Moonraker warning

Unparsed config option 'events: complete' detected in section [notifier print_complete]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.
Moonraker warning

Unparsed config option 'body: Voron2.4: Print completed {event_args[1].filename}' detected in section [notifier print_complete]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.

Anyone have a current working notifier for pushover?

Link to comment
Share on other sites

Doing it through HA is pretty easy. Use the Moonraker integration and set up an automation. Here's the YAML for one of mine:

alias: Blue Trident Job Complete
description: Trident finishes a print job.
trigger:
  - platform: state
    entity_id:
      - sensor.bluetrident_current_print_state
    from: printing
    to: complete
condition: []
action:
  - service: script.blutrident_snapshot
    data: {}
  - service: notify.mobile_app_chris_samsung_galaxy_s21
    data:
      title: Print Job Complete
      message: Blue Trident has completed a print job!
      data:
        ttl: 0
        priority: high
        notification_icon: mdi:printer-3d
        group: 3D_Printer
        image: >-
          https://xfh7t3j9w153axjldxatpeg8426afxsy.ui.nabu.casa/local/tmp/bluetrident_jobcomplete.jpg
mode: single

In the data section I'm doing some fancy stuff. Give it a 3D printer icon in the notification, and take a framegrab from the web cam to attach to the notification.

Link to comment
Share on other sites

This is soooo frustrating. I copy and paste a real example from the moonraker config docs and it fails!!

https://moonraker.readthedocs.io/en/latest/configuration/?h=http#examples

[power generic_tasmota]
type: http
on_url:
  # Build the query string so we can encode it.  This example assumes a password is
  # supplied in a "secrets" file.  If no password is required the "password" field can
  # be omitted or set to an empty string
  {% set qs = {"user": "admin", "password": secrets.tasmota.password, "cmnd": "Power1 on"} %}
  http://tasmota-switch.lan/cm?{qs|urlencode}
off_url:
  {% set qs = {"user": "admin", "password": secrets.tasmota.password, "cmnd": "Power1 off"} %}
  http://tasmota-switch.lan/cm?{qs|urlencode}
status_url:
  {% set qs = {"user": "admin", "password": secrets.tasmota.password, "cmnd": "Power1"} %}
  http://tasmota-switch.lan/cm?{qs|urlencode}
response_template:
  # The module will perform the "GET" request using the appropriate url.
  # We use the `last_response` method to fetch the result and decode the
  # json response.  Tasmota devices return a similar response for all
  # commands, so the response does not require special processing.
  {% set resp = http_request.last_response().json() %}
  # The expression below will render "on" or "off".
  {resp["POWER1"].lower()}

Throws errors. This makes it VERY hard to try and figure out a solution here....

Moonraker warning

Unparsed config option 'status_url:
{% set qs = {"user": "admin", "password": secrets.tasmota.password, "cmnd": "Power1"} %}
http://tasmota-switch.lan/cm?{qs|urlencode}' detected in section [power generic_tasmota]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.
Moonraker warning

Unparsed config option 'response_template:
{% set resp = http_request.last_response().json() %}
{resp["POWER1"].lower()}' detected in section [power generic_tasmota]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.

 

Is it just me?? I don't understand how this isn't broken for everyone....

At this point I gave up on all the moonraker notification options and am trying to do something that should be real simple:

"When a print is done, call a URL with an http GET."

That's all I want to do.... doesn't seem easy unfortunately but it should be...

 

 

Link to comment
Share on other sites

As I mentioned before, I can't use the moonraker integration (as much as I would love to) as it generates very spammy log errors when the printer is off.

HA logs that is. It's mentioned in many places on the web and people complain about this, so I'm not the only on here.

There's a thread on the github page for the author and he's aware of the messages and agrees it would be nice if it wasn't so noisy but hasn't figured out a way to fix it.

Link to comment
Share on other sites

Interesting development. I am going with the moonraker telegram bot thing and so far it's working. It's like a chat bot for your printer but most importantly I can get messages on my phone of printer status changes, etc.

I'll post an update with my findings but so far at this least gives me some communication to my printer.

https://github.com/Raabi91/moonraker-telegram/tree/master

Required me to install the app on my phone, as well as the desktop app, and create a telegram app, get API keys, etc. but so far it's not too difficult and is working.

Also I installed this script so I can use a gcode command to send a telegram message if I like:

https://github.com/ericpskl/gcode_telegram

https://github.com/ericpskl/gcode_telegram

SEND_TELEGRAM BOT=bot MESSAGE="Out of filament"

 

Link to comment
Share on other sites

  • 10 months later...
On 3/15/2024 at 4:33 PM, DennisM said:

OK this whole notifier thing has become quite frustrating - I wish things worked like they used to. Here' a quick summary of my stuff recently:

  1. I had a failed SD card in my Voron so I replaced it and had to rebuild everything. Wasn't a big deal.
  2. Since then everything updated and broke the pushover notifications.
  3. Tried the Homeassistant Moonraker integration and that worked but generated too many log errors when the printer was off.
  4. Tried going back to this moonraker setup and it's not working. I get errors like:
Moonraker warning

Failed to load notifier[notifier print_complete]
Error rending Jinja2 Template
Moonraker warning

Failed to load notifier[notifier print_paused]
Error rending Jinja2 Template
Moonraker warning

Unparsed config option 'events: complete' detected in section [notifier print_complete]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.
Moonraker warning

Unparsed config option 'body: Voron2.4: Print completed {event_args[1].filename}' detected in section [notifier print_complete]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.

Anyone have a current working notifier for pushover?

As I was stumbling accross this old thread, when reasearching pushover notifications, I thought I would chime in.

 

Short backstory: Had a fine octoprint install with pushover notification working, but transformed one printer to Klipper and thought I would go the full way and go with mainsail. (For this one printer -- octoprint still going strong for my marlin based other printer).

As I was having octoprint on the raspberry installed via docker, I also wanted to install klipper etc via docker, which I guess could make it easier to avoid clashes. So I went with "prind" which I really can recommend, even if you have to use a newer docker, that is not part of raspbian/debian repos.

 

So my steps were basically following along what was done here:

1.) create moonraker_pushover.conf in your config directory (within the docker container this is /opt/printer_data/config, but this is accessible from outside the container via your prind directory --> prind/config/)

[notifier pushover_error]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}?priority=emergency&expire=3600&retry=300&sound=alien
events: error
title: KobraNeo: EMERG - {event_args[1].filename}
body: {event_name}: {event_args[1].message}
attach: http://raspithinclient/webcam/?action=snapshot

[notifier pushover_cancel]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}?priority=emergency&sound=siren
events: cancelled
title: KobraNeo: EMERG - {event_args[1].filename}
body: {event_name}: {event_args[1].message}
attach: http://raspithinclient/webcam/?action=snapshot


[notifier pushover_pause]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}?priority=high&expire=1800&retry=180&sound=tugboat
events: pause
title: KobraNeo: HIGH - {event_name}d
body: {event_name}d: {event_args[1].filename}
attach: http://raspithinclient/webcam/?action=snapshot

[notifier pushover_resume]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}?priority=high&sound=tugboat
events: resume
title: KobraNeo: HIGH - {event_name}d
body: {event_name}d: {event_args[1].filename}
attach: http://raspithinclient/webcam/?action=snapshot

[notifier pushover_start]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}
events: started
title: KobraNeo: Starting to print
body: Printing: {event_args[1].filename}

[notifier pushover_complete]
url: pover://{secrets.pushover_creds.user}@{secrets.pushover_creds.token}/{secrets.pushover_creds.device}
events: complete
title: KobraNeo: Print completed
body: Completed: {event_args[1].filename}
attach: http://raspithinclient/webcam/?action=snapshot

You see, I just changed it a little bit, just wanted to make it sure it works basically, you can do further modifications if the basis works. Take care to adjust the webcam link, this has my hostname in it.

2.) Include this into moonraker.conf:

[server]
host: 0.0.0.0
port: 7125
klippy_uds_address: /opt/printer_data/run/klipper.sock

[machine]
provider: systemd_cli
validate_service: False

[authorization]
trusted_clients:
  0.0.0.0/0
cors_domains:
  *

[octoprint_compat]

[history]

## Uncomment the following lines if the stack is started with the spoolman profile.
## Add your printers IP address or hostname to the server url.
#
[spoolman]
server: http://raspithinclient/spoolman

[include moonraker_pushover.conf]

3.) This is a crucial and not so easy step to figure out: Set your credentials correctly.

First you have to have an account at pushover.net. There you will find a user key, your device names (e.g. if your android phone has a client installed and you login from there to this account). And you will need to create an API Key for your moonraker.

Pushover.net: pushover.thumb.png.9b270665fcceda4e72a1ff0807c95185.png

Then put these credentials into a file "moonraker.secrets":

[pushover_creds]
user: ************************
token: **********************
device: *********************

So important is here, that user is the "User Key" (see circle "1" in screenshot) NOT YOUR ACCOUNT NAME. And token is the API Token (circle "2") that you created for klipper/moonraker. Device should be optional, as without device, you should get a broadcast on all your devices.

 

If you have this file, it is important to put it in the right place: That is not the config directory (for security reasons) but in my current version of moonraker it is supposed to be in the "printer_data" directory. If you have used the "prind" docker container solution, this directory is "/opt/printer_data/" which is not mapped from outside the container.

So you would need to create/copy that file at/to your raspi (eg. home directory of user pi), go via ssh to that directory and copy from there to the running docker container into /opt/printer_data/:

You can find out the name of the moonraker container via "sudo docker ps", in my case this is "prind-moonraker-1" and the command looks like:

pi@raspiThinClient:~/prind $ sudo docker cp moonraker.secret prind-moonraker-1:/opt/printer_data/
Successfully copied xxxkB to prind-moonraker-1:/opt/printer_data/

 

Be sure to restart the moonraker after adding the configs.

 

I do not know how to fire an event in moonraker for testing purposes, but as the print start notification is the least complicated one, it is the easiest way to test. If you do not get an notification, I would assume that your credentials are either not read (they are not set) or you put the wrong values in there, such that pushover is not accepting them. You will find out by inspecting the moonraker.log. If you get the start notification but not the other ones --> check your "attach" line, which makes a screenshot to attach to the notification. You will have adjust the url to get the screenshot from (you should be able to test it in your browser, by putting the url in there and getting a screenshot shown).

Edited by possebaer
  • Like 1
  • Voron FTW! 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...