Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save peyanski/20d5cb3cfed41aff575fe18a032b0e21 to your computer and use it in GitHub Desktop.

Select an option

Save peyanski/20d5cb3cfed41aff575fe18a032b0e21 to your computer and use it in GitHub Desktop.
When the air quality category changes, AI reads all air quality sensors and sends you a simple, friendly notification explaining what's going on.
# 🌬️ AI Air Quality Summary - Home Assistant Automation
# This automation monitors your Google Air Quality sensors,
# uses AI to summarize the data in plain language,
# and sends you a persistent notification.
#
# 👉 Change the sensor entity IDs below to match YOUR sensors.
# Go to Settings > Devices & Services > Google Air Quality
# to find your sensor names.
alias: AI Air Quality Summary
description: >
When the air quality category changes, AI reads all air quality sensors
and sends you a simple, friendly notification explaining what's going on.
triggers:
# 🔄 Trigger: fires when the UAQI category changes
# (e.g. from "Good" to "Moderate")
# ✏️ CHANGE THIS to your UAQI Category sensor
- entity_id: sensor.home_yellow_uaqi_category
trigger: state
variables:
# 📊 Collect all air quality sensor data into one snapshot
# ✏️ CHANGE each sensor below to match YOUR sensor entity IDs
air_snapshot: |
CURRENT AIR QUALITY DATA:
📈 Overall Scores:
- Universal Air Quality Index (UAQI): {{ states('sensor.home_yellow_universal_air_quality_index') }}
- UAQI Category: {{ states('sensor.home_yellow_uaqi_category') }}
- UAQI Dominant Pollutant: {{ states('sensor.home_yellow_uaqi_dominant_pollutant') }}
🌍 Local Index (region-specific):
- Local AQI: {{ states('sensor.home_yellow_aqi_bg_aqi') }}
- Local Category: {{ states('sensor.home_yellow_aqi_bg_category') }}
- Local Dominant Pollutant: {{ states('sensor.home_yellow_aqi_bg_dominant_pollutant') }}
🔬 Individual Pollutants:
- PM2.5 (fine particles): {{ states('sensor.home_yellow_pm2_5') }} µg/m³
- PM10 (coarse particles): {{ states('sensor.home_yellow_pm10') }} µg/m³
- Ozone (O₃): {{ states('sensor.home_yellow_ozone') }} µg/m³
- Nitrogen Dioxide (NO₂): {{ states('sensor.home_yellow_nitrogen_dioxide') }} µg/m³
- Sulphur Dioxide (SO₂): {{ states('sensor.home_yellow_sulphur_dioxide') }} µg/m³
- Carbon Monoxide (CO): {{ states('sensor.home_yellow_carbon_monoxide') }} µg/m³
actions:
# 🤖 Step 1: Ask AI to summarize the air quality data
- action: ai_task.generate_data
data:
# ✏️ CHANGE THIS to your AI Task entity
entity_id: ai_task.ollama_ai_task_gpt_oss_120b_cloud
task_name: Air quality summary
instructions: |-
You are a friendly air quality assistant.
Look at the current air quality data below and write a short,
easy-to-understand summary for a regular person (not a scientist).
Your summary must include:
1. The overall air quality verdict (Is it good, okay, or bad?)
2. Which pollutant is the biggest concern right now and a one-line
explanation of what it is and why it matters
3. A quick, positive, and practical suggestion
(e.g. "Great day for a walk!" or "Maybe keep the windows
closed for now and enjoy a cozy day inside.")
Rules:
- Keep it SHORT — max 4-5 sentences
- Use simple, friendly language (like texting a friend)
- Be positive and helpful, not scary
- Use 1-2 emojis to make it feel friendly
- Do NOT list raw numbers — just explain what they mean
{{ air_snapshot }}
response_variable: ai_response
# 📬 Step 2: Send the AI summary as a persistent notification
- action: persistent_notification.create
data:
title: "🌬️ Air Quality Update"
message: "{{ ai_response.data }}"
notification_id: air_quality_ai_summary
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment