...
Represents a specific control element or sensor in the TapHome system. It must always be part of one parent Module.
Info |
---|
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
Info |
---|
Example: Shelly Plug S |
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.
Infotip |
---|
[Click here for more information on the TapHome scripting language](https://taphome.com/support/41123985) |
...
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
Supported protocols
HTTP
TCP
UDP
FTP
MQTT
Anchor | ||||
---|---|---|---|---|
|
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.
...
Code Block | ||
---|---|---|
| ||
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
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.
...
Code Block |
---|
SENDATA(BYTECOLLECTION(“0a dd ef a2”)
SENDATA(“{\”value\”:212}”) |
FTPDOWNLOAD
...
) |
...
FTPDOWNLOAD( pathToFile ) |
Examples:
Code Block |
---|
FTPDOWNLOAD(“/path/to/file”) (Result is Collection<UInt8>) |
FTPUPLOAD
Uploads data (Collection<UInt8> or string) to a file to ftp server.
Code Block |
---|
FTPUPLOAD( pathToFile, data, mode ) |
Examples:
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.
...
Code Block |
---|
COMPLETESERVICEACTION(“Reboot”, “Rebooted successfully”)
COMPLETESERVICEACTION(“Enable cloud”, “Device is offline”) |
FTP
FTPDOWNLOAD
Returns file data (as Collection<UInt8>) from ftp server. Function is supported only in Packet parser scripts with FTP protocol.
Code Block |
---|
FTPDOWNLOAD( pathToFile ) |
Examples:
Code Block |
---|
FTPDOWNLOAD(“/path/to/file”) (Result is Collection<UInt8>) |
FTPUPLOAD
Uploads data (Collection<UInt8> or string) to a file to ftp server.
Code Block |
---|
FTPUPLOAD( pathToFile, data, mode ) |
Examples:
Code Block |
---|
FTPUPLOAD(“/path/to/file”, “some data”, “write”)
FTPUPLOAD(“/path/to/file”, BYTECOLLECTION(“a7 ff e2”), “append”) |
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.
...