Make payload for MQTT more readable.

This commit is contained in:
Andrés Uribe Stengel 2020-07-17 15:16:25 +02:00
parent 8d8461f471
commit 83c94a9755

View File

@ -52,13 +52,13 @@ export default function Settings() {
const handleTest = (e) => {
var payload = "";
if (selectedType === "Vegetables") {payload = JSON.stringify(payloadVegi);}
if (selectedType === "Cacti") {payload = JSON.stringify(payloadCacti);}
if (selectedType === "Flowers") {payload = JSON.stringify(payloadFlower);}
if (selectedType === "Vegetables") {payload = JSON.stringify(payloadVegi.data.soilMoisture);}
if (selectedType === "Cacti") {payload = JSON.stringify(payloadCacti.data.soilMoisture);}
if (selectedType === "Flowers") {payload = JSON.stringify(payloadFlower.data.soilMoisture);}
if ((payload === "") || (selectedEspName === undefined) || (selectedType === undefined)) {alert("No device or type selected!");} else {
Meteor.call('mqttPublish', {
topic: 'smartgarden/commands/' + selectedEspName,
topic: 'smartgarden/commands/' + selectedEspName + '/soil',
payload: payload
}, (err, res) => {
if (err) {