Skip to content

Commit 9a0800d

Browse files
committed
refactor: Use full sensor type for topic if no dot is present
1 parent 654cc55 commit 9a0800d

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • data/src/main/java/com/github/umercodez/sensorspot/data/sensorpublisher
  • ui/src/main/java/com/github/umercodez/sensorspot/ui/screens/sensors/components

data/src/main/java/com/github/umercodez/sensorspot/data/sensorpublisher/SensorPublisher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SensorPublisher(
8585

8686
private fun getTopic(mqttConfig: MqttConfig, sensorType: String ) : String {
8787
return if(mqttConfig.dedicatedTopics){
88-
"${mqttConfig.topic}/${sensorType.split('.').last()}"
88+
"${mqttConfig.topic}/${ if (sensorType.contains(".")) sensorType.split('.').last() else sensorType}"
8989
} else {
9090
mqttConfig.topic
9191
}

ui/src/main/java/com/github/umercodez/sensorspot/ui/screens/sensors/components/SensorItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fun SensorItem(
7070
headlineContent = { Text(text = sensor.name) },
7171
supportingContent = {
7272
val subText = if (dedicatedTopics) {
73-
"topic = ${mqttTopic}/${sensor.stringType.split('.').last()}"
73+
"topic = ${mqttTopic}/${ if (sensor.stringType.contains(".")) sensor.stringType.split('.').last() else sensor.stringType}"
7474
} else {
7575
"type = ${sensor.stringType}"
7676
}

0 commit comments

Comments
 (0)