---
# System prepended metadata

title: CHT City OS Integration - MQTT
tags: [cht, adyawinsa, mqtt]

---

# MQTT CONNECTION
IP/host	: by WA
PORT	: by WA
Username	: by WA 
Password    : by WA


# MQTT TOPIC
`device_id`   : `36828155029`

## - publish topic: 
`/v1/device/[device_id]/rawdata`

## - subscribe topic untuk command lampu:
`/v1/device/[device_id]/sensor/setBrightnessPercent/rawdata`

## - subscribe topic (format): 
`/v1/device/[device_id]/sensor/(json[index].id)/rawdata`

## - list subscribe topic
`/v1/device/[device_id]/sensor/temp/rawdata`
`/v1/device/[device_id]/sensor/lum/rawdata`
`/v1/device/[device_id]/sensor/brightness/rawdata`
`/v1/device/[device_id]/sensor/voltage/rawdata`
`/v1/device/[device_id]/sensor/current/rawdata`
`/v1/device/[device_id]/sensor/setBrightnessPercent/rawdata`
`/v1/device/[device_id]/sensor/lpwanMode/rawdata`

# FORMAT & VALUE OF MQTT PUBLISH
``` json
[
    {
        "id": "temp",
        "value": [
            "36.375"
        ]
    },
    {
        "id": "lpwanMode",
        "value": [
            "NBIoT"
        ]
    },
    {
        "id": "brightnessPercent",
        "value": [
            "0"
        ]
    },
    {
        "id": "firmware",
        "value": [
            "20200207v1"
        ]
    },
    {
        "id": "current",
        "value": [
            "4.025"
        ]
    },
    {
        "id": "voltage",
        "value": [
            "0.172"
        ]
    },
    {
        "id": "lum",
        "value": [
            "0.000"
        ]
    },
]
```

# MQTT TESTING

for testing. you can subscribe topic by yourself. when you publish the data  you will also receive data from your subscribe topic.

Test publish:
``` json
[
    {
        "id": "setBrightnessPercent",
        "value": [
            "36.375"
        ]
    }
]
```
# MQTT SUBSCRIBE FORMAT
*Topic Subscribe lampu untuk setting brightness*
`/v1/device/[device_id]/sensor/setBrightnessPercent/rawdata`

*Format Data*
```json
{
	"id"		:"setBrightnessPercent",
	"deviceId"	:"36828155029",
	"time"		:"2024-01-03T07:44:35.372Z",
	"value"		:[
		"75.54"
	]
}
```

# DASHBOARD ACCESS
belum ada
