Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Device

Who and what the bound device is: its identity, status, image and tags. Every call targets the device the widget is bound to — JavaScript can't pass a device ID.

Get device info

Returns the bound device's ID, organization, name, status, last activity and image.

bridge.getDeviceInfo()  // → Promise<DeviceInfo>

Parameters: none.

Resolves with

{
  id:             number | null,   // device ID; null when no device is bound
  orgId:          number | null,   // organization ID
  name:           string,          // device display name; '' when no device is bound
  status:         string,          // 'ONLINE' | 'OFFLINE' | a custom status | ''
  lastReportedAt: number | null,   // Unix ms of the last server activity
  image:          string | null    // absolute http(s) URL of the device image — see "Device image"
}
  • The call always resolves with an object, also when no device is linked. Guard on info.id, not on info itself.

  • status is a flat string — there is no nested status object. Compare case-insensitively: info.status.toUpperCase() === 'ONLINE'.

  • There is no callback for device-info changes. Call getDeviceInfo() again when you need fresh status.

Rejects with request_timeout (web, after 10 seconds — Device info request timeout (10s)), server_error, device_unavailable, bridge_destroyed.

Example


Device image

The device's photo comes with the device info — no separate call.

getDeviceInfo().image is an absolute http(s) URL of the device image, or null when the device has none.

  • Set it as an <img> src from JavaScript. It's a URL the host hands you, so it works on every host, including the sandboxed web iframe.

  • While the image loads, when image is null, and on an error event, show a neutral placeholder in the same box — the device name's initial, for example — never a broken-image icon.

  • Don't hardcode or cache the URL across sessions: read it from getDeviceInfo() every time the widget loads.

  • The image is read-only for a widget — the bridge has no method to change it. Files stored on the device are a separate thing; see Device Files & Assets.

  • The URL is cross-origin, so don't draw it to a <canvas> and read pixels back.

Example


Get device tags

Returns the tags assigned to the bound device.

Parameters: none.

Resolves with an array of tags, [] when the device has none:

Rejects with

Code
When

too_many_requests

50 tag requests from this widget are already pending

request_timeout

No result within 30 seconds (Device tags request timeout (30s))

server_error

The host failed without a specific code

device_unavailable

Called outside a Blynk host

bridge_destroyed

Called after destroy()

Permission: VIEW_DEVICE_TAGS. Feature-detect the method — an older host can lack it.

Example

Was this helpful?