Wirtualne wejścia HTTP

Dzięki wirtualnemu wejściu HTTP wartości można odczytać ze strony internetowej. Ułatwia to pobieranie danych z urządzeń wyposażonych w interfejs WWW.

Z biblioteki Loxone Library można importować odpowiednie szablony do integracji urządzeń.

Obsługiwany jest tylko podstawowy schemat uwierzytelniania.

Automatyczne pobieranie danych ze stron internetowych (Web scraping) i wszelkie późniejsze wykorzystanie wyodrębnionych danych powinno odbywać się zgodnie z warunkami korzystania z witryny internetowej, lokalnymi przepisami i obowiązującymi normami.
Loxone nie ponosi odpowiedzialności za jakiekolwiek powstałe konsekwencje z nieprzestrzegania.

Spis treści


Właściwości

Krótki opis Opis Jednostka Zakres wartości Wartość standardowa
URL URL dla zapytań HTTP(S)
Np.: http://192.168.1.7:80/request.php
https://192.168.1.7:443/request.php
- - -
Cykl odpytywania Okres odpytywania w sekundach (minimalnie 10s) s 10...604800 -
Timeout Przekroczenie czasu (timeout) dla odbierania wiadomości
Zwiększ w wypadku powolnych urządzeń lub złego połączenia
ms 10...8000 -
Liczba dozwolonych limitów czasu Liczba nieudanych zapytań przed wyświetleniem komunikatu systemowego. Wartość 0 wyłącza monitorowanie. - 0...100 -




Przykład programowania

Najpierw w obszarze Wejścia wirtualne tworzone jest „Wirtualne wejście HTTP”:

Adres internetowy, odpowiedni cykl odpytywania, limit czasu i liczba dozwolonych limitów czasu są zdefiniowane w oknie właściwości.
W tym przykładzie wartość wejścia „Temperatura” jest pobierana z Miniservera za pomocą polecenia usługi internetowej .
Jeśli wymagana jest autoryzacja użytkownika, nazwę użytkownika i hasło można wprowadzić w następujący sposób: http://Użytkownik:Hasło@adres IP

Wirtualne wejście HTTP rozkaz

Aby wyodrębnić wartości z tej strony, wymagane jest „Wirtualne wejście HTTP rozkaz”.
Można utworzyć dowolną liczbę poleceń w celu pobrania wartości.

Wzorzec wyszukiwania jest definiowany w ustawieniach. W związku z tym można otworzyć okno edycji, w którym wyświetlany jest kod źródłowy strony internetowej, aby ułatwić nawigację do żądanej wartości.

Dane wejściowe można przenieść na stronę programowania poprzez przeciągnięcie i upuszczenie.


Rozpoznawanie poleceń

Command recognition can be used to navigate in a text or source text and to retrieve values.

Characters used to extract a value:

\v = numeric value

\1 = value of byte interpreted as 1st byte of the output (\2, \3, ...)

- If the received data is interpreted as hexadecimal (e.g., "\x0A"), the decimal equivalent (10 in this example) is obtained. This method also works for multiple hexadecimal bytes (e.g., "\x0A\x0B"). When combined, these bytes form the 32-bit integer 0x0A0B, and \2\1 returns 2571 in decimal. The same value, when extracted with \1, results in 10 in decimal.

- If the received data is interpreted as text, each byte represents an ASCII character. For instance, "Loxone" corresponds to the Line Feed character with an ASCII code of 76.

- The data can be used as a signed integer by considering the correct byte order and applying sign extension if necessary.

\h = value interpreted as hexadecimal number

- If the received data is a hex string represented as text (e.g., "0A"), it can be converted to its decimal equivalent (10 in this example).

- This method also works for multiple hex data (e.g., "0A0B"). When converted from hex to decimal, "0A0B" corresponds to 2571.

Characters to navigate through the text:

\. = any character

\w = any word

\# = any number

\d = digits 0-9

\m = character A-Z/a-z/0-9

\a = character A-Z/a-z

\s12 = skip 12 characters
- For example, \s12 skips 12 characters when the received data is a text string.

- If the received data is a hex string represented with escape sequences (e.g., \xFE\xFF\x00\x12\xA0\xB0\xC1\xD2\xE3\xF4\x11\x16\x17), then \s12 will skip 12 hex bytes. In this case, it will jump behind \x16, effectively skipping a total of 48 text characters (since each hex byte is represented by four text characters).

\iText\i = jump behind "Text"

Special characters:

\x = Hexadecimal number (e.g. 0x09)

\\ = Slash

\t = Tab (0x09)

\b = Space (0x02) or Tab (0x09)

<b>\r</b> = Return (0x0d)

<b>\n</b> = Newline (0x0a)

In the following example, we want to extract the current price of natural gas:

Since the text "Natural Gas" is constant, we can jump to this position in the text. To extract the current price, we have to skip the time indication. There are several options to do so:

Variant 1 via \d\a
With \d single digits and with \a single characters can be skipped:

Variant 2 via \#\w
With \# a number and with \w any word can be skipped:

Variant 3 via \s8
Since in this example the time will always have the same number of digits and characters, they can be skipped with \s8: