# GROUP\_BY\_DEVICE

### Description

Converts *vector* to a *grouped vector* by grouping by devices. I.e. each device has its own list of events.

### GROUP\_BY\_DEVICE(Vector\<Event>)

```java
GROUP_BY_DEVICE(vector: Vector<Event>): GroupedVector<Device,Event>
```

Groups the events in the given vector by deviceId.

#### Parameters

<table><thead><tr><th width="138">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A vector of type Event</td></tr></tbody></table>

#### Returns

A GroupedVector of type \<Device,Event>.

### Examples

Group the events in the GridPowerConsumption vector by device id.

```java
GROUP_BY_DEVICE($GridPowerConsumption)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.moost.io/platform-manual/rules/rule-language/functions/group_by_device.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
