http request via Generic HTTP to Homematic - detailed log?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
spitzlbergerj
Normal user
Posts: 11
Joined: 29 Oct 2022, 09:22
Location: Germany - Bavaria
Contact:

http request via Generic HTTP to Homematic - detailed log?

#1 Post by spitzlbergerj » 31 Oct 2022, 14:27

Hi,
I am trying to send a request to my Homematic via the controller type Generic HTTP.
ESPEasy-Generic-HTTP.png
ESPEasy-Generic-HTTP.png (14.76 KiB) Viewed 2330 times
The controller publish currently says

Code: Select all

egal.exe?ret=dom.GetObject(%27StromCounter1TotalAkt%27).State(%27%val2%27) 
The device is defined like this
ESPEasy-Device.png
ESPEasy-Device.png (27.65 KiB) Viewed 2330 times
In the future I would like to replace the name of the Homematic system variable with

Code: Select all

%tskname%%vname2%Akt
. But first it would have to work ... :-)

If I send via browser the request

Code: Select all

http://192.168.178.160:8181/egal.exe?ret=dom.GetObject('StromCounter1TotalAkt').State(1234)
then this is acknowledged with an OK and the new value is in the system variable at Homematic

However, if the controller sends the request, I get an HTTP Error 400. Unfortunately, there is nothing in the log on the Homematic.

The ESPeasy Weblog says:

Code: Select all

90589101: EVENT: CurrentCounter1#Total=12432
90589112: ACT : let,1,12432/100
90589149: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589159: EVENT: CurrentCounter1#Time=158
90589168: ACT : let,1,12432/100
90589208: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589216: EVENT: http#192.168.178.160=400
90589255: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589264: EVENT: http#192.168.178.160=400
90589299: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589308: EVENT: http#192.168.178.160=400
90589348: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589356: EVENT: http#192.168.178.160=400
90589393: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589432: EVENT: http#192.168.178.160=400
90589468: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589478: EVENT: http#192.168.178.160=400
90589519: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589525: EVENT: http#192.168.178.160=400
90589530: EVENT: http#192.168.178.160=400
90589568: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589576: EVENT: http#192.168.178.160=400
90589616: HTTP : C008 192.168.178.160 GET... failed HTTP code: 400 
90589624: EVENT: http#192.168.178.160=400
90589631: EVENT: http#192.168.178.160=400
I am a bit irritated because these messages come very often. These 400 errors also come without the EVENT StromCounter1#*.
If I understood correctly, then after an event exactly one entry should follow .....
I still don't understand the function of IDX when specifying that the controller should be called. Does this play a role here?

But to find the error, I would need the complete http request, which is sent to the Homematic.
I have already tried all possible log levels, but unfortunately I haven't found one where the request is output completely.

How could I get the request?

Thanks a lot
Sepp

by the way: is there a way to limit uploaded images in display size within the text in bbcode?
Interested layman ... ;)

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#2 Post by TD-er » 31 Oct 2022, 14:44

The IDX is just an integer value you can use to send along the data to the controller to help distinguish what origin the data has.
It is mainly used/introduced by Domoticz, which needs an IDX value to know how to interpret the data and its origin as in Domoticz you have to add a (virtual) device first, which then gets an IDX value assigned. By sending your data along with this IDX, Domoticz knows it is data belonging to a certain (virtual) device it has defined.

Now back to the controller issues you're seeing.
The data sent via a controller is put into a queue.
In the controller settings you can configure how this queue is being used.
For example, you set the queue size, but also whether or not to check the return code from the server on the other side and how many retries each sample must be retried.
It also has some fields to set a timeout and the minimal send interval.

Not sure why your host does reply with a 400 error code, which is "Bad Request".
This often indicates something like a syntax error or incomplete URL/request.
But maybe you're sending them too frequently? In your logs you can see it is retried at an interval of about 40-ish msec.
Could it be that your server is still processing the previous call when you're sending the next one? In your screenshot it looks like you've set the controller to ignore the acknowledgement.

So my first suggestion would be to switch the "ignore acknowledgement" to waiting for the ack.
Also increase the minimal send interval to see if that's making a difference.

spitzlbergerj
Normal user
Posts: 11
Joined: 29 Oct 2022, 09:22
Location: Germany - Bavaria
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#3 Post by spitzlbergerj » 31 Oct 2022, 15:16

Thank you for the super fast reply.

I should perhaps have added that I have successfully created such an http request on another ESPeasy. Is exactly the same structure, only with a different system variable on the Homematic.

I have implemented your tips (unfortunately all values changed at the same time :roll: ) and then the request worked. Then I wanted to know which change brought success. I have piece by piece everything changed back to the old values. The request still works, although everything is as before, when it did not work ....

I am perplexed - but also happy. It works.

Thanks again for the help!
Interested layman ... ;)

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#4 Post by TD-er » 31 Oct 2022, 15:30

Possibly the server was kind of "grey listing" your node as it flooded the server with requests.

Also you may want to increase the timeout in the controller settings to something like 500 msec.
I have recently made this timeout a bit more dynamic, so it will internally use the "average" over the last N requests and multiply that by 3 to set some more dynamic timeout.
However, it still needs to perform the initial one to even get to compute an average.

I think I will increase at least the default timeout (which is used for newly added controller settings) as it may be a bit too tight when using WiFi.
Especially when the interval of sending data via WiFi is relatively low, then the first packet may need more than 100 msec to get a reply.

Anyway, I think the "ignore ack" may have been your main issue here, along with this timeout.
This may trigger the conditions which will then cause the server to "feel" being flooded with requests.

spitzlbergerj
Normal user
Posts: 11
Joined: 29 Oct 2022, 09:22
Location: Germany - Bavaria
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#5 Post by spitzlbergerj » 31 Oct 2022, 16:00

Thanks! And yes I'll increase the timeout to a higher value,
Interested layman ... ;)

spitzlbergerj
Normal user
Posts: 11
Joined: 29 Oct 2022, 09:22
Location: Germany - Bavaria
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#6 Post by spitzlbergerj » 01 Nov 2022, 08:52

Hi @TD-er,

I have one more question. What is the difference between a Controller Generic HTTP and a SendToHTTP inside the Rules?

I have now within the Rules e.g. the following SendToHTTP which seem to work fine. In particular I can use the internal variables

Code: Select all

// -------------------------------------------------------
// Upload der Divisoren zur Homematic
// -------------------------------------------------------
//
On WiFi#Connected do
  SendToHTTP 192.168.178.160,8181,/egal.exe?ret=dom.GetObject(%22StromCounter1Divisor%22).State([var#11])
  SendToHTTP 192.168.178.160,8181,/egal.exe?ret=dom.GetObject(%22StromCounter2Divisor%22).State([var#12])
  SendToHTTP 192.168.178.160,8181,/egal.exe?ret=dom.GetObject(%22StromCounter3Divisor%22).State([var#13])
endon

// -------------------------------------------------------
// aktuelles Total geteilt durch Pulse pro kWh = Zählerstand
// -------------------------------------------------------
//
on StromCounter1#* do
  let,1,%eventvalue2%/[var#11]
  SendToHTTP 192.168.178.160,8181,/egal.exe?ret=dom.GetObject(%22StromCounter1TotalAkt%22).State(%eventvalue2%)
  SendToHTTP 192.168.178.160,8181,/egal.exe?ret=dom.GetObject(%22StromCounter1Stand%22).State([var#1])
endon
Thanks a lot
Sepp
Interested layman ... ;)

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: http request via Generic HTTP to Homematic - detailed log?

#7 Post by TD-er » 01 Nov 2022, 13:09

A controller is called from a task.
A task does have task name and task value names.
These can be used when formatting things in the controller, like the taskname or value name.
Also a controller sends data to a queue, so when failed it can retry sending (based on controller settings).

The SendToHTTP command can be called from rules.
You can also trigger sending via a controller from the rules, using a work-around.

A task will be executed internally by calling the PLUGIN_READ function (in the C++ code). When successful, it will hand over the values to the connected controller(s).
This is typically called every "Interval" nr of seconds (the Interval setting at the bottom of each task page).
But you can also call PLUGIN_READ from the rules by "running" a task via the command "TaskRun".
This is why there is a dummy plugin.
You could for example set values into a dummy task via TaskValueSet. Since a task can hold upto 4 values, you can set upto 4 values in this dummy and then call TaskRun.
There is also a shortcut command: "TaskValueSetAndRun"

Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests