useTelemetry
hook makes it very easy to just listen to telemetry on a single device.string
string
HookOptions
telemetryKey
is received on the device(data: unknown) => void
grantRequestFunction
fails to grant the direct method requestGrantErrorCallback
telemetryKey
this hook will update this value.temperature
telemetry.useMultiTelemetry
hook is a more sophisticated variant of useTelemetry
. It is designed to cover use-cases where a several streams of telemetry of multiple devices need to be subscribed to.HookOptions
Record<string, string[]>
value
for a telemetryKey
is sent by a device with ID deviceId
(deviceId: string, telemetryKey: string, value: unknown) => void
grantRequestFunction
fails to grant the subscription request.GrantErrorCallback
initialSubscribers
object. This object is meant solely as an option for use cases where you always have an initial set of subscribers. Updates to initialSubscribers
will not trigger updates in the hook.Record<string, Record<string, unknown>
deviceId
and telemetryKey
(deviceId: string, telemetryKey: string) => void
deviceId
and multiple telemetryKeys
(deviceId: string, telemetryKeys: string[]) => void
deviceId
and multiple telemetryKeys
(deviceId: string, telemetryKeys: string[]) => void
deviceId
and telemetryKey
exists(deviceId: string, telemetryKey: string) => boolean
deviceId
and value being the telemetryKey names.Record<string, string[]>
useDirectMethod
hook returns a function that, when invoked, calls a direct method on the target device. It returns a Promise that resolves to the direct method result that the device returns (or an error when the direct method could not be executed, e.g. if the device is offline).string
string
HookOptions
grantRequestFunction
fails to grant the direct method requestGrantErrorCallback
(params: Record<string, unknown>) => Promise<IotHubResponse | void>
onGrantError
handler of useDirectMethod
with the catch block of the direct method itself. onGrantError
will only be executed when this hook is rendered by react and the security backend fails to grant the direct method. The error that reboot
may throw is an HTTP error that could occur when the function is executed.useDeviceTwin
hook subscribes to device twin updates.string
HookOptions
(twin: Twin) => void
grantRequestFunction
fails to grant the subscription request.GrantErrorCallback
Twin
Twin
typescript type provided from the azure-iothub library.useConnectionState
hook subscribes to the connection state of a device. This state can change, i.e as soon as a device connects or disconnects.string
HookOptions
(connectionState: boolean) => void
grantRequestFunction
fails to grant the subscription request.GrantErrorCallback
boolean
usePatchDesiredProperties
hook is used to perform desired property updates on devices.string
HookOptions
grantRequestFunction
fails to grant the patch desired properties request.GrantErrorCallback
(desiredProperties: Record<string, unknown>) => Promise<IoTHubResponse | void>
useDeviceTwin
string
HookOptions
(data: Record<string, unknown>) => void
grantRequestFunction
fails to grant the subscription request.GrantErrorCallback
T
unknown
first and are then casted to your type T
. Omitting this generic type will leave the type unknown
.onData
onData
as function in subscription hooks, removes the burden of you needing to decide when to notice value changes.onGrantError
grantRequestFunction
returns. The grantRequestFunction
is something that you need to implement yourself when you want to use ux4iot in production. The purpose of this function is to determine whether you as a user of the react application have the permission to subscribe to telemetry / device twin / connection state or perform a direct method / desired property patch.