HTTP Client¶
The HTTP Client page allows you to configure HTTP requests to be sent periodically, as well as HTTP requests for use in the Events feature.
Elements of page¶
The HTTP client configuration form contains fields:
- enabling the function of sending via the GSM module instead of the Ethernet connection
- enable cyclical query sending to first address
- using the double
%
character to insert readings from the device (allows the%
character to be entered) - using Digest Authentication (after attempt with Basic Authentication)
- period of sending a cyclical query
- server addresses or rather URL to query (up to 4), in format
<host>:<port>/<path>
HTTP Client configuration¶
The client sends HTTP requests using the GET method to the specified server and port at a specified time.
The query can include values from the sensors with help of special phrase %xxy
, where: In the query, you can insert values from sensors using a special expression %XXXAB
, where B
is only used in OLED and ignored in the HTTP client. More information on this here.
An example of an HTTP GET query to the thingspeak server, which writes the value from the T1 sensor to the server
In the Server address field enter:
api.thingspeak.com:80/update?api_key=H2PN0O35KRVRG6Q0&field1=%141
As a result, the following text is sent to the server, where you can see the substitution of the sensor value in the indicated place:
update?api_key=H2PN0O35KRVRG6Q0&field1=26.3
The query can also be sent manually from a web browser without LC3 participation by pasting/entering the following text in the search bar:
http://api.thingspeak.com/update?api_key=H2PN0O35KRVRG6Q0&field1=26.3
Full content of the query:
GET /update?api_key=H2PN0O35KRVRG6Q0&field1=26.3 HTTP/1.0
Host: api.thingspeak.com
Connection: close
Sensor numbers¶
Current readings from sensors and selected parameters from the device can be accessed using a special format for: HTTP client queries, displaying on the OLED display, e-mail and SMS texts (since HW3.5+ SW 1.40).
The format for use in the HTTP client is %XXXA
and for OLED it is %XXXAB
(with an additional B parameter). This is the case since version HW3.5+ SW 1.36, for the previous versions it is %XXA
for the HTTP client and %XXAB
for OLED.
%
– a character that begins a special formatXXX
– sensor number, necessarily a three-digit value (list of codes below)-
A
– divisor, range 0-3, allows you to match the decimal point for a specific reading, since values are returned as integers- 0 – do not divide the value
- 1 – divide by 10
- 2 – divide by 100
- 3 – divide by 1000
Different effect of divisor for some readings
For some variables, the divisor of
A
works differently:- UPTIME:
- 0 - value in seconds
- 1 - value in minutes
- 2 - value in hours (before SW 1.44 value in seconds)
- 3 - value in format
dd hh:mm:ss
(before SW 1.44 value in hours)
- Time:
- 0 - hh:mm:ss
- 1 - hhmmss
- Date:
- 0 - yyyy-mm-dd
- 1 - yyyymmdd
Recommended divisor settings
The divisor should take the following values to make the readings in the same format as on the page:
0
for OUT, PWM, INPD, INPA_RAW, CO21
for T1, H1, DS, PM2
for P1, INPA, VCC/VIN, TEMP3
for POWER, ENERGY, DIFF (from HW 3.5+ SW 1.49. Previously, the value of 'A' for DIFF should be either1
,2
or3
, depending on the readings selected in it)
-
B
- cutter, range 0-9, shortens the value by a given number of characters
List of readings codes¶
{
"000": "INPA1",
"001": "INPA2",
"002": "INPA3",
"003": "INPA4",
"004": "INPA5",
"005": "INPA6",
"006": "VCC",
"007": "INPA1_RAW",
"008": "INPA2_RAW",
"009": "INPA3_RAW",
"010": "INPA4_RAW",
"011": "INPA5_RAW",
"012": "INPA6_RAW",
"013": "TEMP",
"014": "T1",
"015": "H1",
"016": "DS1",
"017": "DS2",
"018": "DS3",
"019": "DS4",
"020": "DS5",
"021": "DS6",
"062": "DS7",
"063": "DS8",
"022": "DIFF1",
"023": "DIFF2",
"067": "DIFF3",
"103": "DIFF4", // added in HW 3.5+ SW 1.49
"104": "DIFF5", // added in HW 3.5+ SW 1.49
"105": "DIFF6", // added in HW 3.5+ SW 1.49
"035": "POWER1",
"036": "POWER2",
"037": "POWER3",
"038": "POWER4",
"106": "POWER5", // added in HW 3.5+ SW 1.49
"107": "POWER6", // added in HW 3.5+ SW 1.49
"039": "ENERGY1",
"040": "ENERGY2",
"041": "ENERGY3",
"042": "ENERGY4",
"108": "ENERGY5", // added in HW 3.5+ SW 1.49
"109": "ENERGY6", // added in HW 3.5+ SW 1.49
"043": "OUT0",
"044": "OUT1",
"045": "OUT2",
"046": "OUT3",
"047": "OUT4",
"048": "OUT5",
"049": "PWM0",
"050": "PWM1",
"051": "PWM2",
"052": "PWM3",
"053": "INPD1",
"054": "INPD2",
"055": "INPD3",
"056": "INPD4",
"065": "PM1.0",
"057": "PM2.5",
"066": "PM4.0",
"058": "PM10.0",
"059": "P1",
"060": "CO2/GMQ125", // changed in HW 3.5+ SW 1.49
"061": "UPTIME",
"064": "IP",
"068": "Distance sensor",
"069": "Time",
"070": "Date",
"071": "m1",
"072": "m2",
"073": "m3",
"074": "m4",
"075": "m5",
"076": "m6",
"077": "m7",
"078": "m8",
"079": "m9",
"080": "m10",
"081": "m11",
"082": "m12",
"083": "m13",
"084": "m14",
"085": "m15",
"086": "m16",
"087": "m17",
"088": "m18",
"089": "m19",
"090": "m20",
"091": "m21",
"092": "m22",
"093": "m23",
"094": "m24",
"095": "m25",
"096": "m26",
"097": "m27",
"098": "m28",
"099": "m29",
"100": "m30",
"101": "RHEWA 82comfort", // added in HW 3.5+ SW 1.38
"102": "IAQ", // added in HW 3.5+ SW 1.40
"024": "DUX0",
"026": "DUX1",
"028": "DUX2",
"030": "DUX3",
"032": "DUX4",
"034": "DUX5",
"025": "DUX6",
"027": "DUX7",
"029": "DUX8",
"031": "DUX9",
"033": "DUX10",
}
{
"00": "INPA1",
"01": "INPA2",
"02": "INPA3",
"03": "INPA4",
"04": "INPA5",
"05": "INPA6",
"06": "VIN",
"07": "INPA1_RAW",
"08": "INPA2_RAW",
"09": "INPA3_RAW",
"10": "INPA4_RAW",
"11": "INPA5_RAW",
"12": "INPA6_RAW",
"13": "TEMP",
"14": "T1",
"15": "H1",
"16": "DS1",
"17": "DS2",
"18": "DS3",
"19": "DS4",
"20": "DS5",
"21": "DS6",
"62": "DS7",
"63": "DS8",
"22": "DIFF1",
"23": "DIFF2",
"81": "DIFF3",
"35": "POWER1",
"36": "POWER2",
"37": "POWER3",
"38": "POWER4",
"39": "ENERGY1",
"40": "ENERGY2",
"41": "ENERGY3",
"42": "ENERGY4",
"43": "OUT0",
"44": "OUT1",
"45": "OUT2",
"46": "OUT3",
"47": "OUT4",
"48": "OUT5",
"49": "PWM0",
"50": "PWM1",
"51": "PWM2",
"52": "PWM3",
"53": "INPD1",
"54": "INPD2",
"55": "INPD3",
"56": "INPD4",
"65": "PM1.0",
"57": "PM2.5",
"66": "PM4.0",
"58": "PM10.0",
"59": "P1",
"60": "CO2",
"61": "UPTIME",
"64": "IP",
"67": "sdm1 (Voltage/Total system power)",
"68": "sdm2 (Current/Import Energy since last reset)",
"69": "sdm3 (Active power/Export Energy since last reset)",
"70": "sdm4 (Apparent power/Total Energy)",
"71": "sdm5 (Reactive power/Settable total Energy)",
"72": "sdm6 (Power factor/Settable import Energy)",
"73": "sdm7 (Phase angle/Settable export Energy)",
"74": "sdm8 (Frequency/Import power)",
"75": "sdm9 (Import active energy/Export power)",
"76": "sdm10 (Export active energy/-)",
"77": "sdm11 (Import reactive energy/-)",
"78": "sdm12 (Export reactive energy/-)",
"79": "sdm13 (Total active energy/-)",
"80": "sdm14 (Total reactive energy/-)",
"24": "DUX0",
"26": "DUX1",
"28": "DUX2",
"30": "DUX3",
"32": "DUX4",
"34": "DUX5",
"25": "DUX6",
"27": "DUX7",
"29": "DUX8",
"31": "DUX9",
"33": "DUX10",
}
The current list of readings codes is available on the Lan Controller website in sections where it can be used: HTTP Client, OLED, Email, Serial Port > GSM SIM800L. It looks like on picture below (excerpt from the HTTP Client page).
Use with a Dahua camera¶
The HTTP Client can be used to send data to be displayed on the image of the Dahua camera, e.g. readings from sensors.
To do this, configure the HTTP Client on the LK as follows:
- select Use Digest Authentication
- in the field Server address 1 enter
<USERNAME>:<PASSWORD>@<CAMERA_IP_ADDRESS>:80/cgi-bin/configManager.cgi?action=setConfig&ChannelTitle[0].Name=<TEXT_TO_DISPLAY>
, np.admin:admin@192.168.1.14:80/cgi-bin/configManager.cgi?action=setConfig&ChannelTitle[0].Name=T %0141 H %0151|U %061
(%0141
- T1 reading,%0151
- H1 reading,%061
- uptime). Alternatively, you can select a different address field, but the cyclic sending function is available for the first. The remaining fields can be used in the Events function, for example to conditionally set different texts. - select Enable periodic sending (only first address)
- set Sending period to 30 (the lower the value, the more frequent updates of the text on the camera view)
As a result, the given text will be visible in the camera view, and the text will be updated every 30 seconds. The image below shows the function in question on the Dahua IPC-HFW5241T-ASE camera. HTTPS access is disabled on the camera (System > Safety > HTTPS) because LK currently does not support HTTPS requests, only HTTP.