ESP8266 does not upate Air Quality device
Posted: Saturday 15 April 2023 1:39
Hi all,
I made a virtual Air Quality device with index 120. I try to update it with a value from an ESP8266 but it does not update the device. I don't even know what Domoticz does with the data at all...
The ESP8266 gets IP number 192.168.1.158 when connected. On the security page I enabled 'Allow Basic-Auth authentication over plain HTTP (API only)' and set '192.168.1.*' as a trusted network. I also tried with a text device but that doesn't work also.
What am I missing?
Peter
I made a virtual Air Quality device with index 120. I try to update it with a value from an ESP8266 but it does not update the device. I don't even know what Domoticz does with the data at all...
Code: Select all
#include <ESP8266WiFi.h>
#include "Types.h"
//=============================================================================
// SSID
const char* ssid = "*******************";
// wifi-password
const char* password = "************";
// Domoticz-server
const char* dzAddress = "192.168.1.162";
const int dzPort = 8080;
// index of sensor
const int dzIdx = 120;
//=============================================================================
WiFiClient client;
long lastMsg = 0;
void setup() {
// Wifi instellen
WiFi.mode(WIFI_STA);
delay(10);
WiFi.hostname("Vindriktning");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
void loop() {
long now = millis();
if ((now - lastMsg > 10000) or (now < lastMsg)) {
lastMsg = now;
if (client.connect(dzAddress, dzPort)) {
client.print(String("GET "));
client.print("/json.htm?type=command¶m=udevice&idx=120&nvalue=220");
client.println(" HTTP/1.1");
client.print("Host: ");
client.print(dzAddress);
client.print(":");
client.println(dzPort);
client.println("User-Agent: Arduino-ethernet");
client.println("Connection: close");
client.println();
client.stop();
}
}
}
What am I missing?
Peter