---
name: "useProtocolRun"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.8.0" }
title: "useProtocolRun"
---

## useProtocolRun

> [VERSION] @ray-js/panel-sdk >= 1.8.0

> 💡 This Hook automatically determines the communication protocol type (Zigbee, SIG Mesh, Wi-Fi, etc.) from the device information and executes the corresponding callback.
> Device info is cached and not requested again after the first fetch.

### Description

Execute the corresponding callback based on the device communication protocol type

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `props` | `Props` | Yes | A configuration object containing devId and callbacks for each protocol type |
| `deps` | `any` | No | Optional dependencies; changes will regenerate the executor function |

### Return Value

None


### Referenced Types

##### `type` Props

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `zigbee` | `() => void` | Callback executed for Zigbee devices |
| `sigMesh` | `() => void` | Callback executed for SIG Mesh devices |
| `sigMeshGateway` | `() => void` | Callback executed when a SIG Mesh device is connected via a gateway |
| `wifi` | `() => void` | Callback executed for Wi‑Fi devices |
| `ble` | `() => void` | Callback executed for Bluetooth devices |
| `group` | `() => void` | Callback executed for group devices |
| `default` | `() => void` | Fallback callback executed when no protocol type matches |
| `deps` | `any` | Optional dependencies; changes will regenerate the executor function |


### Examples

#### Example

```tsx
import { useProtocolRun } from '@ray-js/panel-sdk';

function ProtocolHandler() {
  const run = useProtocolRun({
    devId: 'device123',
    wifi: () => console.log('Wi-Fi device'),
    zigbee: () => console.log('Zigbee device'),
    sigMesh: () => console.log('SIG Mesh device'),
    default: () => console.log('Other protocols'),
  });

  useEffect(() => {
    run();
  }, [run]);
}
```
