Skip to content

Commit 2c2cc8f

Browse files
committed
Add context handling to BearClaw commands and implement daily maintenance automation for OneNote indexer. Updated README to reflect new features and improvements.
1 parent 0224c20 commit 2c2cc8f

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

config/packages/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Live collection of plug-and-play Home Assistant packages. Each YAML file in this
4747
| [mariadb_monitoring.yaml](mariadb_monitoring.yaml) | MariaDB health sensors and Lovelace dashboard snippet for recorder stats. | `sensor.mariadb_status`, `sensor.database_size` |
4848
| [docker_infrastructure.yaml](docker_infrastructure.yaml) | Docker host patching telemetry (docker_10/14/17/69) + host-side auto-reboots + container-down Repairs alerts. | `sensor.docker_*_apt_status`, `repairs.create`, `repairs.remove` |
4949
| [infrastructure_observability.yaml](infrastructure_observability.yaml) | Normalized WAN/DNS/backup/domain/cert health sensors used by the Infrastructure Home + Website Health dashboards. | `binary_sensor.infra_*`, `sensor.infra_*`, `script.send_to_logbook` |
50-
| [onenote_indexer.yaml](onenote_indexer.yaml) | OneNote indexer health/status monitoring for Joanna, including last-run outcome and trigger-ready failure sensors. | `sensor.onenote_indexer_last_job_status`, `binary_sensor.onenote_indexer_last_job_successful` |
50+
| [onenote_indexer.yaml](onenote_indexer.yaml) | OneNote indexer health/status monitoring for Joanna, failure-repair automation, and a daily duplicate-delete maintenance request. | `sensor.onenote_indexer_last_job_status`, `binary_sensor.onenote_indexer_last_job_successful` |
5151
| [mariadb.yaml](mariadb.yaml) | MariaDB recorder health and capacity SQL sensors. | `sensor.mariadb_status`, `sensor.database_size` |
5252
| [tugtainer_updates.yaml](tugtainer_updates.yaml) | Tugtainer container update notifications via webhook + persistent alerts. | `persistent_notification.create`, `input_datetime.tugtainer_last_update` |
5353
| [bearclaw.yaml](bearclaw.yaml) | Joanna/BearClaw bridge automations that forward Telegram commands to codex_appliance and relay replies back. | `rest_command.bearclaw_*`, `automation.bearclaw_*`, webhook relay |

config/packages/bearclaw.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rest_command:
2424
"text": {{ text | tojson }},
2525
"user": {{ user | default('carlo') | tojson }},
2626
"source": {{ source | default('home_assistant') | tojson }},
27+
"context": {{ context | default(none) | tojson }},
2728
"callback": {{ callback | default(none) | tojson }}
2829
}
2930

config/packages/onenote_indexer.yaml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
# -------------------------------------------------------------------
99
# Notes: Keep onenote indexer monitoring in this package (separate from bearclaw transport).
1010
# Notes: last_status='never' is treated as success to avoid false alerts after restarts.
11+
# Notes: Only explicit last_status='error' is treated as failure; unknown/unavailable are neutral.
12+
# Notes: HA->Joanna request includes trigger context so Telegram progress messages can identify origin.
1113
# Notes: Creates/clears a Spook Repair issue and requests Joanna remediation on failures.
14+
# Notes: Schedules daily OneNote duplicate-delete maintenance request via Joanna.
1215
######################################################################
1316

1417
sensor:
@@ -104,9 +107,37 @@ template:
104107
unique_id: onenote_indexer_job_failed
105108
device_class: problem
106109
state: >-
107-
{{ not is_state('binary_sensor.onenote_indexer_last_job_successful', 'on') }}
110+
{{ is_state('sensor.onenote_indexer_last_job_status', 'error') }}
108111
109112
automation:
113+
- id: onenote_indexer_daily_delete_maintenance
114+
alias: OneNote Indexer - Daily Delete Maintenance Request
115+
description: Ask Joanna daily to run duplicate cleanup and delete reconciliation for OneNote indexer.
116+
mode: single
117+
trigger:
118+
- platform: time
119+
at: "03:15:00"
120+
condition:
121+
- condition: template
122+
value_template: "{{ not (state_attr('sensor.onenote_indexer_last_job_status', 'running') | default(false) | bool) }}"
123+
action:
124+
- variables:
125+
trigger_context: "HA automation onenote_indexer_daily_delete_maintenance (OneNote Indexer - Daily Delete Maintenance Request)"
126+
- service: script.send_to_logbook
127+
data:
128+
topic: "ONENOTE"
129+
message: "Requesting daily duplicate cleanup + delete reconciliation run from Joanna."
130+
- service: rest_command.bearclaw_command
131+
data:
132+
text: >-
133+
Trigger: {{ trigger_context }}.
134+
Run OneNote indexer duplicate cleanup and apply deletions.
135+
Include delete reconciliation so removed source pages are removed from the index.
136+
Report pages/chunks and delete metrics before and after completion.
137+
user: "carlo"
138+
source: "home_assistant_automation.onenote_indexer_daily_delete_maintenance"
139+
context: "{{ trigger_context }}"
140+
110141
- id: onenote_indexer_failure_open_repair
111142
alias: OneNote Indexer - Open Repair On Failure
112143
description: Open a Spook Repair issue and ask Joanna to troubleshoot when indexer status is failed.
@@ -122,6 +153,7 @@ automation:
122153
run_id: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_run_id') | default('n/a') }}"
123154
last_error: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_error') | default('n/a') }}"
124155
last_metrics: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_metrics') | default({}) }}"
156+
trigger_context: "HA automation onenote_indexer_failure_open_repair (OneNote Indexer - Open Repair On Failure)"
125157
- service: repairs.create
126158
data:
127159
issue_id: "onenote_indexer_job_failed"
@@ -143,14 +175,16 @@ automation:
143175
- service: rest_command.bearclaw_command
144176
data:
145177
text: >-
178+
Trigger: {{ trigger_context }}.
146179
OneNote indexer containerhealth alert from Home Assistant.
147180
Please troubleshoot and resolve if possible.
148181
last_status={{ last_status }},
149182
last_run_id={{ run_id }},
150183
last_error={{ last_error }},
151184
last_metrics={{ last_metrics }}.
152185
user: "carlo"
153-
source: "home_assistant_repair"
186+
source: "home_assistant_automation.onenote_indexer_failure_open_repair"
187+
context: "{{ trigger_context }}"
154188

155189
- id: onenote_indexer_failure_clear_repair
156190
alias: OneNote Indexer - Clear Repair On Recovery

0 commit comments

Comments
 (0)