alchemy-unifi
Describe a UniFi site’s networks, Wi-Fi, zone-based firewall and local DNS as Effect code, and let Alchemy plan and apply the changes on your console.
import * as UnifiNetwork from "@alchemy-unifi/network";import * as Alchemy from "alchemy";import * as Effect from "effect/Effect";
export default Alchemy.Stack( "HomeNetwork", { providers: UnifiNetwork.providers(), state: UnifiNetwork.state() }, Effect.gen(function* () { const cameras = yield* UnifiNetwork.FirewallZone("cameras", { name: "Cameras" }); yield* UnifiNetwork.Network("cctv", { management: "GATEWAY", name: "CCTV", vlanId: 30, enabled: true, cellularBackupEnabled: false, internetAccessEnabled: false, isolationEnabled: true, zone: cameras, ipv4Configuration: { autoScaleEnabled: false, hostIpAddress: "192.168.30.1", prefixLength: 24 }, }); yield* UnifiNetwork.FirewallPolicy("cameras-to-internal", { name: "Block cameras to internal", enabled: true, action: { type: "BLOCK" }, source: { zone: cameras }, destination: { zone: UnifiNetwork.FirewallZone.INTERNAL }, ipProtocolScope: { ipVersion: "IPV4_AND_IPV6" }, loggingEnabled: false, }); }),);Networks
Section titled “Networks”Firewall
Section titled “Firewall”- Zones: custom and built-in zones.
- Policies: allow, block or reject traffic between zones.
- Ordering: the order a zone pair’s policies run in.
- Traffic-matching lists: reusable port and address lists.
- Local DNS: records and forwarded domains on the gateway.
- State on the console: keep a stack’s state on the console it manages.
Concepts
Section titled “Concepts”- References and lookups: point at managed, existing and built-in objects.
- Changes made in the UI: what deploys and
alchemy driftdo with them. - Adoption: take over objects that already exist.
- Calling the Integration API: the raw Effect SDK the provider is built on.
Requirements
Section titled “Requirements”- UniFi Network 10.6 with the zone-based firewall. The provider tracks the latest stable Network release, and warns when a console runs another version.
- Node 22 or later, Alchemy 2 (beta) and Effect 4.
For a real-world config, see home-network: two sites sharing one stack, with zones, networks, Wi-Fi, a full firewall matrix and the state store on the console.