Skip to content

Memory & Knowledge

brAIn keeps one memory of your home: preferences, nicknames, household patterns, device quirks. It is what turns “turn on the beacon” into the office lamp. The terminal, the chat, voice, insight cards and house checks all read it, and you can see and change every line.

Memory → Knowledge: “Everything brAIn believes about this house”, a list of rooms and devices on the left with a count beside each, and facts on the right such as “Bins go out on Thursday evenings” and “The back door sensor runs on a CR2032 that lasts about three months”, each with a bin, then a “Tell brAIn about the house…” box with Teach, and the Suggested reports and Tools folds

What ends up in it

Facts that change an answer:

  • “The office” means the upstairs back bedroom, not the study downstairs.
  • Sam is a light sleeper. Nothing in the hallway should go above 15% brightness between 23:00 and 06:00.
  • Heating is an 8 kW air-source heat pump on weather compensation. “Boost the heating” means raising the flow temperature.
  • The garage fridge is meant to run 24/7. Its draw at 3 am is the defrost cycle, not a fault.
  • Never rename an entity_id without asking. Several are referenced in a Node-RED flow I cannot see.

The last kind is a rule. Put the things you would otherwise repeat in every request here.

Browse what brAIn knows

Memory → Knowledge lists every fact.

To Do this
See what it knows about one room or device Pick it from the list on the left (a picker on a phone).
Find a fact Search facts. A device’s friendly name works.
Narrow the list The Rooms, Devices and House pills, Taught by (anyone, you, a conversation, voice…) and the sort (newest, by room or device, oldest, most certain).
Remove a wrong fact The bin beside it.
See where a fact came from Each fact records who taught it (voice, the chat, the terminal, a run) and the conversation it came from.
Have brAIn review its own memory Clean up. brAIn reads its memory and lists what looks wrong, useless or mistaken.

Nothing on Knowledge waits on you, so it has no badge. What brAIn has measured (when the house wakes, what is normal here) is in ⚙ → Diagnostics → Measurements. See Measurements.

Teach it

Way How
Type it Tell brAIn about the house… and Teach on Memory → Knowledge: “the garage freezer is off in winter”.
Say it “Remember that…” to a voice assistant.
Talk normally After each turn in the chat or the terminal, a small run with no tools reads what you said and files anything durable: a preference, a nickname, a correction. It needs two new messages, or one that plainly teaches something.
From the command line brain memory add "…"
From an automation brain.add_memory

brAIn also learns without being told:

  • From voice. When a voice conversation ends, a short pass with no tools extracts up to three durable facts. Transient states, one-off commands and secrets are excluded. A preference stated by somebody signed in to Home Assistant (“I like the bedroom at 19”) is remembered as theirs.
  • By studying. brain learn <topic>, the brain.study service or /learn in the terminal runs a deep session on one subject. With no topic it picks whatever has gone stalest.
  • From insight runs, which file their durable findings the same way.

New facts are used straight away and written into the memory document once a day, or sooner when 20 or more are waiting.

Answer its guesses

brAIn states what it believes and asks you to confirm:

“The garage fridge is meant to run 24/7, right?”

Guesses appear on Needs you under Questions for you.

Press What happens
Yes It becomes a plain fact in memory.
No A dead end that is never revisited, in any wording. Say why if you can: the reason is kept as a correction.
Snooze It leaves every screen and stops counting against the limit, so brAIn can ask something else. Its fortnight starts again when it returns.
Doesn’t apply The card closes and nothing is recorded.

Three rules hold in code, whatever a model does:

  • At most 3 open at a time.
  • An unanswered guess expires after 14 days.
  • A guess is never proposed again, confirmed or rejected, however it is reworded.

When brAIn wonders why you did something by hand and three guesses are already open, it waits for a free slot before spending anything. It never asks why about a lock, an alarm panel or where people are.

Guesses from Home Assistant:

  • binary_sensor.brain_memory_questions_waiting (Questions waiting) turns on when a guess needs an answer, with the open guesses and their ids in its attributes. Use it to push a guess to a phone before it expires.
  • brain.answer_question answers one. Start the answer with yes or no.

Rules you set

Pressing Ignore on a house check’s card writes a rule (this sensor, this check) that the check reads on its next pass.

  • A correction can reach further (the whole device, the room, everywhere) and can last until a date, a month or a season. Wide ones are asked first.
  • They are listed under Rules you set. Undo, or Let brAIn raise it again, removes the rule.
  • Only Ignore is permanent. Done and a finished to-do stop a card being raised only for as long as the problem stays fixed.

brAIn also writes short judgements about where its own calls keep disagreeing with you: “Night motion on the hall landing is the cat. 4 of 4 it raised were marked not a problem.” The counts are arithmetic, not a model’s guess. A judgement expires after 30 days unless renewed, goes away when a later card on the same thing turns out to be real, and can be deleted like any fact.

Read, edit and undo the document

Memory → Knowledge → Tools holds the memory document.

Under Tools What it is
What brAIn has written down The document, with Edit for the raw text and Export. Below it, Waiting to be filed lists every queued fact and where it came from. ✕ drops one before it reaches memory.
What brAIn is told before it works What each kind of run (a chat, a card, voice, a check) is handed, and what it can look up.
Review the whole house The deep review.

The document is /config/.brain/memory/memory.md, plain markdown, and it is yours. Your edits are the source of truth, and brAIn merges new facts around them.

Everything is also on the command line:

Terminal window
brain memory list # print the document
brain memory add "Guests use the loft" # teach it something
brain memory forget "the loft is warm" # queue a line for removal
brain memory edit # open memory.md in $EDITOR
brain memory log # what changed recently, and why
brain memory history # every kept version
brain memory undo # go back one version
brain memory undo 2 # revert change #2 from the log
brain memory hypotheses # guesses waiting on a yes/no
brain memory confirm "<text>" # yes: file it as a fact
brain memory reject "<text>" "why" # no: a dead end, with your reason
brain memory inbox # facts waiting to be filed
brain memory consolidate # file them now
brain memory clear --confirm # reset (old file kept as memory.md.bak)
brain learn energy # study a topic now
brain learn # study whatever is stalest

Forgetting reaches everything. A line you delete from the document, a brain memory forget, a cleared memory, the ✕ on a queued fact and an Undo all reach what every run is told, not only the file you can see. Your own corrections and the rules an Ignore made survive a document that does not quote them.

Move it to new hardware

Terminal window
brain memory export # on the old box: one JSON file
brain memory import backup.json # on the new one

The export carries the memory document, the Needs you work list, the answers you gave, the facts and the rules your Ignore presses made. Export under Tools downloads the same file.

Import is command-line only, and it is a migration, not a sync:

  • Your existing entries win where the two disagree.
  • The memory document replaces only an effectively empty one, unless you pass --replace-memory.
  • Importing the same file twice changes nothing the second time.

Use it from Home Assistant

# Teach a fact from an automation (administrators only when called by a signed-in user)
action: brain.add_memory
data:
fact: "The dog gets fed at 7 and 17. Kitchen lights on then means feeding time"
confidence: high # high | medium | low (default medium)
# Study a topic in the background; results arrive in memory, not in a response
action: brain.study
data:
topic: "energy" # omit to study whatever has gone stalest
Entity or event What it is
brain_learned A logbook event for every new fact: “brAIn learned: the hallway sensor drops offline around 2am”.
sensor.brain_memory_facts_learned How many things it knows.
sensor.brain_memory_last_learned The most recent one, with the text as an attribute.
binary_sensor.brain_memory_questions_waiting On while a guess needs an answer.
sensor.brain_findings_open_findings How many cards are waiting on you, with the severity split and the texts.
brain_finding Fires for every new finding, and can ring your phone. See notifications.

Turn learning off

Switch Effect
⚙ → Features → Learning loop The master switch. Off stops the voice pass, what the terminal and chat teach, and the rest of learning. Existing memory stays and is still used.
memory_injection: false Keep learning, but stop adding memory to voice prompts.
brain memory clear --confirm Forget everything learned so far.

How memory is stored

What Role
memory.md The document. Plain markdown, editable, capped at memory_max_kb (default 32 KB, range 1–64).
voice.md A summary of at most 2 KB that voice reads on every request. Regenerated, so do not edit it.
The inbox A queue of facts waiting to be filed.
Guesses A queue of open guesses.
The change log An audit trail, so you can see what changed and undo it.
Facts The same knowledge one fact at a time, tagged with what it is about, who taught it and when. This is what Knowledge shows and what a run looks things up in.

All of it lives under /config/.brain/memory/. The queues and the change log are never put into a prompt.

  • One writer. Only the daily filing pass writes memory.md. It dedupes, lets the newest fact win a contradiction and holds the size cap.
  • It cannot quietly erase what it knows. A pass that would drop more than 60% of the document is refused, and a failed pass leaves memory untouched with the queue still waiting. Both files are replaced whole or not at all.
  • Runs get the facts that matter. A run is handed facts about the rooms and devices it is reading, with facts that share words with your question first.
  • Duplicates merge. The same fact said two ways is stored once. Facts that differ by a “not” stay apart.
  • Some facts expire. A note about a device’s health (“the hall sensor’s battery is at 12%”) expires after thirty days, and a reading of one moment after two. Facts about an entity your house no longer has stop being used at once, are removed thirty days later, and come back if the entity does.
  • The cap is not a speed setting. Voice reads the 2 KB summary, never the document. The cap decides how much brAIn can know before filing something new means dropping something old.