> For the complete documentation index, see [llms.txt](https://wiki.inels.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.inels.com/inels-bus/3rd-party-integration/mqtt-payload-description-of-inels-bus-devices/mqtt-payload-manual-for-bits-and-integers.md).

# MQTT Payload Manual for Bits and Integers

This manual provides guidance on the payload structure and commands for working with bits and integers in MQTT (Message Queuing Telemetry Transport). Bits and integers represent binary states and numerical values respectively in an iNELS environment.

### Topics and Payload Format

#### Status Topic

The status topic is used to retrieve the current state of bits and integers.

**Topic Structure:**

```
inels/status/<mac_ID>/bits/<topic_ID>
inels/status/<mac_ID>/integers/<topic_ID>
```

**Payload Format:**

```
{
    "last_seen": "<timestamp>",
    "state": {
        "<ID_1>": <value_1>,
        "<ID_2>": <value_2>,
        ...
        "<ID_n>": <value_n>
    }
}
```

* `<timestamp>`: Time when the status was last updated.
* `<ID>`: Unique identifier for the bit or integer.
* `<value>`: Binary state (for bits) or numerical value (for integers).

#### Set Topic

The set topic is used to send commands to control bits and integers.

**Topic Structure:**

```
inels/set/<mac_ID>/bits/<topic_ID>
inels/set/<mac_ID>/integers/<topic_ID>
```

**Command Format:**

```
{
    "cmd": {
        "<ID_1>": "<command_1>",
        "<ID_2>": "<command_2>",
        ...
        "<ID_n>": "<command_n>"
    }
}
```

* `<ID>`: Unique identifier for the bit or integer.
* `<command>`: Action to be performed on the corresponding bit or integer.

### Commands

#### For Bits

* `0`: Turn off the bit.
* `1`: Turn on the bit.
* `toggle`: Toggle the current state of the bit.

#### For Integers

* Set a specific value for the integer.

### Limitations

* Maximum 40 bits or 20 integers can be included in one topic.
* If there are more bits or integers, they will be displayed in additional topics.

### Example

#### Status Topic Payload (Bits)

**Topic:** `inels/status/2C6A6F104825/bits/000001`

**Payload:**

```json
{
    "last_seen": "2024-03-15T13:02:07.+0100Z",
    "state": {
        "000": 1,
        "001": 0,
        "002": 0,
        ...
        "040": 0
    }
}
```

#### Set Topic Command (Bits)

**Topic:** `inels/set/2C6A6F104825/bits/000001`

**Command:**

```json
{
    "cmd": {
        "005": "toggle"
    }
}
```

#### Status Topic Payload (Integers)

**Topic:** `inels/status/2C6A6F104825/integers/000001`

**Payload:**

```json
{
    "last_seen": "2024-03-15T13:11:33.+0100Z",
    "state": {
        "000": 2556,
        "001": 0,
        "002": 97,
        ...
        "020": 0
    }
}
```

#### Set Topic Command (Integers)

**Topic:** `inels/set/2C6A6F104825/integers/000001`

**Command:**

```json
{
    "cmd": {
        "002": 97
    }
}
```

### Conclusion

This manual provides a clear understanding of the payload structure and commands for interacting with bits and integers over MQTT. It facilitates efficient communication and control in IoT applications.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://wiki.inels.com/inels-bus/3rd-party-integration/mqtt-payload-description-of-inels-bus-devices/mqtt-payload-manual-for-bits-and-integers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
