Aypac / Arduino-TR-064-SOAP-Library

Arduino library for the TR-064 protocol, most commonly used by the Fritz!Box router API
Other
63 stars 21 forks source link

URL is empty, abort http request #67

Open lifeofbda opened 1 year ago

lifeofbda commented 1 year ago

Hi,

I tried to do the example where i grab the data of a smart plug. Wifi connection works and I can see the ESP32 in the fritzbox Interface connected to the wifi.

But when I want to grab the data with:

String paramsb[][2] = { { "NewAIN", AIN } }; String reqb[][2] = {{ "NewMultimeterPower", "" }}; connection.action("urn:dslforum-org:service:X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", paramsb, 1, reqb, 2);

I get this error:

21:43:37.380 -> [TR064][action] with extraction 21:43:37.381 -> [TR064][cleanOldServiceName] searching for prefix in servicename: urn:dslforum-org:service:X_AVM-DE_Homeauto:1 21:43:37.412 -> [TR064][action_raw] with parameter, NewAIN 21:43:37.412 -> [TR064][action_raw] with parametervalue, 11657 0551398 21:43:37.412 -> [TR064][findServiceURL] Services NOT Loaded. 21:43:37.412 -> [TR064][httpRequest] URL is empty, abort http request. 21:43:37.412 -> [TR064][action] Request Failed

I've already tried different user, etc...

Best, Ben

saak2820 commented 1 year ago

Not a bug.

Services NOT Loaded.

You have to use the init() method or provide a url.

Please see the examples.

lifeofbda commented 1 year ago

I tried to be 100% like the examples... I use the init method in my setup:

`#include

include

include

WiFiMulti WiFiMulti;

include

include

define LED_PIN 26

define LED_COUNT 1

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//------------------------------------------------------------------------------------- // Put your router settings here //------------------------------------------------------------------------------------- // Wifi network name (SSID) const char wifi_ssid = "FRITZ!Box 7530 EC"; // Wifi network password const char wifi_password = "passwort"; // The username if you created an account, "admin" otherwise const char fuser = "esp32"; // The password for the aforementioned account. const char fpass = "passwort"; // IP address of your router. This should be "192.168.179.1" for most FRITZ!Boxes const char* IP = "192.168.179.1"; // Port of the API of your router. This should be 49000 for all TR-064 devices. const int PORT = 49000; // -------------------------------------------------------------------------------------

// TR-064 connection TR064 connection(PORT, IP, fuser, fpass);

// Die AIN der DECT!200 Steckdose findet sich im FritzBox Webinterface const String Steckdose1 = "11657 0551398";

void setup() { Serial.begin(115200); Serial.println("boot...");

// Connect to wifi ensureWIFIConnection(); Serial.println("WIFI connected...");

if(Serial) Serial.printf("Initialize TR-064 connection\n\n"); connection.init(); // Bei Problemen kann hier die Debug Ausgabe aktiviert werden connection.debug_level = ESP_LOG_VERBOSE;

strip.begin(); strip.show(); // Turn off all pixels initially }

void loop() { GetDeviceInfo(Steckdose1); delay(2000); }

void GetDeviceInfo(String AIN) { ensureWIFIConnection();

String params[][2] = {{"NewAIN", AIN}}; String req[][2] = {{"NewMultimeterPower", ""}};

connection.action("X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", params, 1, req, 1);

float power = (float)((req[0][1]).toInt()) / 100.0; Serial.print("Stromverbrauch: "); Serial.print(power, 1); Serial.println("W");

if (power > 100) { // If value is less than 1/3 of max // Set pixel to green strip.setPixelColor(0, strip.Color(255, 0, 0)); } else if (power >= 100 && power > 150) { // If value is less than 2/3 of max // Set pixel to yellow strip.setPixelColor(0, strip.Color(255, 255, 0)); } else { // Otherwise, set pixel to red strip.setPixelColor(0, strip.Color(0, 255, 0)); }

strip.show(); // Update the LED with the new color delay(10); // Small delay for stability }

void ensureWIFIConnection() { if ((WiFiMulti.run() != WL_CONNECTED)) { WiFiMulti.addAP(wifi_ssid, wifi_password); while ((WiFiMulti.run() != WL_CONNECTED)) { delay(100); } } }`