{ pkgs, config, ... }:
{
  # Enable the Home Assistant service
  services.home-assistant = {
    enable = true;
    package = pkgs.unstable.home-assistant;
    configWritable = true;
    config = null;
    extraPackages =
      python3Packages: with pkgs.unstable.python312Packages; [
        aiopyarr
        zigpy-cc
        zigpy-znp
        zigpy-zigate
        zigpy-xbee
        zigpy-deconz
        pykodi
        gtts
        bellows
        radios
        paho-mqtt
        zha-quirks
        uiprotect
        unifi-discovery
        universal-silabs-flasher
        vacuum-map-parser-base
        vacuum-map-parser-roborock
        python-roborock
      ];
    customComponents =
      with pkgs.home-assistant-custom-components;
      [
      ];
  };

  # Enable the mosquitto MQTT broker
  services.mosquitto = {
    enable = true;
    persistence = true;
    listeners = [
      {
        acl = [ "pattern readwrite #" ];
        omitPasswordAuth = true;
        settings.allow_anonymous = true;
      }
    ];
  };

  # Enable the zigbee2mqtt service
  services.zigbee2mqtt = {
    enable = true;
    package = pkgs.unstable.zigbee2mqtt;
    settings = {
      homeassistant = {
        legacy_entity_attributes = false;
        legacy_triggers = false;
      };
      availability = true;
      frontend = true;
      permit_join = false;
      serial.port = "/dev/ttyUSB0";
    };
  };
}