Route OctoEverywhere alerts to a Google Chat space per printer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Joshua King
2026-11-06 09:47:44 -05:00
co-authored by Claude Opus 5.5
parent 2ae16ceb97
commit 14e3e405c1
2 changed files with 57 additions and 5 deletions
@@ -1,8 +1,12 @@
### OctoEverywhere -> Google Chat ###
# OctoEverywhere (LAN mode) POSTs fixed JSON to this webhook. Google Chat needs a
# `text` or `cardsV2` body, so this automation builds a card and sends it through
# rest_command.google_chat_octoeverywhere (helpers/rest_command.yaml).
# Requires `google_chat_octoeverywhere_webhook` in secrets.yaml.
# rest_command.google_chat_octoeverywhere_<printer> (helpers/rest_command.yaml).
# Each printer has its own Google Chat space, picked by a keyword in PrinterName
# (see `spaces` below). Unknown printers and the safety-net message go to the
# shared space, rest_command.google_chat_octoeverywhere.
# Requires `google_chat_octoeverywhere_webhook` and the per-printer
# `google_chat_octoeverywhere_<printer>` secrets in secrets.yaml.
#
# Card: header (printer + event), details (file, progress, layer, time, error),
# camera snapshot, and an "Open printer" button to OctoEverywhere Quick View.
@@ -67,6 +71,21 @@
# Build the message
- variables:
printer: "{{ p.PrinterName | default('Printer', true) | string }}"
# Keyword in the printer name (lowercase, letters/digits only) -> rest_command
spaces:
constipation: google_chat_octoeverywhere_constipation_orion
printney: google_chat_octoeverywhere_printney_spears
charming: google_chat_octoeverywhere_prints_charming
polly: google_chat_octoeverywhere_polly_pocket
slayer: google_chat_octoeverywhere_layer_slayer
turd: google_chat_octoeverywhere_turd_flinger
chat_cmd: >-
{%- set key = printer | lower | regex_replace('[^a-z0-9]', '') -%}
{%- set ns = namespace(cmd='google_chat_octoeverywhere') -%}
{%- for word, cmd in spaces.items() if word in key and ns.cmd == 'google_chat_octoeverywhere' -%}
{%- set ns.cmd = cmd -%}
{%- endfor -%}
{{ ns.cmd }}
pct: "{{ p.Progress | int(0) }}"
event_name: >-
{{ 'Print progress: ' ~ pct ~ '%' if ev == 6
@@ -123,8 +142,8 @@
{%- if p.QuickViewUrl %}{% set ns.lines = ns.lines + ['<' ~ p.QuickViewUrl ~ '|Open printer>'] %}{% endif -%}
{{ ns.lines | join('\n') }}
# Send the card
- action: rest_command.google_chat_octoeverywhere
# Send the card to this printer's space
- action: "rest_command.{{ chat_cmd }}"
data:
payload: "{{ card }}"
response_variable: chat_resp
@@ -137,7 +156,7 @@
value_template: "{{ chat_resp is not defined or (chat_resp.status | int(0)) != 200 }}"
then:
- delay: 2
- action: rest_command.google_chat_octoeverywhere
- action: "rest_command.{{ chat_cmd }}"
data:
payload:
text: "{{ plain }}"
+33
View File
@@ -44,3 +44,36 @@ google_chat_octoeverywhere:
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
# One Google Chat space per printer. The automation picks one by PrinterName and
# falls back to google_chat_octoeverywhere (shared space) for unknown printers.
google_chat_octoeverywhere_constipation_orion:
url: !secret google_chat_octoeverywhere_constipation_orion
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
google_chat_octoeverywhere_printney_spears:
url: !secret google_chat_octoeverywhere_printney_spears
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
google_chat_octoeverywhere_prints_charming:
url: !secret google_chat_octoeverywhere_prints_charming
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
google_chat_octoeverywhere_polly_pocket:
url: !secret google_chat_octoeverywhere_polly_pocket
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
google_chat_octoeverywhere_layer_slayer:
url: !secret google_chat_octoeverywhere_layer_slayer
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"
google_chat_octoeverywhere_turd_flinger:
url: !secret google_chat_octoeverywhere_turd_flinger
method: POST
content_type: "application/json; charset=UTF-8"
payload: "{{ payload | to_json }}"