Compare commits
5 Commits
46993821ae
...
327d4276ec
| Author | SHA1 | Date |
|---|---|---|
|
|
327d4276ec | 3 weeks ago |
|
|
ae2850fe54 | 3 weeks ago |
|
|
ca71ac2522 | 3 weeks ago |
|
|
cd0431daf1 | 3 weeks ago |
|
|
4d553735ea | 3 weeks ago |
@ -0,0 +1,95 @@
|
|||||||
|
######################################################################
|
||||||
|
# @CCOSTAN - Follow Me on X
|
||||||
|
# For more info visit https://www.vcloudinfo.com/click-here
|
||||||
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# MQTT Broker Monitoring - Broker reachability + remediation handoff
|
||||||
|
# Probes local MQTT broker TCP health and escalates failures to Spook + Joanna.
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# Notes: Probe target is pinned to docker_10 host broker endpoint 192.168.10.10:1883.
|
||||||
|
# Notes: `binary_sensor.mqtt_status_raw` is `on` when probe returns `open`.
|
||||||
|
# Notes: Creates/clears Spook repair issue `mqtt_broker_unreachable`.
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
command_line:
|
||||||
|
- binary_sensor:
|
||||||
|
name: MQTT Status Raw
|
||||||
|
unique_id: mqtt_status_raw
|
||||||
|
command: >-
|
||||||
|
/bin/bash -c "(echo > /dev/tcp/192.168.10.10/1883) > /dev/null 2>&1 && echo open || echo closed"
|
||||||
|
payload_on: "open"
|
||||||
|
payload_off: "closed"
|
||||||
|
scan_interval: 60
|
||||||
|
|
||||||
|
template:
|
||||||
|
- binary_sensor:
|
||||||
|
- name: MQTT Broker Problem
|
||||||
|
unique_id: mqtt_broker_problem
|
||||||
|
device_class: problem
|
||||||
|
state: >-
|
||||||
|
{{ states('binary_sensor.mqtt_status_raw') | lower in ['off', 'unknown', 'unavailable'] }}
|
||||||
|
|
||||||
|
automation:
|
||||||
|
- id: mqtt_open_repair_on_failure
|
||||||
|
alias: MQTT - Open Repair On Failure
|
||||||
|
description: Open a Spook Repair issue and dispatch Joanna when broker health is down.
|
||||||
|
mode: single
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: binary_sensor.mqtt_broker_problem
|
||||||
|
to: "on"
|
||||||
|
for: "00:03:00"
|
||||||
|
action:
|
||||||
|
- variables:
|
||||||
|
broker_endpoint: "192.168.10.10:1883"
|
||||||
|
mqtt_raw_state: "{{ states('binary_sensor.mqtt_status_raw') }}"
|
||||||
|
issue_id: "mqtt_broker_unreachable"
|
||||||
|
trigger_context: "HA automation mqtt_open_repair_on_failure (MQTT - Open Repair On Failure)"
|
||||||
|
- service: repairs.create
|
||||||
|
data:
|
||||||
|
issue_id: "{{ issue_id }}"
|
||||||
|
title: "MQTT broker unreachable"
|
||||||
|
severity: "warning"
|
||||||
|
persistent: true
|
||||||
|
description: >-
|
||||||
|
Home Assistant detected MQTT broker connectivity failure.
|
||||||
|
|
||||||
|
broker_endpoint: {{ broker_endpoint }}
|
||||||
|
mqtt_status_raw: {{ mqtt_raw_state }}
|
||||||
|
- service: script.send_to_logbook
|
||||||
|
data:
|
||||||
|
topic: "MQTT"
|
||||||
|
message: >-
|
||||||
|
MQTT broker appears down at {{ broker_endpoint }}. Spook repair opened and Joanna remediation requested.
|
||||||
|
- service: script.joanna_dispatch
|
||||||
|
data:
|
||||||
|
trigger_context: "{{ trigger_context }}"
|
||||||
|
source: "home_assistant_automation.mqtt_open_repair_on_failure"
|
||||||
|
summary: "MQTT broker endpoint is unreachable"
|
||||||
|
entity_ids:
|
||||||
|
- "binary_sensor.mqtt_status_raw"
|
||||||
|
- "binary_sensor.mqtt_broker_problem"
|
||||||
|
diagnostics: >-
|
||||||
|
issue_id={{ issue_id }},
|
||||||
|
broker_endpoint={{ broker_endpoint }},
|
||||||
|
mqtt_status_raw={{ mqtt_raw_state }}
|
||||||
|
request: "Troubleshoot and resolve MQTT broker reachability if possible."
|
||||||
|
|
||||||
|
- id: mqtt_clear_repair_on_recovery
|
||||||
|
alias: MQTT - Clear Repair On Recovery
|
||||||
|
description: Clear the Spook Repair issue once broker health is stable again.
|
||||||
|
mode: single
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: binary_sensor.mqtt_broker_problem
|
||||||
|
to: "off"
|
||||||
|
for: "00:02:00"
|
||||||
|
action:
|
||||||
|
- service: repairs.remove
|
||||||
|
continue_on_error: true
|
||||||
|
data:
|
||||||
|
issue_id: "mqtt_broker_unreachable"
|
||||||
|
- service: script.send_to_logbook
|
||||||
|
data:
|
||||||
|
topic: "MQTT"
|
||||||
|
message: "MQTT broker recovered at 192.168.10.10:1883. Spook repair cleared."
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
######################################################################
|
||||||
|
# @CCOSTAN - Follow Me on X
|
||||||
|
# For more info visit https://www.vcloudinfo.com/click-here
|
||||||
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# Joanna Dispatch - Shared BearClaw dispatch helper for automations
|
||||||
|
# Normalizes remediation context and forwards requests via bearclaw_command.
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# Notes: Keep this helper generic so package automations can reuse one schema.
|
||||||
|
# Notes: Source defaults to home_assistant_automation.unknown when omitted.
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
joanna_dispatch:
|
||||||
|
alias: Joanna Dispatch
|
||||||
|
description: Standardized Joanna/BearClaw dispatch helper for automation-triggered requests.
|
||||||
|
mode: queued
|
||||||
|
fields:
|
||||||
|
trigger_context:
|
||||||
|
description: Automation and trigger context string.
|
||||||
|
source:
|
||||||
|
description: Source identifier sent to BearClaw.
|
||||||
|
summary:
|
||||||
|
description: Short summary of the condition requiring Joanna.
|
||||||
|
request:
|
||||||
|
description: What Joanna should do.
|
||||||
|
entity_ids:
|
||||||
|
description: Relevant entity IDs (list or comma-delimited string).
|
||||||
|
diagnostics:
|
||||||
|
description: Extra troubleshooting context.
|
||||||
|
user:
|
||||||
|
description: BearClaw user identity.
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
normalized_context: "{{ trigger_context | default('HA automation', true) }}"
|
||||||
|
normalized_source: "{{ source | default('home_assistant_automation.unknown', true) }}"
|
||||||
|
normalized_summary: "{{ summary | default('Home Assistant remediation request', true) }}"
|
||||||
|
normalized_request: >-
|
||||||
|
{{ request | default('Investigate and recommend remediation. Do not run automated resets or power-cycles unless explicitly requested.', true) }}
|
||||||
|
normalized_user: "{{ user | default('carlo', true) }}"
|
||||||
|
normalized_entity_ids: >-
|
||||||
|
{% if entity_ids is sequence and entity_ids is not string %}
|
||||||
|
{{ entity_ids | map('string') | join(', ') }}
|
||||||
|
{% elif entity_ids is string and entity_ids | trim != '' %}
|
||||||
|
{{ entity_ids | trim }}
|
||||||
|
{% else %}
|
||||||
|
n/a
|
||||||
|
{% endif %}
|
||||||
|
normalized_diagnostics: >-
|
||||||
|
{% if diagnostics is string %}
|
||||||
|
{{ diagnostics | trim if diagnostics | trim != '' else 'n/a' }}
|
||||||
|
{% elif diagnostics is mapping or (diagnostics is sequence and diagnostics is not string) %}
|
||||||
|
{{ diagnostics | tojson }}
|
||||||
|
{% else %}
|
||||||
|
n/a
|
||||||
|
{% endif %}
|
||||||
|
- service: rest_command.bearclaw_command
|
||||||
|
data:
|
||||||
|
text: >-
|
||||||
|
Trigger: {{ normalized_context }}.
|
||||||
|
Summary: {{ normalized_summary }}.
|
||||||
|
Entity IDs: {{ normalized_entity_ids }}.
|
||||||
|
Diagnostics: {{ normalized_diagnostics }}.
|
||||||
|
Request: {{ normalized_request }}
|
||||||
|
user: "{{ normalized_user }}"
|
||||||
|
source: "{{ normalized_source }}"
|
||||||
|
context: "{{ normalized_context }}"
|
||||||
|
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 811 B |
Loading…
Reference in new issue