Display/Arduino/.svn/pristine/cc/ccad5b7fe1e6f75356d2ac8ebaa3309063aa7d5e.svn-base
Frank c252b506a7 First version
First version
2021-12-29 21:18:39 +01:00

56 lines
1023 B
Plaintext

void domoticz_send_nvalue(int idx, int nvalue)
{
StaticJsonDocument<200> doc;
#ifdef DEBUG
Serial.println("Sending nvalue");
Serial.println(idx);
Serial.println(nvalue);
#endif
// Make our document be an object
JsonObject root = doc.to<JsonObject>();
root["command"] = "switchlight";
root["idx"] = idx;
if (nvalue == 1)
{
root["switchcmd"] = "On";
}
else
{
root["switchcmd"] = "Off";
}
serializeJson(root, msg);
#ifdef DEBUG
Serial.println(msg);
#endif
client.publish("domoticz/in", msg);
}
//Setting page nummer into Domoticz varaiable
void domoticz_set_pagenr(int pagenr)
{
StaticJsonDocument<200> doc;
#ifdef DEBUG
Serial.println("Sending variable pagenr");
Serial.println(pagenr);
#endif
// Make our document be an object
JsonObject root = doc.to<JsonObject>();
root["command"] = "setuservariable";
root["idx"] = 4;
root["value"] = pagenr;
serializeJson(root, msg);
#ifdef DEBUG
Serial.println(msg);
#endif
client.publish("domoticz/in", msg);
}