Home Assistant: Difference between revisions

imported>Fab
m Fix naming
imported>Mweinelt
PostgreSQL support
Line 26: Line 26:
   };
   };


</syntaxHighlight>
= Adding postgresql support =
Home-assistant supports PostgreSQL as a database backend for, among other things, its logger and history components. It's a lot more scalable and typically provides faster response times than the SQLite database, that is used by default.
Remember to make backups of your database, for home-assistant is becoming more and more stateful and has moved away from a completely declarative YAML configuration for new and core components.
<syntaxHighlight lang=nix>
  services.home-assistant = {
    package = (pkgs.home-assistant.override {
      extraPackages = py: with py; [ psycopg2 ];
    });
    config.recorder.db_url = "postgresql://@/hass";
  };
  services.postgresql = {
    enable = true;
    ensureDatabases = [ "hass" ];
    ensureUsers = [{
      name = "hass";
      ensurePermissions = {
        "DATABASE hass" = "ALL PRIVILEGES";
      };
    }];
  };
</syntaxHighlight>
</syntaxHighlight>