Skip to content

Commit 26a7050

Browse files
committed
Add OneNote indexer health monitoring to logbook and recorder configurations. Updated README to include OneNote indexer package details.
1 parent 00f1a8c commit 26a7050

4 files changed

Lines changed: 181 additions & 0 deletions

File tree

config/logbook.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ exclude:
4242
- automation.cuckoo_clock
4343
- automation.detect_lights_and_adjust_the_brightness_when_turned_on_based_on_time
4444
- binary_sensor.office_motion
45+
- binary_sensor.onenote_indexer_job_failed
46+
- binary_sensor.onenote_indexer_last_job_successful
4547
- binary_sensor.vcloudinfo_com
4648
- binary_sensor.refrigerator_door_open
4749
- binary_sensor.rheem_wh_running
50+
- sensor.onenote_indexer_last_job_status
51+
- sensor.onenote_indexer_status_payload
4852
- sensor.vcloudinfo_com
4953
- group.garage_doors
5054
- media_player.LivingRoomCC

config/packages/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +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` |
5051
| [mariadb.yaml](mariadb.yaml) | MariaDB recorder health and capacity SQL sensors. | `sensor.mariadb_status`, `sensor.database_size` |
5152
| [tugtainer_updates.yaml](tugtainer_updates.yaml) | Tugtainer container update notifications via webhook + persistent alerts. | `persistent_notification.create`, `input_datetime.tugtainer_last_update` |
5253
| [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 |
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
######################################################################
2+
# @CCOSTAN - Follow Me on X
3+
# For more info visit https://www.vcloudinfo.com/click-here
4+
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
5+
# -------------------------------------------------------------------
6+
# OneNote Indexer Monitoring - Status and health sensors for Joanna
7+
# Polls codex_appliance OneNote status and exposes trigger-ready health entities.
8+
# -------------------------------------------------------------------
9+
# Notes: Keep onenote indexer monitoring in this package (separate from bearclaw transport).
10+
# Notes: last_status='never' is treated as success to avoid false alerts after restarts.
11+
# Notes: Creates/clears a Spook Repair issue and requests Joanna remediation on failures.
12+
######################################################################
13+
14+
sensor:
15+
- platform: rest
16+
name: OneNote Indexer Status Payload
17+
unique_id: onenote_indexer_status_payload
18+
resource: !secret bearclaw_onenote_status_url
19+
method: GET
20+
headers:
21+
x-codex-token: !secret bearclaw_token
22+
scan_interval: 300
23+
timeout: 20
24+
value_template: >-
25+
{% if value_json is mapping %}
26+
{{ value_json.server_time | default(now().isoformat()) }}
27+
{% else %}
28+
unknown
29+
{% endif %}
30+
json_attributes:
31+
- ok
32+
- indexer
33+
- embeddingWorker
34+
35+
template:
36+
- sensor:
37+
- name: OneNote Indexer Last Job Status
38+
unique_id: onenote_indexer_last_job_status
39+
icon: mdi:notebook-check
40+
state: >-
41+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
42+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
43+
{% set raw = (sync.get('last_status', '') | string | lower) %}
44+
{% if raw in ['ok', 'success', 'never'] %}
45+
success
46+
{% elif raw == 'running' %}
47+
running
48+
{% elif raw == 'error' %}
49+
error
50+
{% else %}
51+
unknown
52+
{% endif %}
53+
attributes:
54+
running: >-
55+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
56+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
57+
{{ sync.get('running', false) | bool }}
58+
last_run_id: >-
59+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
60+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
61+
{{ sync.get('last_run_id') }}
62+
last_started_at: >-
63+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
64+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
65+
{{ sync.get('last_started_at') }}
66+
last_finished_at: >-
67+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
68+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
69+
{{ sync.get('last_finished_at') }}
70+
last_error: >-
71+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
72+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
73+
{{ sync.get('last_error') }}
74+
pending_embeddings: >-
75+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
76+
{% set index = payload.get('index', {}) if payload is mapping else {} %}
77+
{{ index.get('pending_embeddings') }}
78+
pages: >-
79+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
80+
{% set index = payload.get('index', {}) if payload is mapping else {} %}
81+
{{ index.get('pages') }}
82+
chunks: >-
83+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
84+
{% set index = payload.get('index', {}) if payload is mapping else {} %}
85+
{{ index.get('chunks') }}
86+
last_metrics: >-
87+
{% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %}
88+
{% set sync = payload.get('sync', {}) if payload is mapping else {} %}
89+
{{ sync.get('last_metrics', {}) }}
90+
91+
- binary_sensor:
92+
- name: OneNote Indexer Last Job Successful
93+
unique_id: onenote_indexer_last_job_successful
94+
state: >-
95+
{{ states('sensor.onenote_indexer_last_job_status') in ['success', 'running'] }}
96+
icon: >-
97+
{% if is_state('binary_sensor.onenote_indexer_last_job_successful', 'on') %}
98+
mdi:check-circle
99+
{% else %}
100+
mdi:alert-circle
101+
{% endif %}
102+
103+
- name: OneNote Indexer Job Failed
104+
unique_id: onenote_indexer_job_failed
105+
device_class: problem
106+
state: >-
107+
{{ not is_state('binary_sensor.onenote_indexer_last_job_successful', 'on') }}
108+
109+
automation:
110+
- id: onenote_indexer_failure_open_repair
111+
alias: OneNote Indexer - Open Repair On Failure
112+
description: Open a Spook Repair issue and ask Joanna to troubleshoot when indexer status is failed.
113+
mode: single
114+
trigger:
115+
- platform: state
116+
entity_id: binary_sensor.onenote_indexer_job_failed
117+
to: "on"
118+
for: "00:03:00"
119+
action:
120+
- variables:
121+
last_status: "{{ states('sensor.onenote_indexer_last_job_status') }}"
122+
run_id: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_run_id') | default('n/a') }}"
123+
last_error: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_error') | default('n/a') }}"
124+
last_metrics: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_metrics') | default({}) }}"
125+
- service: repairs.create
126+
data:
127+
issue_id: "onenote_indexer_job_failed"
128+
title: "OneNote indexer job failed"
129+
severity: "warning"
130+
persistent: true
131+
description: >-
132+
Home Assistant detected OneNote indexer failure.
133+
134+
last_status: {{ last_status }}
135+
last_run_id: {{ run_id }}
136+
last_error: {{ last_error }}
137+
last_metrics: {{ last_metrics }}
138+
- service: script.send_to_logbook
139+
data:
140+
topic: "ONENOTE"
141+
message: >-
142+
OneNote indexer failed (run {{ run_id }}). Spook repair opened and Joanna remediation requested.
143+
- service: rest_command.bearclaw_command
144+
data:
145+
text: >-
146+
OneNote indexer containerhealth alert from Home Assistant.
147+
Please troubleshoot and resolve if possible.
148+
last_status={{ last_status }},
149+
last_run_id={{ run_id }},
150+
last_error={{ last_error }},
151+
last_metrics={{ last_metrics }}.
152+
user: "carlo"
153+
source: "home_assistant_repair"
154+
155+
- id: onenote_indexer_failure_clear_repair
156+
alias: OneNote Indexer - Clear Repair On Recovery
157+
description: Clear the Spook Repair issue when OneNote indexer is healthy again.
158+
mode: single
159+
trigger:
160+
- platform: state
161+
entity_id: binary_sensor.onenote_indexer_job_failed
162+
to: "off"
163+
for: "00:02:00"
164+
action:
165+
- service: repairs.remove
166+
continue_on_error: true
167+
data:
168+
issue_id: "onenote_indexer_job_failed"
169+
- service: script.send_to_logbook
170+
data:
171+
topic: "ONENOTE"
172+
message: "OneNote indexer recovered. Spook repair cleared."

config/recorder.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ exclude:
5757
entities:
5858
- automation.update_garage_get_status
5959
- binary_sensor.bear_stone
60+
- binary_sensor.onenote_indexer_job_failed
61+
- binary_sensor.onenote_indexer_last_job_successful
6062
- binary_sensor.vcloudinfo_com
6163
- binary_sensor.powerwall_charging
64+
- sensor.onenote_indexer_last_job_status
65+
- sensor.onenote_indexer_status_payload
6266
- sensor.phyn_current_water_pressure
6367
- sensor.vcloudinfo_com
6468
- number.alarm_panel_1_screen_brightness

0 commit comments

Comments
 (0)