diff --git a/config/logbook.yaml b/config/logbook.yaml index 96fd31c7..4c1cb7ea 100644 --- a/config/logbook.yaml +++ b/config/logbook.yaml @@ -42,9 +42,13 @@ exclude: - automation.cuckoo_clock - automation.detect_lights_and_adjust_the_brightness_when_turned_on_based_on_time - binary_sensor.office_motion + - binary_sensor.onenote_indexer_job_failed + - binary_sensor.onenote_indexer_last_job_successful - binary_sensor.vcloudinfo_com - binary_sensor.refrigerator_door_open - binary_sensor.rheem_wh_running + - sensor.onenote_indexer_last_job_status + - sensor.onenote_indexer_status_payload - sensor.vcloudinfo_com - group.garage_doors - media_player.LivingRoomCC diff --git a/config/packages/README.md b/config/packages/README.md index 583b62eb..3b67294a 100755 --- a/config/packages/README.md +++ b/config/packages/README.md @@ -47,6 +47,7 @@ Live collection of plug-and-play Home Assistant packages. Each YAML file in this | [mariadb_monitoring.yaml](mariadb_monitoring.yaml) | MariaDB health sensors and Lovelace dashboard snippet for recorder stats. | `sensor.mariadb_status`, `sensor.database_size` | | [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` | | [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` | +| [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` | | [mariadb.yaml](mariadb.yaml) | MariaDB recorder health and capacity SQL sensors. | `sensor.mariadb_status`, `sensor.database_size` | | [tugtainer_updates.yaml](tugtainer_updates.yaml) | Tugtainer container update notifications via webhook + persistent alerts. | `persistent_notification.create`, `input_datetime.tugtainer_last_update` | | [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 | diff --git a/config/packages/onenote_indexer.yaml b/config/packages/onenote_indexer.yaml new file mode 100644 index 00000000..aa392ba5 --- /dev/null +++ b/config/packages/onenote_indexer.yaml @@ -0,0 +1,172 @@ +###################################################################### +# @CCOSTAN - Follow Me on X +# For more info visit https://www.vcloudinfo.com/click-here +# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig +# ------------------------------------------------------------------- +# OneNote Indexer Monitoring - Status and health sensors for Joanna +# Polls codex_appliance OneNote status and exposes trigger-ready health entities. +# ------------------------------------------------------------------- +# Notes: Keep onenote indexer monitoring in this package (separate from bearclaw transport). +# Notes: last_status='never' is treated as success to avoid false alerts after restarts. +# Notes: Creates/clears a Spook Repair issue and requests Joanna remediation on failures. +###################################################################### + +sensor: + - platform: rest + name: OneNote Indexer Status Payload + unique_id: onenote_indexer_status_payload + resource: !secret bearclaw_onenote_status_url + method: GET + headers: + x-codex-token: !secret bearclaw_token + scan_interval: 300 + timeout: 20 + value_template: >- + {% if value_json is mapping %} + {{ value_json.server_time | default(now().isoformat()) }} + {% else %} + unknown + {% endif %} + json_attributes: + - ok + - indexer + - embeddingWorker + +template: + - sensor: + - name: OneNote Indexer Last Job Status + unique_id: onenote_indexer_last_job_status + icon: mdi:notebook-check + state: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {% set raw = (sync.get('last_status', '') | string | lower) %} + {% if raw in ['ok', 'success', 'never'] %} + success + {% elif raw == 'running' %} + running + {% elif raw == 'error' %} + error + {% else %} + unknown + {% endif %} + attributes: + running: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('running', false) | bool }} + last_run_id: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('last_run_id') }} + last_started_at: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('last_started_at') }} + last_finished_at: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('last_finished_at') }} + last_error: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('last_error') }} + pending_embeddings: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set index = payload.get('index', {}) if payload is mapping else {} %} + {{ index.get('pending_embeddings') }} + pages: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set index = payload.get('index', {}) if payload is mapping else {} %} + {{ index.get('pages') }} + chunks: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set index = payload.get('index', {}) if payload is mapping else {} %} + {{ index.get('chunks') }} + last_metrics: >- + {% set payload = state_attr('sensor.onenote_indexer_status_payload', 'indexer') or {} %} + {% set sync = payload.get('sync', {}) if payload is mapping else {} %} + {{ sync.get('last_metrics', {}) }} + + - binary_sensor: + - name: OneNote Indexer Last Job Successful + unique_id: onenote_indexer_last_job_successful + state: >- + {{ states('sensor.onenote_indexer_last_job_status') in ['success', 'running'] }} + icon: >- + {% if is_state('binary_sensor.onenote_indexer_last_job_successful', 'on') %} + mdi:check-circle + {% else %} + mdi:alert-circle + {% endif %} + + - name: OneNote Indexer Job Failed + unique_id: onenote_indexer_job_failed + device_class: problem + state: >- + {{ not is_state('binary_sensor.onenote_indexer_last_job_successful', 'on') }} + +automation: + - id: onenote_indexer_failure_open_repair + alias: OneNote Indexer - Open Repair On Failure + description: Open a Spook Repair issue and ask Joanna to troubleshoot when indexer status is failed. + mode: single + trigger: + - platform: state + entity_id: binary_sensor.onenote_indexer_job_failed + to: "on" + for: "00:03:00" + action: + - variables: + last_status: "{{ states('sensor.onenote_indexer_last_job_status') }}" + run_id: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_run_id') | default('n/a') }}" + last_error: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_error') | default('n/a') }}" + last_metrics: "{{ state_attr('sensor.onenote_indexer_last_job_status', 'last_metrics') | default({}) }}" + - service: repairs.create + data: + issue_id: "onenote_indexer_job_failed" + title: "OneNote indexer job failed" + severity: "warning" + persistent: true + description: >- + Home Assistant detected OneNote indexer failure. + + last_status: {{ last_status }} + last_run_id: {{ run_id }} + last_error: {{ last_error }} + last_metrics: {{ last_metrics }} + - service: script.send_to_logbook + data: + topic: "ONENOTE" + message: >- + OneNote indexer failed (run {{ run_id }}). Spook repair opened and Joanna remediation requested. + - service: rest_command.bearclaw_command + data: + text: >- + OneNote indexer containerhealth alert from Home Assistant. + Please troubleshoot and resolve if possible. + last_status={{ last_status }}, + last_run_id={{ run_id }}, + last_error={{ last_error }}, + last_metrics={{ last_metrics }}. + user: "carlo" + source: "home_assistant_repair" + + - id: onenote_indexer_failure_clear_repair + alias: OneNote Indexer - Clear Repair On Recovery + description: Clear the Spook Repair issue when OneNote indexer is healthy again. + mode: single + trigger: + - platform: state + entity_id: binary_sensor.onenote_indexer_job_failed + to: "off" + for: "00:02:00" + action: + - service: repairs.remove + continue_on_error: true + data: + issue_id: "onenote_indexer_job_failed" + - service: script.send_to_logbook + data: + topic: "ONENOTE" + message: "OneNote indexer recovered. Spook repair cleared." diff --git a/config/recorder.yaml b/config/recorder.yaml index ed60e02f..f4dc3d13 100755 --- a/config/recorder.yaml +++ b/config/recorder.yaml @@ -57,8 +57,12 @@ exclude: entities: - automation.update_garage_get_status - binary_sensor.bear_stone + - binary_sensor.onenote_indexer_job_failed + - binary_sensor.onenote_indexer_last_job_successful - binary_sensor.vcloudinfo_com - binary_sensor.powerwall_charging + - sensor.onenote_indexer_last_job_status + - sensor.onenote_indexer_status_payload - sensor.phyn_current_water_pressure - sensor.vcloudinfo_com - number.alarm_panel_1_screen_brightness