Skip to content

About

This Home Assistant integration provides persistent, key-value storage backed by SQLite for automations, scripts, and integrations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

Repository files navigation

Settings Store

This Home Assistant integration provides persistent, key-value storage backed by SQLite for automations, scripts, and integrations.

It allows you to store, update, retrieve, and delete arbitrary settings organized by scopes (namespaces) and keys, persisting them safely across Home Assistant restarts.

It is especially useful when you want to:

  • Avoid cluttering Home Assistant with dummy helper entities (input_text, input_number, input_boolean, template sensors, or switches) created solely to persist intermediate states or automation variables.
  • Store state, runtime configuration, or counters that need to persist across restarts.
  • Organize settings into logical namespaces (scope) and key names (name).
  • Share custom configuration data between different automations, scripts, and templates.
  • Dynamically update and query parameters at runtime without modifying YAML configuration files.

Installation

This integration is installed via HACS:

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  1. Click the button above to open the repository in HACS.
  2. Click Download to download the integration.
  3. Restart Home Assistant.

Note: Alternatively, you can add https://github.com/catgiggle/HomeAssistant-SettingsStore as a custom repository under HACS → Integrations.

Configuration

Open your Home Assistant instance and show an integration.

  1. Click the button above or go to Settings → Devices & Services → Add Integration and search for Settings Store.
  2. Configure the instance parameters:

You can add multiple instances of this integration. Each instance represents an isolated SQLite settings store.

installation.png

Parameter Description
Display name Display name for the instance (shown in Home Assistant UI).
Internal name Unique identifier used as the SQLite database filename. If left empty, it is generated automatically from Display name.

Features

  • Persistent key-value storage backed by SQLite (.storage/settings_store/<name>.db)
  • Grouping of settings using scopes (namespaces) and keys
  • Automatic tracking of creation (created_at) and modification (modified_at) timestamps for each entry
  • No need to create throwaway helper entities (input_*, dummy switches/sensors) just to store state
  • Atomic upsert operations (insert or update on key conflict)
  • Diagnostic sensor reporting total stored entries count along with store-wide and per-scope metrics and timestamps
  • Response data support in get and list services for direct use in automations, scripts, and templates
  • Ability to delete individual entries or clear entries by scope or entire store
  • Isolated storage per configured instance

features.png

Entities

Each configured instance creates the following diagnostic sensor:

  • Store: Displays the current total number of entries stored in the instance's database. This sensor automatically updates whenever records are created, updated, deleted or cleared. Its entity_id is passed in the store parameter to the integration's services.
    • Attributes:
      • store_created_at: Timestamp of the first entry created in the store (YYYY-MM-DD HH:MM:SS or null).
      • store_modified_at: Timestamp of the most recently modified entry across the entire store (YYYY-MM-DD HH:MM:SS or null).
      • store_hash: MD5 checksum hash calculated from store entry count, first creation timestamp, and last modification timestamp.
      • <scope>_count: Total number of entries stored in a given scope.
      • <scope>_created_at: Timestamp of the first entry created in a given scope (YYYY-MM-DD HH:MM:SS).
      • <scope>_modified_at: Timestamp of the most recently modified entry for a given scope (YYYY-MM-DD HH:MM:SS).

Services

This integration provides the following services:

settings_store.set

Sets or updates a value for a specific scope and name in the store. If the entry already exists, its value is updated. Alternatively, provide id to update an existing entry. An unknown id does not create an entry. Updating by id changes the value and modification timestamp; the entry's name and scope remain unchanged.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
id Optional ID of the entry to update; cannot be combined with scope or name
scope Scope (defaults to default when updating by name)
name Setting key name (required without id)
value Value to store

settings_store.patch

Partially updates a JSON value by scope and name, or by ID, merging properties without overwriting existing fields (JSON Merge Patch). If the entry does not exist, it is created. If either the existing or incoming value is not valid JSON, it falls back to replacing the value.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
id Optional ID of the entry to patch; cannot be combined with scope or name
scope Scope (defaults to default when updating by name)
name Setting key name (required without id)
value Value or JSON patch to merge

settings_store.get

Retrieves the stored value and timestamps by id or by scope and name. Supports returning service response data.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
id Optional entry ID; cannot be combined with scope or name
scope Scope (defaults to default when retrieving by name)
name Setting key name (required without id)

Response

Returns a dictionary containing the entry ID, setting key name, scope, stored value and timestamps:

{
  "id": 1,
  "name": "last_run_duration",
  "scope": "irrigation",
  "value": "15",
  "created_at": "2026-10-12 14:00:00",
  "modified_at": "2026-10-12 14:30:00"
}
  • id: Entry ID or null if the key does not exist.
  • name: Setting key name or null if the key does not exist.
  • scope: Scope / namespace identifier or null if the key does not exist.
  • value: Stored value string or null if the key does not exist.
  • created_at: Creation timestamp formatted as YYYY-MM-DD HH:MM:SS (or null if not found).
  • modified_at: Last modification timestamp formatted as YYYY-MM-DD HH:MM:SS (or null if not found).

settings_store.list

Retrieves all stored entries for a given scope (or across all scopes if scope: "*"), ordered alphabetically by key name. Supports returning service response data.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
scope Scope / namespace identifier (optional, defaults to default; use * to list all entries across all scopes)

Response

Returns a dictionary containing a list array of stored entries:

{
  "list": [
    {
      "id": 1,
      "name": "interval_minutes",
      "scope": "irrigation",
      "value": "30",
      "created_at": "2026-10-12 10:00:00",
      "modified_at": "2026-10-12 10:00:00"
    },
    {
      "id": 2,
      "name": "last_run_duration",
      "scope": "irrigation",
      "value": "15",
      "created_at": "2026-10-12 14:00:00",
      "modified_at": "2026-10-12 14:30:00"
    }
  ]
}
  • list: Array of entries for the requested scope (ordered alphabetically by name, or by scope then name when * is used).
    • id: Entry ID.
    • name: Setting key name.
    • scope: Scope / namespace identifier.
    • value: Stored value string.
    • created_at: Creation timestamp formatted as YYYY-MM-DD HH:MM:SS.
    • modified_at: Last modification timestamp formatted as YYYY-MM-DD HH:MM:SS.

settings_store.delete

Deletes a specific setting identified by ID or by scope and name. An unknown ID has no effect.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
id Optional entry ID; cannot be combined with scope or name
scope Scope / namespace identifier (optional, defaults to default without id)
name Setting key name (required without id)

settings_store.clear

Removes stored entries from the instance's database for a specific scope, or all entries across all scopes if scope: "*" is provided.

Field Description
store Entity ID of the Settings Store sensor (identifies target storage instance)
scope Scope / namespace identifier to clear (optional, defaults to default; use * to clear all scopes)

Usage Examples

Storing a Value

action: settings_store.set
data:
  store: sensor.settings_store_main_store
  scope: irrigation
  name: last_run_duration
  value: "15"

Retrieving a Value in an Automation or Script

action: settings_store.get
data:
  store: sensor.settings_store_main_store
  scope: irrigation
  name: last_run_duration
response_variable: saved_setting

action: notify.persistent_notification
data:
  message: "Last duration was {{ saved_setting.value }} minutes (modified at {{ saved_setting.modified_at }})."

Listing Entries in an Automation or Script

action: settings_store.list
data:
  store: sensor.settings_store_main_store
  scope: irrigation
response_variable: irrigation_settings

action: notify.persistent_notification
data:
  message: >
    {% for entry in irrigation_settings.list %}
      {{ entry.name }}: {{ entry.value }} (created: {{ entry.created_at }}, modified: {{ entry.modified_at }})
    {% endfor %}

Deleting a Setting

action: settings_store.delete
data:
  store: sensor.settings_store_main_store
  scope: irrigation
  name: last_run_duration

To update or delete an entry by ID, provide id instead of name and scope:

action: settings_store.set
data:
  store: sensor.settings_store_main_store
  id: 2
  value: "20"
action: settings_store.delete
data:
  store: sensor.settings_store_main_store
  id: 2

Retrieving All Entries Across Scopes

action: settings_store.list
data:
  store: sensor.settings_store_main_store
  scope: "*"
response_variable: all_settings

action: notify.persistent_notification
data:
  message: >
    {% for entry in all_settings.list %}
      [{{ entry.scope }}] {{ entry.name }}: {{ entry.value }} (modified: {{ entry.modified_at }})
    {% endfor %}

Clearing Settings

To clear settings within the default scope:

action: settings_store.clear
data:
  store: sensor.settings_store_main_store

To clear settings within a specific scope:

action: settings_store.clear
data:
  store: sensor.settings_store_main_store
  scope: irrigation

To clear all stored settings across all scopes:

action: settings_store.clear
data:
  store: sensor.settings_store_main_store
  scope: "*"

Notes

  • Settings are stored in .storage/settings_store/<name>.db within your Home Assistant configuration directory.
  • Values are stored as strings in SQLite, allowing you to store primitive values, JSON strings, or serialized payloads.
  • Removing an instance through the Home Assistant UI will automatically delete its associated database file.

About

This Home Assistant integration provides persistent, key-value storage backed by SQLite for automations, scripts, and integrations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages