Home Assistant with Local AI
What this article covers
- Connecting Home Assistant to local AI (Ollama).
- How a local voice assistant works.
- Building intelligent automations with AI.
- Practical examples for lighting, climate, security, and energy.
- Best practices for privacy and performance.
Introduction: Home Assistant with AI explained
Home Assistant controls your smart home. Add local AI and it becomes intelligent: “Make it cozy” becomes “Turn on lights, set temperature to 22°, play music”. The AI understands context and makes decisions, all locally, no cloud required.
This article is for Home Assistant users looking to integrate AI. For background, check out Smart Home Automation and Ollama.
Why do you need Home Assistant with AI?
Standard automation: “If temperature exceeds 25°, turn on AC”. With AI: “It’s warm and I have guests coming over, cool things down and ventilate the space”. The AI grasps context, not just thresholds.
Home Assistant with AI in a nutshell
Ollama works as a conversation agent in Home Assistant. Assist (the voice assistant) uses Ollama for understanding, Whisper for speech recognition, and Piper for speech synthesis. AI in automations enables smarter decision-making.
The core idea: local AI as your smart home’s brain.
Who this article is for
- Home Assistant users who want to add AI to their setup.
- Privacy-conscious users who don’t want cloud-based voice assistants.
- Smart home enthusiasts building intelligent automations.
- Self-hosters who prefer everything running locally.
Key terminology
- Home Assistant - Smart home platform. Use when: you need a central hub.
- Assist - HA’s voice assistant. Use when: you want voice control.
- Ollama - Local model server. Use when: you need the AI backend.
- Whisper - Speech-to-text. Use when: accepting voice input.
- Piper - Text-to-speech. Use when: generating voice output.
- Node-RED - Complex workflows. Use when: building advanced logic.
Setup
1. Ollama in Home Assistant
# configuration.yaml
ollama:
url: http://ollama:11434
Or via the UI: Settings → Devices & Services → Add Integration → Ollama → URL: http://ollama:11434
2. Configure Assist
# Assist uses Ollama as the conversation agent
conversation:
intents:
# Custom intents here
In the UI:
- Settings → Voice Assistants → Assist
- Conversation Agent: Ollama
- STT: Whisper (local)
- TTS: Piper (local)
3. Docker stack
version: "3.8"
services:
homeassistant:
image: homeassistant/home-assistant:latest
ports:
- "8123:8123"
volumes:
- ha_config:/config
ollama:
image: ollama/ollama:latest
ports:
- "11434:11434"
volumes:
- ollama_data:/root/.ollama
whisper:
image: rhasspy/wyoming-whisper:latest
ports:
- "10300:10300"
command: --model small --language de
piper:
image: rhasspy/wyoming-piper:latest
ports:
- "10200:10200"
command: --voice de_DE-thorsten-high
volumes:
ha_config:
ollama_data:
Practical example 1: Natural language commands
automation:
- alias: "AI light control"
trigger:
- platform: conversation
command:
- "Turn the light [in the] {room} [on|off]"
action:
- service: light.toggle
target:
area_id: "{{ trigger.slots.room }}"
Practical example 2: Intelligent climate control
automation:
- alias: "AI climate"
trigger:
- platform: time_pattern
minutes: "/15"
action:
- service: ollama.generate
data:
prompt: |
Data:
- Outside temperature: {{ states('sensor.aussentemperatur') }}°C
- Inside temperature: {{ states('sensor.innentemperatur') }}°C
- Occupancy: {{ states('person.max') }}
- Time: {{ now().strftime('%H:%M') }}
What should the heating/cooling system do?
Reply with: heat, cool, off, or ventilate + brief reason
response_variable: ki_decision
- choose:
- conditions: "{{ 'heat' in ki_decision.text }}"
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
Practical example 3: Morning briefing
automation:
- alias: "AI morning briefing"
trigger:
- platform: time
at: "07:30:00"
action:
- service: ollama.generate
data:
prompt: |
Create a morning briefing:
- Weather: {{ states('weather.home') }}
- Temperature: {{ states('sensor.aussentemperatur') }}°C
- Calendar: {{ states('calendar.personal') }}
- Electricity rate: {{ states('sensor.strompreis') }} cents/kWh
Keep it brief and friendly, 3 sentences.
response_variable: briefing
- service: notify.notify
data:
title: "Morning briefing"
message: "{{ briefing.text }}"
Practical example 4: Security analysis
automation:
- alias: "AI security"
trigger:
- platform: state
entity_id: binary_sensor.bewegung
to: "on"
condition:
- condition: time
after: "23:00"
before: "06:00"
action:
- service: ollama.generate
data:
prompt: |
Motion detected at night:
- Sensor: {{ trigger.entity_id }}
- Time: {{ now().strftime('%H:%M') }}
- People home: {{ states('group.personen') }}
Is this suspicious? Reply with: normal or suspicious + reason
response_variable: analyse
- choose:
- conditions: "{{ 'suspicious' in analyse.text }}"
sequence:
- service: notify.notify
data:
title: "Security alert"
message: "{{ analyse.text }}"
Security considerations
- Everything local: Whisper, Ollama, Piper, no cloud needed.
- Validation: Verify AI decisions for critical actions (unlocking doors). See Human approval.
- Fallback: If AI fails, critical automations should continue running in HA.
- Logging: Record AI decisions. See Logging.
Common pitfalls
- Model too slow: Large models (over 13B parameters) are slow for real-time use. Use llama3.1:8b instead.
- Whisper model choice:
smallis good for most use cases.largeis more accurate but slower. - German voice: For Piper, use
de_DE-thorsten-highfor good quality. - Context overflow: Too many entities in your prompt overload the model. Filter for what’s relevant.
- AI misinterprets: “Turn on light” might affect multiple entities. Write precise prompts.
Further reading
- Smart Home Automation - Overview.
- Local voice assistant - Voice assistant in detail.
- Smart home agent - AI agents in smart homes.
- Home Assistant integration - HA with Ollama.
- Node-RED Home Assistant - Node-RED and HA.
- Ollama - Model server.
Key takeaways:
- Home Assistant plus Ollama gives you a fully local voice assistant.
- Whisper for speech-to-text, Ollama for understanding, Piper for speech synthesis.
- Use AI in automations for intelligent decision-making.
- Everything stays local, no cloud, no data leaves your network.
- Small models (8B) for real-time use, larger ones for analysis.
FAQ
How do I connect Ollama to Home Assistant?
Can I run the voice assistant completely locally?
Which Ollama model is best for a smart home?
How fast is the voice control?
Does my data stay private?
What hardware do I need?
What if the AI misunderstands a command?
Home Assistant with Ollama or Alexa?
Sources and further reading
- Home Assistant Ollama - Integration.
- Home Assistant Assist - Voice assistant.
- Wyoming - Speech services.
- Ollama - Model server.


