Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/prd0000/push_notify

Push notification plugin for Klipper
https://github.com/prd0000/push_notify

Last synced: 6 days ago
JSON representation

Push notification plugin for Klipper

Awesome Lists containing this project

README

        

# Push Notification for Klipper









## Introduction

I have been wanting to make my printer notify me whenever it finishes any print for some time now. And after I heard about Klipper, I soon realize that it can use python to extend its functionality. So I wrote this script to help me. And I hope this script can help you, too.

This simple script will add push notification capabilty to Klipper.

Klipper is a open source 3D Printer firmware. If you want to install Klipper, you can go to [Klipper 3D](https://www.klipper3d.org/) for detailed instruction

## What you need

This script is using either [Pushover](https://pushover.net/), the free [ntfy.sh](https://ntfy.sh/), or [Pushbullet](https://www.pushbullet.com/) to send push notification to your phone.

* Pushover service is more secure, but it is a paid service. To utilize Pushover, you will need an account at Pushover to start. Please follow the link for registration detail. After you have registered, you'll receive your ***User key***. Then you have to create your ***API key*** for this script.

* ntfy.sh is a free service, and you can create any topic you like. Make sure the topic is unique enough to not receive other people's push notification. The topic is essentially your "password". I don't use private ntfy server because I don't deem a 3D printer notification such as out of filament or printing status to be something sensitive. To utilize ntfy.sh, you only need to pick up a topic, and match it to your phone and ***Topic*** entry at configuration file.

* [Pushbullet](https://www.pushbullet.com/) ... "connects your devices, making them feel like one." To use Pushbullet you'll need to generate an ***Access Token*** for your Pushbullet user account to be used when implementing this script. This script currently only implements the "note" type of notification, allowing a title and a message to be sent for the push notification.

## Installation


  1. Download the source code of [notify.py](https://raw.githubusercontent.com/prd0000/push_notify/main/script/notify.py) if you want to use Pushover, or [fcm.py](https://raw.githubusercontent.com/prd0000/push_notify/main/script/fcm.py) if you want to use ntfy, or [pushbullet.py](https://raw.githubusercontent.com/prd0000/push_notify/main/script/pushbullet.py) if you want to use Pushbullet.


  2. Copy the script into `/klippy/extras` folder.

    ![Alt text](resources/image.png)

  3. Add one of these to your `printer.cfg` configuration
    ```
    [notify]
    api_key:
    user_key:
    ```

    or
    ```
    [fcm]
    topic:
    server:
    serverport:
    ```

    or
    ```
    [pushbullet]
    pb_access_token:
    ```

  4. After you add the section to printer.cfg, do `FIRMWARE_RESTART` at Klipper.




## Usage

  • ### Syntax
    You can put it in any G-Code file like:

    ```
    PUSH_NOTIFY MSG= [DEVICE=] [TITLE=] [SOUND=]
    ```

    ```
    FCM_NOTIFY MSG= [TITLE=]
    ```

    ```
    PUSHBULLET_NOTIFY MSG= TITLE=
    ```

    * `MSG`: (mandatory) is the message that you are going to send to your phone.

    * `DEVICE`: (optional) send a device id. This is corresponds to your device id registered at Pushoverr.

    * `TITLE`: (optional, mandatory for pushbullet) put a title to the message. If you omit this, the script will default to empty string

    * `SOUND`: (optional) use a specific sound for the notification (Credits to [@Xierion](https://github.com/Xierion))

  • ### Command example:

    ```
    PUSH_NOTIFY DEVICE="my_phone" TITLE="filename.gcode" MSG="printing done"
    ```
    ```
    FCM_NOTIFY TITLE="filename.gcode" MSG="printing done"
    ```
    ```
    PUSHBULLET_NOTIFY TITLE="Klipper" MSG="printing done"
    ```


  • ### Macro example

    Or you can also put it in your macro like:

    ```
    [gcode_macro END_PRINT]
    gcode:

    # Turn off bed, extruder, and fan
    M140 S0
    M104 S0
    M106 S0
    # Move nozzle away from print while retracting
    G91
    G1 Z10 E-5 F300
    G90
    G1 X10 Y300 F3000
    # Disable steppers
    M84
    # Notify User
    PUSH_NOTIFY MSG="Printing Done"

    ```


Enjoy