feat: make PowerOn a plain GET request without auth and add custom trigger app launcher icon

This commit is contained in:
2026-11-18 13:36:14 +05:30
parent 378bf291f2
commit 48dabc50a8
13 changed files with 33 additions and 19 deletions
+2 -2
View File
@@ -6,9 +6,9 @@
<application
android:allowBackup="true"
android:icon="@android:drawable/sym_def_app_icon"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@android:drawable/sym_def_app_icon"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ExpApp">
<activity
@@ -23,21 +23,34 @@ class TriggerClient(
private val jsonMediaType = "application/json; charset=utf-8".toMediaType()
fun buildRequest(device: DeviceConfig, action: TriggerAction): Request {
val targetUrl = when (action) {
TriggerAction.POWER_ON -> device.powerOnUrl
TriggerAction.POWER_OFF -> device.powerOffUrl
TriggerAction.REBOOT -> device.rebootUrl
return when (action) {
TriggerAction.POWER_ON -> {
Request.Builder()
.url(device.powerOnUrl)
.get()
.build()
}
TriggerAction.POWER_OFF -> {
val jsonPayload = """{"node":"${device.node}"}"""
val body = jsonPayload.toRequestBody(jsonMediaType)
Request.Builder()
.url(device.powerOffUrl)
.addHeader("Content-Type", "application/json")
.addHeader("X-Secret-Key", device.secretKey)
.post(body)
.build()
}
TriggerAction.REBOOT -> {
val jsonPayload = """{"node":"${device.node}"}"""
val body = jsonPayload.toRequestBody(jsonMediaType)
Request.Builder()
.url(device.rebootUrl)
.addHeader("Content-Type", "application/json")
.addHeader("X-Secret-Key", device.secretKey)
.post(body)
.build()
}
}
val jsonPayload = """{"node":"${device.node}"}"""
val body = jsonPayload.toRequestBody(jsonMediaType)
return Request.Builder()
.url(targetUrl)
.addHeader("Content-Type", "application/json")
.addHeader("X-Secret-Key", device.secretKey)
.post(body)
.build()
}
fun sendTrigger(
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB