Storage module.


File based storage module.

Memory storage module.


class AbstractStorage

Abstract base class handling all logic except for saving and loading.

New storage modules should generally inherit from this class and implement save and load according to the underlying storage mechanism.

Initialize a new AbstractStorage instance.



Instance variables

var changed -> bool

Return if anything has changed in the model since loading.

This property will return True if a any setting has been changed. It is reset when data is loaded into storage (by calling load) or manually by calling mark_as_solved (typically done by save).

var storage_model -> StorageModel

Return storage model representation.


async def get_settings(self, config: BaseConfig) -> Settings

Return settings for a specific configuration (device).

The returned Settings object is a reference to an object in the storage module. Changes made can/will be written back to the storage in case "save" is called.

If no settings exists for the current configuration, new settings are created automatically and returned. If the configuration does not contain any valid identitiers, DeviceIdMissingError will be raised.

If settings exists for a configuration but mismatch, they will be automatically updated in the storage. Set ignore_update to False to not update storage.

def mark_as_saved(self) -> None

Call after saving to indicate settings have been saved.

The changed property reflects whether something has been changed in the model or not based on calling this method.

Inherited members

class StorageModel (**data: Any)

Storage model of data that is saved or restored to underlying storage.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.


  • pydantic.v1.main.BaseModel
  • pydantic.v1.utils.Representation

Class variables

var devices -> List[Settings]
var version -> int