Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

doc_tap_packetparser_implementation; Implementation in TapHome

doc_tap_http1;

doc_tap_packetparser_hierarchy;

Hierarchy

TapHome system uses a hierarchical structure for organizing the connected devices. In this structure, a Module acts as a parent device and can communicate with and control its child devices.

Module

An interface can contain one or more modules, which in most cases cover communication with the entire physical device. From a configuration point of view, the Module defines:

  • IP address or mDNS name of a device

  • Communication port

  • [%key_id:207485597%]: See section [%key_id:19612204%] in [%key_id:3757195%] of a Module

  • Ignore SSL certificate errors

Device

Represents a specific control element or sensor in the TapHome system. It must always be part of one parent Module.

Supported devices:

  • Digital output

  • Analog output

  • Thermostat

  • Multi-value switch

  • Temperature sensor

  • Variable

  • Push button

  • Electric meter

  • Status contact

  • [%key_id:12433814%]

  • [%key_id:3757124%]

  • Tunable white light

Example: Shelly Plug S
Modul obsahuje informáciu o IP adrese, má v sebe skripty na čítanie stavu, nastavení, a vykonávanie servisných akcií. Zastrešuje 2 zariadenia: digitálny výstup (relé) a elektromer merajúci spotrebu pripojených zariadení.

doc_tap_packetparser_hierarchy_example;

doc_tap_packetparser_scripts;

Scripts for reading and writing

TapHome control unit and the connected devices can communicate using HTTP or HTTPS GET / POST requests. The responses to these requests can be parsed using a set of specialized functions. For example, there may be a function that is specifically designed to parse XML responses, another function for parsing JSON responses, and yet another function for parsing byte array responses. These functions make it easier to interpret and use the information received in the responses, allowing for more efficient and effective communication with the control unit and connected devices.

TapHome defines multiple attributes that can contain script language:

  • Initialize script: is run when the device starts (e.g. after the control unit is restarted)

  • Read script: setting values of global variables or reading error states

  • Read Value script: script for reading a specific value (quantity) from a connected device (e.g. set temperature on the thermostat or measured temperature on the thermostat)

  • Write Value script: write the value to the connected device

[Click here for more information on the TapHome scripting language](https://taphome.com/support/41123985)
doc_tap_packetparser_scripts_link;

Definition of error states from scripts

Service attributes and actions

Scripts and auxiliary variables on the module

Scripts and helper variables on the device

See more info on [Modbus documentation page](https://taphome.com/support/15597569).

doc_tap_packetparser_protocols; Supported protocols

  • HTTP

  • TCP

  • UDP

  • FTP

  • MQTT

HTTP

SENDHTTPREQUEST

doc_tap_sendhttprequest;

Sends http request with specified parameters, waits for response and returns response as JSON string with values as Content, Headers, Http result code. Function is supported only in Packet parser scripts with Http protocol.

SENDHTTPREQUEST( path, method, body, header1, header2… )
SENDHTTPREQUEST( HttpRequest )

Examples:

SENDHTTPREQUEST("/getValue")		Result is:
{
  "Headers": [
    {
      "Key": "Content-Type", “Value": [“application/json"]
    },
    {
      "Key": "Content-Length", “Value": ["1007"]
    },
  ],
  "Content": "{\"value\":31}”,
  "ReasonPhrase": "OK",
  "StatusCode": 200,
  "IsSuccess": true
}
SENDHTTPREQUEST("/doSomething", “POST”, “someData”, “header1:value1”, “header2:value2”, “header3:value3”)
VAR request := HTTPREQUEST(“/path”, “PUT”, “someData”);
request.Headers := { “name1: value1”, “name2: value2” … };
request.Method := “POST”;
VAR response := SENDHTTPREQUEST(request);
 
IF response.IsSuccess
	VAR content := response.Content;
	…
END

TCP, UDP

SENDDATA

doc_tap_senddata;

Sends specified data (string or Collection<UInt8>) using tcp or udp protocol. If data is a string object, it’s implicitly converted to bytes using iso-8859-1 encoding. Function is supported only in Packet parser scripts with TCP or UDP protocol. Received bytes can be processed in Listener script.

SENDDATA( string/Collection<UInt8> )

Examples:

SENDATA(BYTECOLLECTION(“0a dd ef a2”)
SENDATA(“{\”value\”:212}”)

COMPLETESERVICEATTRIBUTE

doc_tap_completeserviceattribute;

Function is used in listener scripts in packet parser with TCP/UDP protocol, to notify completion of service attribute value request. Eg. you create a request in service attribute script using the SENDDATA function and after receiving the data in listener script, you complete the service attribute read.

COMPLETESERVICEATTRIBUTE( attributeName, value, error )

Examples:

COMPLETESERVICEATTRIBUTE(“Uptime”, “2d:21h:43m”)
COMPLETESERVICEATTRIBUTE(“Status”, “”, “Device is offline”)

COMPLETESERVICEACTION

doc_tap_completeserviceaction;

Function is used in listener scripts in packet parser with TCP/UDP protocol, to notify completion of service action request. Eg. you create a request in service action script using the SENDDATA function and after receiving the data in listener script, you complete the service action.

COMPLETESERVICEACTION( actionName, result )

Examples:

COMPLETESERVICEACTION(“Reboot”, “Rebooted successfully”)
COMPLETESERVICEACTION(“Enable cloud”, “Device is offline”)

FTP

FTPDOWNLOAD

doc_tap_ftpdownload;

Returns file data (as Collection<UInt8>) from ftp server. Function is supported only in Packet parser scripts with FTP protocol.

FTPDOWNLOAD( pathToFile )

Examples:

FTPDOWNLOAD(“/path/to/file”) 		(Result is Collection<UInt8>)

FTPUPLOAD

doc_tap_ftpupload;

Uploads data (Collection<UInt8> or string) to a file to ftp server.

FTPUPLOAD( pathToFile, data, mode )

Examples:

FTPUPLOAD(“/path/to/file”, “some data”, “write”)
FTPUPLOAD(“/path/to/file”, BYTECOLLECTION(“a7 ff e2”), “append”)

MQTT

doc_tap_packetparser_mqtt;

In addition to the communication options mentioned above, the TapHome system also allows for communication with third-party devices using the MQTT protocol. MQTT, or Message Queuing Telemetry Transport, is a lightweight publish/subscribe messaging protocol that is designed for efficient and reliable communication between devices in machine-to-machine (M2M) and Internet of Things (IoT) contexts.

To enable communication with third-party devices using MQTT, it is necessary to create a separate module in [%key_id:3757018%] → [%key_id:3758433%] → [%key_id:11421487%] → [MQTT Broker](https://taphome.com/support/2331377665). This module acts as an intermediary between the third-party devices and the control unit, allowing them to communicate using the MQTT protocol. The MQTT Broker can be run autonomously on the control unit, allowing for independent and efficient communication between the third-party devices and the TapHome system.

MQTTPUBLISH

doc_tap_mqttpublish;

Function is used in PacketParser devices with MQTT protocol to publish message to a MQTT broker.

MQTTPUBLISH( topic, message )

Examples:

MQTTPUBLISH(“shellies/deviceid/relay/0/command”, “off”)

  • No labels