# Bluetooth Scan

Action `dot.radiowaves.left.and.right`

`action.bluetooth_scan`

Read which Bluetooth devices your Mac is connected to right now — and, optionally, the ones that are paired but currently offline. Pick a target device (for example, your headphones) and the node pre-chews the answer into a plain `true`/`false` you can wire straight into a Condition: “AirPods connected → is → true”.

## How it works

- A “scan” is not a radio sweep for strangers. It is one synchronous read of macOS's connection and pairing table — the same source the System Event Bluetooth trigger watches. That is what keeps it fast and reliable.
- There is no proximity or signal-strength reading. Presence means connected (or paired-offline when you turn that on), not “how close.”
- The headline output is `targetDeviceConnected`. Because a boolean serializes to the string `"true"`, you can compare it in a Condition with no extra steps.

## Target matching

When you pick a specific device, the node matches it against the scan by the device name first (so the match survives address randomization), then falls back to the remembered address (so the match survives a rename).

## Outlets

- Done fires once with the rollup — the booleans, the device count, and a comma-joined `deviceNames` list.
- Each Device fans out, running everything downstream once per device found, with that device's details on the payload.

## Permissions

- The first time a flow uses this node (or the Bluetooth trigger), macOS asks for Bluetooth access.
- If access is denied, the node does not throw — it emits `status: "permission_denied"` with `found: false` so your flow can branch on it.
- A Mac with no devices (or Bluetooth turned off) reads as `status: "empty"`.

## Ports

Direction | Name | Data Type | Description
--- | --- | --- | ---
Input | Input | Any | Incoming payload (passed through, with the scan results merged in)
Output | Done | Any | Fires once with the rollup scalars and the per-device array
Output | Each Device | Any | Fans out, running downstream once per device found

## Configuration

Field | Type | Default | Description
--- | --- | --- | ---
target | Dropdown | `anything` | Anything nearby just reports the device list. A specific device… reveals a device picker and sets the `targetDevice*` outputs.
device | Device Picker | — | Opens a live “Choose a Device” sheet (connected devices pinned first). The picker always lists every device your Mac is paired with — including ones that are currently off — so you can target a device even when it isn't connected; the `includePairedOffline` toggle below only affects what the node reports at run time. Stored as the chosen device's name and remembered address.
includePairedOffline | Boolean | `false` | When off, only currently-connected devices are reported. Turn it on to also include devices that are paired but not connected.

## Output Variables

On the Done outlet:

Variable | Type | Description
--- | --- | ---
targetDeviceConnected | Boolean | The headline check — `true` if your chosen target device is connected right now. Wire it into a Condition as “is true”.
targetDevicePresent | Boolean | `true` if your target is in the scan (connected, or paired-offline when that toggle is on)
targetDeviceName | String | Name of the matched target device, or empty if none matched
deviceCount | Number | How many devices the scan found
deviceNames | String | Comma-joined device names, connected first then alphabetical
found | Boolean | `true` if the scan found at least one device
status | String | `ok`, `empty`, or `permission_denied`
summary | String | A one-line plain-English summary of the scan
devices | Array | Per-device details (name, address, kind, transport, connected)

On each Each Device iteration:

Variable | Type | Description
--- | --- | ---
deviceName | String | This device's name
deviceAddress | String | This device's MAC address
deviceKind | String | Derived kind: headphones, audio, keyboard, mouse, gamepad, phone, computer, or unknown
connected | Boolean | Whether this device is connected right now
index | Number | This device's 0-based position in the scan

## Example

Pause music only when your headphones are not connected: