Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

doc_tap_packetparser_implementation;

doc_tap_http1;

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.

Example: DOPLNIT!!!!!!!

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

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.

Info

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

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.

...

doc_tap_packetparser_hierarchy;

Info

doc_tap_packetparser_hierarchy_example;

doc_tap_packetparser_scripts;

Tip

doc_tap_packetparser_scripts_link;

Info

doc_tap_packetparser_moreinfo;

doc_tap_packetparser_protocols;

  • HTTP

  • TCP

  • UDP

  • FTP

  • MQTT

HTTP

SENDHTTPREQUEST

doc_tap_sendhttprequest;

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

...

Code Block
languagenone
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

SENDDATA

...

TCP, UDP

SENDDATA

doc_tap_senddata;

Code Block
SENDDATA( string/Collection<UInt8> )

...

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

COMPLETESERVICEATTRIBUTE

doc_tap_completeserviceattribute;

Code Block
COMPLETESERVICEATTRIBUTE( attributeName, value, error )

Examples:

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

FTPDOWNLOAD

...

COMPLETESERVICEACTION

doc_tap_completeserviceaction;

Code Block
COMPLETESERVICEACTION( actionName, result )

Examples:

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

FTP

FTPDOWNLOAD

doc_tap_ftpdownload;

Code Block
FTPDOWNLOAD( pathToFile )

...

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

FTPUPLOAD

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

Code Block
FTPUPLOAD( pathToFile, data, mode )

...

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

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.

...

MQTT

doc_tap_packetparser_mqtt;

MQTTPUBLISH

doc_tap_mqttpublish;

Code Block
MQTTPUBLISH( topic, message )

Examples:

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

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.

Code Block
COMPLETESERVICEACTION( actionName, result )

Examples:

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

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

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

Code Block
MQTTPUBLISH( topic, message )

Examples:

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

Listener script

doc_tap_pp_listener_script_description;

doc_tap_pp_listener_script_improvements_heading;

doc_tap_pp_listener_script_instead_of;

Code Block
VAR jsonResponse := TOSTRING(RECEIVEDBYTES);

if parsejson(jsonResponse, "Topic") = "my-topic"

	Va := todouble(parsejson(jsonResponse, "Payload"));

end

doc_tap_pp_listener_script_new_way;

Code Block
if RECEIVEDMSG.TOPIC = "my-topic"

	Va := todouble(TOSTRING(RECEIVEDMSG.PAYLOAD));

end

doc_tap_pp_listener_script_new_way_description;

doc_tap_pp_listener_script_packet_analysis_heading;

doc_tap_pp_listener_script_packet_analysis_description;