Make payload for MQTT more readable.
This commit is contained in:
parent
8d8461f471
commit
83c94a9755
@ -52,13 +52,13 @@ export default function Settings() {
|
|||||||
|
|
||||||
const handleTest = (e) => {
|
const handleTest = (e) => {
|
||||||
var payload = "";
|
var payload = "";
|
||||||
if (selectedType === "Vegetables") {payload = JSON.stringify(payloadVegi);}
|
if (selectedType === "Vegetables") {payload = JSON.stringify(payloadVegi.data.soilMoisture);}
|
||||||
if (selectedType === "Cacti") {payload = JSON.stringify(payloadCacti);}
|
if (selectedType === "Cacti") {payload = JSON.stringify(payloadCacti.data.soilMoisture);}
|
||||||
if (selectedType === "Flowers") {payload = JSON.stringify(payloadFlower);}
|
if (selectedType === "Flowers") {payload = JSON.stringify(payloadFlower.data.soilMoisture);}
|
||||||
|
|
||||||
if ((payload === "") || (selectedEspName === undefined) || (selectedType === undefined)) {alert("No device or type selected!");} else {
|
if ((payload === "") || (selectedEspName === undefined) || (selectedType === undefined)) {alert("No device or type selected!");} else {
|
||||||
Meteor.call('mqttPublish', {
|
Meteor.call('mqttPublish', {
|
||||||
topic: 'smartgarden/commands/' + selectedEspName,
|
topic: 'smartgarden/commands/' + selectedEspName + '/soil',
|
||||||
payload: payload
|
payload: payload
|
||||||
}, (err, res) => {
|
}, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user