Publish state as number and string
This commit is contained in:
		| @@ -211,9 +211,14 @@ void Plant::deactivatePump(void) | |||||||
|  |  | ||||||
| void Plant::publishState(int stateNumber, String stateString) | void Plant::publishState(int stateNumber, String stateString) | ||||||
| { | { | ||||||
|  |     String buffer; | ||||||
|  |     StaticJsonDocument<200> doc; | ||||||
|     if (this->mConnected) |     if (this->mConnected) | ||||||
|     { |     { | ||||||
|         this->mPlant->setProperty("state").send(stateString); |         doc["number"] = stateNumber; | ||||||
|  |         doc["message"] = stateString; | ||||||
|  |         serializeJson(doc, buffer); | ||||||
|  |         this->mPlant->setProperty("state").send(buffer.c_str()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user