ESP8266 does not upate Air Quality device

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

ESP8266 does not upate Air Quality device

Post by peterbos »

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...

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&param=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();
    }
  }
}
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
User avatar
waltervl
Posts: 5374
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ESP8266 does not upate Air Quality device

Post by waltervl »

If you send the same api call as an URL in a browser from a system in your network, does it work?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: ESP8266 does not upate Air Quality device

Post by peterbos »

Hi Walter,

If I do an http API call it says the connection is reinitialized. With an https call the secured connection fails with fault PR_END_OF_FILE_ERROR. I did not do exact the same command, but used "http://192.168.1.162:8080/json.htm?type ... &range=day" which should normally work - and did work before I upgraded. This was the first time since the update I tried to use an ESP8266.

Peter
User avatar
waltervl
Posts: 5374
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ESP8266 does not upate Air Quality device

Post by waltervl »

I meant if you send the following api call (as in your esp program) will it update the device?

Code: Select all

http://192.168.1.162:8080/json.htm?type=command&param=udevice&idx=120&nvalue=220
If not you should check the trusted network settings, or check the nvalue if it has the correct range.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5374
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ESP8266 does not upate Air Quality device

Post by waltervl »

Perhaps you need to change your HTTP message in the code from GET to POST...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: ESP8266 does not upate Air Quality device

Post by peterbos »

waltervl wrote: Saturday 15 April 2023 22:52 I meant if you send the following api call (as in your esp program) will it update the device?

Code: Select all

http://192.168.1.162:8080/json.htm?type=command&param=udevice&idx=120&nvalue=220
If not you should check the trusted network settings, or check the nvalue if it has the correct range.
Hi Walter,

That doesn't work but it works if I use port number 443 and https instead of port number 8080 and http. That's weird because I have allowed Basic Authentication over plain HTTP. The ESP8266 has address 192.168.1.158 and the trusted network range is '192.168.1.*;127.0.0.*;localhost'. I do remember in my old setup I also had a IPv6 address in this range but I can't find how to specify that. May that be the problem?

Peter
User avatar
waltervl
Posts: 5374
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ESP8266 does not upate Air Quality device

Post by waltervl »

I think in latest 2023 beta there were some changes to loosen up some security rules. But I have not enough knowledge to understand if it would help in your case.

With the HTTP authorization setting in my opinion it should indeed behave the same has with HTTPS.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 does not upate Air Quality device

Post by jvdz »

peterbos wrote: Sunday 16 April 2023 22:39 That's weird because I have allowed Basic Authentication over plain HTTP.
Don't you require the userid:passord in the url when you need basic authentication?
something like:

Code: Select all

http://userid:[email protected]:8080/json.htm?type=command&param=udevice&idx=120&nvalue=220
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
thomasbaetge
Posts: 153
Joined: Wednesday 02 October 2019 11:47
Target OS: Linux
Domoticz version: 2023.1
Location: DE / BY / LT
Contact:

Re: ESP8266 does not upate Air Quality device

Post by thomasbaetge »

Why not simply use MQTT for this?
The ESP8266 is well capable of that and this way you have a protokoll standard, instead of writing scripts for every device.

I have around 10 ESP devices in my network and they all operate on MQTT. No issues at all.
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: ESP8266 does not upate Air Quality device

Post by peterbos »

I changed to MQTT yesterday. I now have a working Ikea Vindriktning device in Domoticz. But it still annoys me that it doesn't work like it used to ...

Peter
thomasbaetge
Posts: 153
Joined: Wednesday 02 October 2019 11:47
Target OS: Linux
Domoticz version: 2023.1
Location: DE / BY / LT
Contact:

Re: ESP8266 does not upate Air Quality device

Post by thomasbaetge »

Great,

you may still look into your previous issue for sure, but I always find it a good idea, to use standard protocols.
Errorhandling and a possible later migration are so much easier.

I write a lot of different integrations and I never even consider using anything else but MQTT.
User avatar
waltervl
Posts: 5374
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ESP8266 does not upate Air Quality device

Post by waltervl »

waltervl wrote: Monday 17 April 2023 0:47 I think in latest 2023 beta there were some changes to loosen up some security rules. But I have not enough knowledge to understand if it would help in your case.

With the HTTP authorization setting in my opinion it should indeed behave the same has with HTTPS.
Could be fixed in latest beta already with PR https://github.com/domoticz/domoticz/pull/5625
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests