---
sidebar_position: 0
---

# deviceInfo

The `sos.deviceInfo` API groups together methods for retrieving information about the device set in the CloudControl, such as location or
tags.

## Methods

### getDeviceName()

The `getDeviceName()` method returns a name of the device. Name is requested from server on application start, automatically
updated when changed and persisted in local storage.

:::note
Device name can be set only in CloudControl on Device Info page, or via [Rest API](https://developers.signageos.io/api/#tag/Device/paths/~1v2~1device~1%7BdeviceUid%7D/get).
:::

```ts expandable
getDeviceName(): Promise<string | null>;
```

#### Return value

A promise that resolves to the device name.

#### Example

```ts
const deviceName = await sos.deviceInfo.getDeviceName();
console.log(`Device name is: ${deviceName}`);
```

<Separator />

### getDeviceTags()

The `getDeviceTags()` method returns all organization tags assigned to the device including parent tags, if available.
Tags are requested from server on application start, automatically updated when changed and persisted in local storage.

:::note
Tags can be set only in CloudControl on Device Info page, or via [Rest API](https://developers.signageos.io/api/#tag/DeviceTag-(Device-Tags)).
:::

```ts expandable
getDeviceTags(): Promise<IDeviceTag[]>;
// show-more
/**
 * Represents a device tag which may have a parent (organization) tag.
 */
interface IDeviceTag extends ITag {
    parentTag?: ITag;
}

/**
 * Represents organization tags assigned to a device.
 */
interface ITag {
    name: string;
}

```

#### Return value

A promise that returns the device tags.

<Separator />

### getLocation()

The `getLocation()` method returns location of the device with child tags if available. Location is requested from server on application start, automatically
updated when changed and persisted in local storage.

:::note
Location can be set only in CloudControl on Device Info page, or via [Rest API](https://developers.signageos.io/api/#tag/DeviceLocation/paths/~1v1~1device~1%7BdeviceUid%7D~1location~1%7BlocationUid%7D/get).
:::

```ts expandable
getLocation(): Promise<IDeviceLocation | null>;
// show-more
/**
 * Represents device location information set via Rest API.
 */
interface IDeviceLocation {
    /** Name of the location. */
    name: string;
    /** Optional custom identifier for the location. */
    customId?: string;
    /** Optional description of the location. */
    description?: string;
    /** Optional child array of tags associated with the location. */
    tags?: ITag[];
}

/**
 * Represents organization tags assigned to a device.
 */
interface ITag {
    name: string;
}

```

#### Return value

A promise that resolves to the device location or `null` if not set.

<Separator />

### ~getOrganizationTags()~

:::danger Deprecated

This method was deprecated. Please use `getDeviceTags()` method instead.

:::

```ts expandable
getOrganizationTags(): Promise<IOrganizationTag[]>;
// show-more
/** @deprecated */
interface IOrganizationTag {
    name: string;
}

```

## API Example

```ts
import { sos } from '@signageos/front-applet';

void sos.onReady(async () => {
	await printLocation();
	await printTags();
});

const printLocation = async () => {
	const { name, customId, description } = (await sos.deviceInfo.getLocation()) ?? {};
	console.log('Location: ', { name, customId, description });
};

const printTags = async () => {
	const tags = await sos.deviceInfo.getDeviceTags();
	for (const { name, parentTag } of tags) {
		console.log('Tag: ', name);
		if (parentTag) {
			console.log(' Parent Tag: ', parentTag.name);
		}
	}
};

```