Skip to content

WifiBroadcast

Package: @alchemy-unifi/network@0.1.2-nightly.20261027100339.gc70dd7b.0 · Source: WifiBroadcast.ts

A Wi-Fi network (SSID). type is "STANDARD" or "IOT_OPTIMIZED". Existing broadcasts are adopted by SSID with --adopt.

network is a network reference, or WifiBroadcast.NATIVE_NETWORK for the site’s default network. A reference to the default network (like lan below) works too.

A WPA2 network on the default network

import * as UnifiNetwork from "@alchemy-unifi/network";
import * as Alchemy from "alchemy";
import * as Config from "effect/Config";
import * as Effect from "effect/Effect";
export default Alchemy.Stack(
"HomeNetwork",
{ providers: UnifiNetwork.providers(), state: UnifiNetwork.state() },
Effect.gen(function* () {
const lan = yield* UnifiNetwork.Network.lookup({ vlanId: 1 });
yield* UnifiNetwork.WifiBroadcast("home", {
type: "STANDARD",
name: "Home",
enabled: true,
network: lan,
securityConfiguration: {
type: "WPA2_PERSONAL",
passphrase: yield* Config.Redacted("WIFI_PASSPHRASE"),
fastRoamingEnabled: false,
},
broadcastingFrequenciesGHz: [2.4, 5],
hideName: false,
clientIsolationEnabled: false,
multicastToUnicastConversionEnabled: false,
uapsdEnabled: false,
channel2gLockedTo6: false,
dtimPeriod2gLockedTo3: false,
advertiseDeviceName: false,
arpProxyEnabled: false,
bssTransitionEnabled: true,
});
}),
);

Read passphrases from config as Redacted, as above, to keep them out of logs and plans.

WifiBroadcast.lookup({ name }) finds a broadcast the stack uses but doesn’t manage.

An SSID made in the UI

import * as UnifiNetwork from "@alchemy-unifi/network";
import * as Effect from "effect/Effect";
export const guestWifi = Effect.gen(function* () {
const broadcast = yield* UnifiNetwork.WifiBroadcast.lookup({ name: "Guests" });
return broadcast.wifiBroadcastId;
});

Props are authoritative: every update sends the whole broadcast, with explicit defaults for unset fields (a standard broadcast’s bandSteeringEnabled: false), so changes made in the UI, passphrases included, are put back. The config attribute mirrors the console’s object, so alchemy drift sees them.