Ollama

The Ollama integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] adds a conversation agent in Home Assistant powered by a local Ollama server.

Controlling Home Assistant is an experimental feature that provides the AI access to the Assist API of Home Assistant. You can control what devices and entities it can access from the exposed entities page. The AI is able to provide you information about your devices and control them.

This integration does not integrate with sentence triggers.

This integration requires an external Ollama server, which is available for macOS, Linux, and Windows. Follow the download instructions to install the server. Once installed, configure Ollama to be accessible over the network.

Configuration

To add the Ollama service to your Home Assistant instance, use this My button:

Manual configuration steps

If the above My button doesn’t work, you can also perform the following steps manually:

Options

Options for Ollama can be set via the user interface, by taking the following steps:

  • Browse to your Home Assistant instance.
  • Go to Settings > Devices & Services.
  • If multiple instances of Ollama are configured, choose the instance you want to configure.
  • Select the integration, then select Configure.
URL

The URL of the external Ollama server, such as http://localhost:11434.

Model

Name of the Ollama model to use, such as mistral or llama2:13b. Models will be automatically downloaded during setup.

Instructions

Instructions for the AI on how it should respond to your requests. It is written using Home Assistant Templating.

Control Home Assistant

If the model is allowed to interact with Home Assistant. It can only control or provide information about entities that are exposed to it. This feature is considered experimental and see Controlling Home Assistant below for details on model limitations.

Context window size

The context window size is the number of tokens the model can take as input. Home Assistant defaults to 8k, which is larger than the default value in Ollama Server (2k), and you may adjust it based on the maximum context size of the specific model used. A larger value will better support larger homes with more entities, and smaller values may lower Ollama server RAM usage.

Max history messages

Maximum number of messages to keep for each conversation (0 = no limit). Limiting this value will cause older messages in a conversation to be dropped.

Keep alive

Duration in seconds for the Ollama host to keep the model in memory after receiving a message (-1 = no limit, 0 = no retention). Default value is -1.

Controlling Home Assistant

If you want to experiment with local LLMs using Home Assistant, we currently recommend using the llama3.1:8b model and exposing fewer than 25 entities. Note that smaller models are more likely to make mistakes than larger models.

Only models that support Tools may control Home Assistant.

Smaller models may not reliably maintain a conversation when controlling Home Assistant is enabled. However, you may use multiple Ollama configurations that share the same model, but use different prompts:

  • Add the Ollama integration without enabling control of Home Assistant. You can use this conversation agent to have a conversation.
  • Add an additional Ollama integration, using the same model, enabling control of Home Assistant. You can use this conversation agent to control Home Assistant.