forked from ghzserg/notify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify.cfg
More file actions
65 lines (51 loc) · 2.3 KB
/
notify.cfg
File metadata and controls
65 lines (51 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
[gcode_macro _NOTIFY]
gcode:
{% set msg = params.MSG|default("Ok")|string %}
{% set photo = params.PHOTO|default(1)|int %}
{% set type = params.TYPE|default("ok")|string %}
{% set var_name = 'notify_' ~ type %}
{% set type_on = printer.save_variables.variables[var_name]|default(1)|int %}
{% if photo == 1 %}
{% set notifier = "notifier_photo" %}
{% else %}
{% set notifier = "notifier" %}
{% endif %}
{% if type_on == 1 %}
{action_call_remote_method("notify",
name=notifier,
message=msg)}
{% endif %}
[gcode_macro _NOTIFY_ON_PERCENT]
variable_notified_percent: 0
gcode:
{% set notify_step = printer.save_variables.variables.notify_percent|default(0)|int %}
{% if notify_step > 0 %}
{% set progress = printer.virtual_sdcard.progress|default(0)|float %}
{% set current_percent = (progress * 100)|round(1)|float %}
{% set last_notified = printer["gcode_macro _NOTIFY_ON_PERCENT"].notified_percent|int %}
{% set next_threshold = ((last_notified // notify_step) + 1) * notify_step %}
{% if current_percent >= next_threshold and current_percent > last_notified %}
{% set filename = printer.print_stats.filename|default("Unknown")|string %}
{% set basename = filename.split('/')[-1].split('\\')[-1] %}
{% set et = printer.extruder.temperature|default(0)|round(1) %}
{% set et_t = printer.extruder.target|default(0)|round(1) %}
{% set bt = printer.heater_bed.temperature|default(0)|round(1) %}
{% set bt_t = printer.heater_bed.target|default(0)|round(1) %}
{% set msg = "%s (%d%%) | %.1f/%.1f°C | %.1f/%.1f°C" |
format(basename, current_percent|int, et, et_t, bt, bt_t) %}
_NOTIFY MSG="{msg}"
SET_GCODE_VARIABLE MACRO=_NOTIFY_ON_PERCENT VARIABLE=notified_percent VALUE={current_percent|int}
{% endif %}
{% endif %}
[gcode_shell_command update_notify]
command: /opt/config/mod_data/plugins/notify/update_notify.sh
timeout: 7200
verbose: False
[delayed_gcode _UPDATE_NOTIFY]
initial_duration: 3
gcode:
RUN_SHELL_COMMAND CMD=update_notify PARAMS=0
[gcode_macro UPDATE_NOTIFY]
gcode:
RUN_SHELL_COMMAND CMD=update_notify PARAMS=1
REBOOT