
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);
}
