Skip to content

Commit 0102e0f

Browse files
committed
🔊 Improved custom triggers logging
They all have a `trigger` tag on them to identify where they came from, useful for bug reports for these features.
1 parent 66d8809 commit 0102e0f

File tree

6 files changed

+121
-117
lines changed

6 files changed

+121
-117
lines changed

.github/workflows/projects.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ jobs:
1111
runs-on: ubuntu-latest
1212
name: Assign to project
1313
steps:
14-
- name: potential bug assignment
15-
uses: srggrs/[email protected]
16-
if: contains(github.event.issue.labels.*.name, 'potential bug')
17-
with:
18-
project: 'https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/1'
19-
column_name: 'To analyse'
14+
- name: potential bug assignment
15+
uses: srggrs/[email protected]
16+
if: contains(github.event.issue.labels.*.name, 'potential bug')
17+
with:
18+
project: "https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/1"
19+
column_name: "To analyse"
2020

21-
- name: confirmed bug assignment
22-
uses: srggrs/[email protected]
23-
if: contains(github.event.issue.labels.*.name, 'confirmed bug')
24-
with:
25-
project: 'https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/1'
26-
column_name: 'To fix'
21+
- name: confirmed bug assignment
22+
uses: srggrs/[email protected]
23+
if: contains(github.event.issue.labels.*.name, 'confirmed bug')
24+
with:
25+
project: "https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/1"
26+
column_name: "To fix"
2727

28-
- name: request assignment
29-
uses: srggrs/[email protected]
30-
if: contains(github.event.issue.labels.*.name, 'request')
31-
with:
32-
project: 'https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/2'
33-
column_name: 'Needs triage'
28+
- name: request assignment
29+
uses: srggrs/[email protected]
30+
if: contains(github.event.issue.labels.*.name, 'request')
31+
with:
32+
project: "https://github.com/cp2004/OctoPrint-WS281x_LED_Status/projects/2"
33+
column_name: "Needs triage"

.github/workflows/stale.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: 'Close stale issues'
1+
name: "Close stale issues"
22
on:
33
schedule:
4-
- cron: '30 1 * * *'
4+
- cron: "30 1 * * *"
55
repository_dispatch:
66

77
jobs:
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/stale@v4
1212
with:
13-
stale-issue-message: 'This issue has been marked a stale because it has been open for 14 days with no activity. If there is no further activity in the next 7 days this issue will be closed.'
14-
close-issue-message: 'This issue has been closed as there was no activity for 21 days. If this issue is still relevant, please request a reopen or create a new issue.'
13+
stale-issue-message: "This issue has been marked a stale because it has been open for 14 days with no activity. If there is no further activity in the next 7 days this issue will be closed."
14+
close-issue-message: "This issue has been closed as there was no activity for 21 days. If this issue is still relevant, please request a reopen or create a new issue."
1515
days-before-stale: 14
1616
days-before-close: 7
17-
any-of-labels: 'question,needs information,duplicate,incomplete,awaiting information'
18-
exempt-issue-labels: 'bug'
17+
any-of-labels: "question,needs information,duplicate,incomplete,awaiting information"
18+
exempt-issue-labels: "bug"

README.md

Lines changed: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,83 @@
1-
# OctoPrint WS281x LED Status
2-
3-
Add some RGB LEDs to your 3D printer for a quick status update!
4-
5-
![GitHub issues](https://img.shields.io/github/issues/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
6-
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/cp2004/OctoPrint-WS281x_LED_Status?label=latest%20release&sort=semver&style=flat-square)
7-
![GitHub release installs (latest by date)](https://img.shields.io/github/downloads/cp2004/OctoPrint-WS281x_LED_Status/latest/total?label=New%20installs%40latest&style=flat-square)
8-
![GitHub Repo stars](https://img.shields.io/github/stars/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
9-
![GitHub](https://img.shields.io/github/license/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
10-
![GitHub Sponsors](https://img.shields.io/github/sponsors/cp2004?style=flat-square)
11-
12-
![rainbow effect](/assets/rainbow.gif)
13-
14-
A highly configurable yet easy to use plugin for attaching WS2811, WS2812 and SK6812 or LEDs to your Raspberry Pi for a printer status update!
15-
16-
With lots of options effects and integrations to choose from, you can customise the plugin to do things _exactly_ as you want them.
17-
18-
Most prominent features include:
19-
20-
- Printer status effects
21-
- Tracking heating, printing and cooling progress
22-
- Intercepting M150 commands & controlling with @ commands
23-
- Easy controls for turning lights on and off from the navbar
24-
- Theme-friendly torch button to temporarily light up your printer
25-
- Timers to turn the LEDs off at certain times of day or after a print is done.
26-
- Custom Triggers - add your own events, @ commands or gcode matching to trigger effects
27-
- Powerful integration with OctoApp for Android
28-
- ...and more!
29-
30-
You can take a look at the [documentation](https://cp2004.gitbook.io/ws281x-led-status/) for more information about all that the plugin has to offer.
31-
32-
![rainbow effect](/assets/color_wipe.gif)
33-
34-
## Setup
35-
36-
Setting up the plugin couldn't be easier! There are 3 main steps, with configuration made easy with the setup wizard.
37-
38-
- Wiring your LEDs
39-
- Configuring SPI
40-
- Configuring plugin settings
41-
42-
Follow the detailed [setup guide](https://cp2004.gitbook.io/ws281x-led-status/guides/setup-guide-1) in the documentation to get up and running.
43-
44-
## Getting help
45-
46-
Please read the [Get Help Guide](https://cp2004.gitbook.io/ws281x-led-status/guides/get-help-guide) as well as the [rest of the documentation](https://cp2004.gitbook.io/ws281x-led-status/), to see if your question has been answered there. Still got questions? Get in touch:
47-
48-
- On the [OctoPrint Discord](https://discord.octoprint.org)
49-
- On the [Community Forums](https://community.octoprint.org)
50-
- Open an issue with the [question template](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/issues/new?assignees=&labels=type%3A+question&template=question.md&title=)
51-
52-
## Reporting problems
53-
54-
Whilst I don't like bugs, I want to hear about them! Let me know by [opening an issue](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/issues/new?assignees=&labels=type%3A+potential+bug&template=bug_report.md&title=%5BBug%5D)
55-
56-
## Contributing
57-
58-
I accept many forms of contribution, from fixing bugs, documentation and new features.
59-
Please see the [Contributing Guidelines](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/blob/master/CONTRIBUTING.md) for more details or get
60-
in touch if you don't know where to start.
61-
62-
## Sponsors
63-
64-
* [@iFrostizz](https://github.com/iFrostizz)
65-
* [@KenLucke](https://github.com/KenLucke)
66-
67-
As well as 7 others supporting me through [GitHub Sponsors](https://github.com/sponsors/cp2004)!
68-
69-
## Supporting my efforts
70-
71-
I created this project in my spare time, so if you have found it useful or enjoyed using it then please consider [supporting it's development!](https://github.com/sponsors/cp2004). You can sponsor monthly or one time, for any amount you choose.
72-
## Thanks
73-
74-
This was my first plugin and is still my favourite, so I have to say thanks for helping me develop it:
75-
76-
[jneilliii](https://github.com/jneilliii) for always answering my questions on discord, and making great plugins I could use as examples.
77-
78-
Andreas C. for jumping at the opportunity to beta-test, and providing great feedback as I was creating this!
79-
80-
And, of course, [Gina Häußge](https://github.com/foosel) for creating OctoPrint and such a great community around it.
81-
82-
# 💡
1+
# OctoPrint WS281x LED Status
2+
3+
Add some RGB LEDs to your 3D printer for a quick status update!
4+
5+
![GitHub issues](https://img.shields.io/github/issues/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
6+
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/cp2004/OctoPrint-WS281x_LED_Status?label=latest%20release&sort=semver&style=flat-square)
7+
![GitHub release installs (latest by date)](https://img.shields.io/github/downloads/cp2004/OctoPrint-WS281x_LED_Status/latest/total?label=New%20installs%40latest&style=flat-square)
8+
![GitHub Repo stars](https://img.shields.io/github/stars/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
9+
![GitHub](https://img.shields.io/github/license/cp2004/OctoPrint-WS281x_LED_Status?style=flat-square)
10+
![GitHub Sponsors](https://img.shields.io/github/sponsors/cp2004?style=flat-square)
11+
12+
![rainbow effect](/assets/rainbow.gif)
13+
14+
A highly configurable yet easy to use plugin for attaching WS2811, WS2812 and SK6812 or LEDs to your Raspberry Pi for a printer status update!
15+
16+
With lots of options effects and integrations to choose from, you can customise the plugin to do things _exactly_ as you want them.
17+
18+
Most prominent features include:
19+
20+
- Printer status effects
21+
- Tracking heating, printing and cooling progress
22+
- Intercepting M150 commands & controlling with @ commands
23+
- Easy controls for turning lights on and off from the navbar
24+
- Theme-friendly torch button to temporarily light up your printer
25+
- Timers to turn the LEDs off at certain times of day or after a print is done.
26+
- Custom Triggers - add your own events, @ commands or gcode matching to trigger effects
27+
- Powerful integration with OctoApp for Android
28+
- ...and more!
29+
30+
You can take a look at the [documentation](https://cp2004.gitbook.io/ws281x-led-status/) for more information about all that the plugin has to offer.
31+
32+
![rainbow effect](/assets/color_wipe.gif)
33+
34+
## Setup
35+
36+
Setting up the plugin couldn't be easier! There are 3 main steps, with configuration made easy with the setup wizard.
37+
38+
- Wiring your LEDs
39+
- Configuring SPI
40+
- Configuring plugin settings
41+
42+
Follow the detailed [setup guide](https://cp2004.gitbook.io/ws281x-led-status/guides/setup-guide-1) in the documentation to get up and running.
43+
44+
## Getting help
45+
46+
Please read the [Get Help Guide](https://cp2004.gitbook.io/ws281x-led-status/guides/get-help-guide) as well as the [rest of the documentation](https://cp2004.gitbook.io/ws281x-led-status/), to see if your question has been answered there. Still got questions? Get in touch:
47+
48+
- On the [OctoPrint Discord](https://discord.octoprint.org)
49+
- On the [Community Forums](https://community.octoprint.org)
50+
- Open an issue with the [question template](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/issues/new?assignees=&labels=type%3A+question&template=question.md&title=)
51+
52+
## Reporting problems
53+
54+
Whilst I don't like bugs, I want to hear about them! Let me know by [opening an issue](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/issues/new?assignees=&labels=type%3A+potential+bug&template=bug_report.md&title=%5BBug%5D)
55+
56+
## Contributing
57+
58+
I accept many forms of contribution, from fixing bugs, documentation and new features.
59+
Please see the [Contributing Guidelines](https://github.com/cp2004/OctoPrint-WS281x_LED_Status/blob/master/CONTRIBUTING.md) for more details or get
60+
in touch if you don't know where to start.
61+
62+
## Sponsors
63+
64+
- [@iFrostizz](https://github.com/iFrostizz)
65+
- [@KenLucke](https://github.com/KenLucke)
66+
67+
As well as 7 others supporting me through [GitHub Sponsors](https://github.com/sponsors/cp2004)!
68+
69+
## Supporting my efforts
70+
71+
I created this project in my spare time, so if you have found it useful or enjoyed using it then please consider [supporting it's development!](https://github.com/sponsors/cp2004). You can sponsor monthly or one time, for any amount you choose.
72+
73+
## Thanks
74+
75+
This was my first plugin and is still my favourite, so I have to say thanks for helping me develop it:
76+
77+
[jneilliii](https://github.com/jneilliii) for always answering my questions on discord, and making great plugins I could use as examples.
78+
79+
Andreas C. for jumping at the opportunity to beta-test, and providing great feedback as I was creating this!
80+
81+
And, of course, [Gina Häußge](https://github.com/foosel) for creating OctoPrint and such a great community around it.
82+
83+
# 💡

octoprint_ws281x_led_status/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def test_led(self, data):
8787
"effect": data.get("effect", "Solid Color"),
8888
"color": data.get("color", "#ff0000"),
8989
"delay": data.get("delay", 10),
90+
"trigger": "test",
9091
}
9192

9293
self.plugin.update_effect({"type": "custom", "data": test_config})

octoprint_ws281x_led_status/static/js/ws281x_led_status.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ $(function () {
309309
};
310310
self.reason_id_map = {
311311
failed: "This test did not pass",
312-
error:
313-
"Error: There was an unknown error running this test, please check the log",
312+
error: "Error: There was an unknown error running this test, please check the log",
314313
missing: "Error: The file this check expected does not exist",
315314
pi4_250:
316315
"It looks like core_freq_min=250 is set in your /boot/config.txt file." +
@@ -396,16 +395,14 @@ $(function () {
396395
) {
397396
new PNotify({
398397
title: "WS281X LED Status: Incomplete config",
399-
text:
400-
"Your configuration is not complete! Please head to the utilities tab in the settings page to fix this.",
398+
text: "Your configuration is not complete! Please head to the utilities tab in the settings page to fix this.",
401399
type: "error",
402400
hide: false,
403401
});
404402
} else {
405403
new PNotify({
406404
title: "Restart needed!",
407-
text:
408-
"WS281x LED Status configuration complete. You will need to restart your Pi for the changes to take effect.",
405+
text: "WS281x LED Status configuration complete. You will need to restart your Pi for the changes to take effect.",
409406
type: "success",
410407
hide: false,
411408
});

octoprint_ws281x_led_status/triggers.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@ def process_settings(self, settings):
137137
self._logger.exception(e)
138138

139139
def on_event(self, event):
140-
for e in self.event_subscriptions:
141-
if e["match"] == event:
140+
for event in self.event_subscriptions:
141+
if event["match"] == event:
142142
self.effect_queue.put(
143143
{
144144
"type": "custom",
145-
"effect": e["effect"],
146-
"color": e["color"],
147-
"delay": e["delay"],
145+
"effect": event["effect"],
146+
"color": event["color"],
147+
"delay": event["delay"],
148+
"trigger": "event: {}".format(event["match"]),
148149
}
149150
)
150151

@@ -160,6 +161,7 @@ def on_at_command(self, command):
160161
"effect": at_command["effect"],
161162
"color": at_command["color"],
162163
"delay": at_command["delay"],
164+
"trigger": "at command: {}".format(at_command["match"]),
163165
}
164166
)
165167

@@ -174,6 +176,7 @@ def on_gcode_command(self, gcode, cmd):
174176
"effect": gcode_command["effect"],
175177
"color": gcode_command["color"],
176178
"delay": gcode_command["delay"],
179+
"trigger": "gcode match: {}".format(gcode_command["match"]),
177180
}
178181
)
179182
# Once we have a match, we can stop looking
@@ -187,6 +190,7 @@ def on_gcode_command(self, gcode, cmd):
187190
"effect": gcode_exact["effect"],
188191
"color": gcode_exact["color"],
189192
"delay": gcode_exact["delay"],
193+
"trigger": "gcode exact: {}".format(gcode_exact["match"]),
190194
}
191195
)
192196
# Once we have a match, we can stop looking
@@ -201,6 +205,7 @@ def on_gcode_command(self, gcode, cmd):
201205
"effect": gcode_regex["effect"],
202206
"color": gcode_regex["color"],
203207
"delay": gcode_regex["delay"],
208+
"trigger": "gcode regex: {}".format(gcode_regex["match"]),
204209
}
205210
)
206211
# Once we have a match, we can stop looking

0 commit comments

Comments
 (0)