Skip to content

Commit

Permalink
Added options for mqtt HA discovery and device topic
Browse files Browse the repository at this point in the history
  • Loading branch information
foorschtbar committed Nov 12, 2023
1 parent 934f246 commit 0ead2b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions public/demoData/demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"matrixType": 4,
"note": "This is demo data",
"hostname": "PixelIt-Demo",
"deviceID": "PixelIt-123456789",
"matrixTempCorrection": "default",
"ntpServer": "0.pool.ntp.org",
"clockTimeZone": 1,
Expand All @@ -67,6 +68,7 @@
"mqttPassword": "",
"mqttServer": "",
"mqttMasterTopic": "Home/PixelIt/",
"mqttUseDeviceTopic": true,
"mqttPort": 1883,
"luxOffset": 0,
"temperatureOffset": 0,
Expand Down
3 changes: 3 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ function getDisplayName(key) {
case 'hostname':
key = 'Hostname';
break;
case 'deviceID':
key = 'Device-ID';
break;
case 'note':
key = 'Note';
break;
Expand Down
13 changes: 12 additions & 1 deletion src/views/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<v-text-field v-model="config.note" label="Note"></v-text-field>
<v-switch v-model="config.bootScreenAktiv" label="Bootscreen active" hide-details dense></v-switch>
<v-switch v-model="config.bootSound" label="Play sound on boot" hide-details dense></v-switch>
<v-switch v-model="config.checkUpdateScreen" label="Check and show new available firmware on the PixelIt " hide-details dense></v-switch>
<v-switch v-model="config.checkUpdateScreen" label="Display on matrix when new firmware is available" hide-details dense></v-switch>
</v-card>
<br />
<v-card class="pa-2" elevation="4">
Expand Down Expand Up @@ -102,6 +102,8 @@
<v-text-field v-model="config.mqttUser" label="User" hint="optional" :disabled="!config.mqttAktiv"></v-text-field>
<v-text-field v-model="config.mqttPassword" label="Password" hint="optional" :disabled="!config.mqttAktiv"></v-text-field>
<v-text-field v-model="config.mqttMasterTopic" label="Master topic" :disabled="!config.mqttAktiv" :rules="config.mqttAktiv ? [rules.required] : []"></v-text-field>
<v-switch v-model="config.mqttUseDeviceTopic" :label="deviceTopicLabel" :disabled="!config.mqttAktiv" dense></v-switch>
<v-switch v-model="config.mqttHAdiscoverable" label="Making the device discoverable by HomeAssistant" :disabled="!config.mqttAktiv" dense></v-switch>
</v-card>
<br />
<v-card class="pa-2" elevation="4">
Expand Down Expand Up @@ -215,6 +217,15 @@ export default {
telemetryData() {
return this.$store.state.telemetryData;
},
deviceTopicLabel() {
let hostname = '';
if (this.$store.state.configData.hostname != '') {
hostname = this.$store.state.configData.hostname.trim();
} else {
hostname = this.$store.state.displayHostname;
}
return 'Use additional device topic (' + this.$store.state.configData.mqttMasterTopic.trim().replace(/\/?$/, '/') + hostname + '/)';
},
},
methods: {
save() {
Expand Down

0 comments on commit 0ead2b2

Please sign in to comment.