Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save peyanski/23fe1625182b93d893b35211ee92fb79 to your computer and use it in GitHub Desktop.

Select an option

Save peyanski/23fe1625182b93d893b35211ee92fb79 to your computer and use it in GitHub Desktop.
alias: AI Network Anomaly Detector - Is This Normal
triggers:
- entity_id: input_button.start_automation
trigger: state
actions:
- action: ai_task.generate_data
data:
entity_id: ai_task.ollama_ai_task_gpt_oss_120b_cloud
task_name: Network anomaly detection
instructions: |-
You are a home network anomaly detection assistant.
Compare CURRENT STATE against both 24h and 168h baselines.
Determine one verdict:
- NORMAL
- TEMPORARY ABNORMALITY
- ONGOING ABNORMALITY
Then:
1. Clearly state the verdict
2. Explain the likely cause in simple human language
3. If abnormal, give 1–3 practical suggestions
Be concise, calm, and avoid technical jargon.
Do not invent historical values.
Assume historical data may be partially filled.
{{ snapshot }}
{{ baselines }}
response_variable: ai_response
- action: persistent_notification.create
data:
title: Network Health Check (AI)
notification_id: Net
message: "{{ ai_response.data }}"
mode: single
variables:
snapshot: |
CURRENT STATE:
Internet:
- Reachable: {{ states('binary_sensor.8_8_8_8') }}
- Packet loss now: {{ states('sensor.8_8_8_8_packet_loss') }} %
Router:
- Reachable: {{ states('binary_sensor.10_0_0_1') }}
- Packet loss now: {{ states('sensor.10_0_0_1_packet_loss') }} %
Laptop:
- Reachable: {{ states('binary_sensor.10_0_0_117') }}
- Packet loss now: {{ states('sensor.10_0_0_117_packet_loss') }} %
- Jitter now: {{ states('sensor.10_0_0_117_jitter') }} ms
- RTT now: {{ states('sensor.10_0_0_117_round_trip_time_average') }} ms
baselines: >
BASELINES (historical averages):
Internet packet loss:
- 24h avg: {{ states('sensor.internet_packet_loss_mean_24h') }} %
- 168h avg: {{ states('sensor.internet_packet_loss_mean_168h') }} %
Router packet loss:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment