Documentation

Device Description

Data Transfer Protocol

To communicate with the device, the built-in communication module ESP8266 model ESP-07 is used. For data exchange, port 8888 and the network protocol of UDP data transfer are used. To exchange information between the device and the user's client, the internal protocol of the device is based on JSON:

The communication device receives three types of commands: GET, POST, INFO:

GET type commands allow you to make a request to receive data from the device.

Syntax of commands: all commands are sent only in a string form. The device has an internal query validator, but there is no validation for the parameters, and all validation of the parameters must take place on the client side, so you need to take this into account when designing. Since the use of non-valid parameters can cause ambiguous operation of the device.

The format of the GET commands:

{"status":"get","message":"device"}

status - the type of the command being sent: GET, POST, INFO

message - command to the device:

  • device - information about the device.
  • canal - information about the state of the channels of the device
  • timer_daily_state - information about daily device timers
  • timer_hours_state - information about the hourly timer of the device
  • timer_seconds_state - information about the device's second timer
  • temp_state - information about the temperature settings of the device
  • temp_sensors - information about the temperature sensors of the device

data - optional parameter for passing query parameters, in the GET request is not used.

For each GET request, the device sends a response as its internal JSON. Such requests and examples of such answers are provided below:

Device Information:

  • Request:
    {
    	"status": "get",
    	"message": "dev"
    }

     

  • Response:
    {
        "status": "success",
        "message": "dev",
        "data": {
            "ver": "AQ_CH08W",
            "m_t": 10,
            "m_t_se": 4,
            "min_t": 1600,
            "max_t": 3500
        }
    }
  • "ver": "AQ_CH08W" - version of the device
  • "m_t": 8 - maximum number of timers (daily, hourly, second)
  • "m_t_se": 4 - the maximum possible number of connected temperature sensors
  • "min_t": 1600 - minimum temperature threshold
  • "max_t: 3500 - maximum temperature threshold

Information on the status of the channels of the device:

  • Request:
    {
    	"status": "get",
    	"message": "c_s"
    }

     

  • Response:
    {
        "status": "success",
        "message": "c_s",
        "data": {
            "cl": [2, 1, 1, 1, 1, 1, 1, 1],
            "c_t": [2, 3, 3, 3, 3, 3, 3, 3]
        }
    }
  • "cl": [2, 2, 1, 1, 1, 1, 1, 1] - Channel state (1 - off, 2 - on, 3-daily, 4-hour, 5-sec, 6-temp)
  • "c_t": [3, 2, 1, 1, 1, 1, 1, 1] - Channel settings (1 - off, 2 - on, 3 - auto)

Information about the device's daily timers:

  • Request:
    {
    	"status": "get",
    	"message": "td_s"
    }

     

  • Response:

    {
        "status": "success",
        "message": "td_s",
        "data": {
            "dt_h_s": [0, 12, 12, 0, 0, 0, 0, 0, 0, 0],
            "dt_h_end": [0, 20, 21, 0, 0, 0, 0, 0, 0, 0],
            "dt_m_s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "dt_m_e": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "dt_s": [0, 1, 1, 0, 0, 0, 0, 0, 0, 0],
            "dt_c": [0, 1, 2, 0, 0, 0, 0, 0, 0, 0]
        }
    }
  • "dt_h_s": [0, 0, 0, 0, 0, 0, 0, 0] - Hour the timer starts (0...23)
  • "dt_h_end": [0, 0, 0, 0, 0, 0, 0, 0] - Hour the timer is turned off (0...23)
  • "dt_m_s: [0, 0, 0, 0, 0, 0, 0, 0] - Minute on timer (0...59)
  • "dt_m_e": [0, 0, 0, 0, 0, 0, 0, 0] - Minute off timer (0...59)
  • "dt_s": [0, 0, 0, 0, 0, 0, 0, 0] - Timer state (0 - off, 1 - on)
  • "dti_c": [0, 0, 0, 0, 0, 0, 0, 0] - Timer-controlled channel (0...max_canal)

Information about hourly timer devices:

  • Request:
    {
    	"status": "get",
    	"message": "th_s"
    }

     

  • Response:

    {
        "status": "success",
        "message": "th_s",
        "data": {
            "ht_m_st": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "ht_m_sp": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "ht_s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "ht_c": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        }
    }
  • "ht_m_st": [0, 0, 0, 0, 0, 0, 0, 0] - Minute on timer (0...59)
  • "ht_m_sp": [0, 0, 0, 0, 0, 0, 0, 0] - Minute off timer (0...59)
  • "ht_s": [0, 0, 0, 0, 0, 0, 0, 0] - Timer state (0 - off, 1 - on)
  • "ht_c": [0, 0, 0, 0, 0, 0, 0, 0] - Timer-controlled channel (0...max_canal)

Information about device's second timers:

  • Request:
    {
    	"status": "get",
    	"message": "ts_s"
    }

     

  • Response:

    {
        "status": "success",
        "message": "ts_s",
        "data": {
            "st_h_s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "st_m_s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "st_d": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "st_s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "st_c": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        }
    }
  • "st_h_s": [0, 0, 0, 0, 0, 0, 0, 0]  - Hour the timer starts(0...23)
  • "st_m_s": [0, 0, 0, 0, 0, 0, 0, 0] - Minute on timer (0...59)
  • "st_d": [0, 0, 0, 0, 0, 0, 0, 0] - Duration of the timer in seconds (0...255)
  • "st_s": [0, 0, 0, 0, 0, 0, 0, 0] - Timer state (0 - off, 1 - on)
  • "st_c": [0, 0, 0, 0, 0, 0, 0, 0] - Timer-controlled channel (0...max_canal)

Information about the temperature settings of the device:

  • Request:
    {
    	"status": "get",
    	"message": "te_s"
    }

     

  • Response:

    {
        "status": "success",
        "message": "te_s",
        "data": {
            "tt_s": [0, 0, 0, 0],
            "tt_m_s": [0, 0, 0, 0],
            "tt_m_e": [76, 76, 76, 76],
            "tt_c": [1, 0, 0, 0]
        }
    }
  • "tt_s": [1, 0, 0, 0, 0, 0, 0, 0] - State of the temperature timer
  • "tt_m_s": [2000, 2250, 0, 0, 0, 0, 0, 0] - Channel switching temperature (min_temp...max_temp, кратна 50)
  • "tt_m_e": [2600, 2850, 0, 0, 0, 0, 0, 0] - Channel shutdown temperature (min_temp...max_temp кратна 50)
  • "tt_c": [1, 0, 0, 0, 0, 0, 0, 0] - Channel controlled by a timer (0...max_canal)

Information about the temperature sensors of the device:

  • Request:
    {
    	"status": "get",
    	"message": "t_se"
    }

      

  • Response:

    {
        "status": "success",
        "message": "t_sen",
        "data": {
            "t_se": [4, 3, 0, 0]
        }
    }
  • "t_se": [2400, 2650, 0, 0, 0, 0, 0, 0] - Sensor temperature (min_temp...max_temp)

POST command format

POST commands differ from GET commands only in that in the request it is necessary to specify the query parameters in the data field and the status field contains the post parameter. The data format for the data field is similar to the data coming from the device when requested by the GET command.

Examples of possible queries:

Changing the status of the device's channels:

  • Request:
{
	"status": "post",
	"message": "c_s",
	"data": {
		"c_t": [1, 0, 0, 0, 0, 0, 0, 0]
	}
}

Note to change the channel settings, send only the canal_timer parameter, the canal parameter is not intended to be changed, it is responsible only for the current channel state, depending on the timer settings or manual settings.

Change the device's daily timers:

  • Request:
{
	"status": "post",
	"message": "timer_daily_state",
	"data": {
		"dt_h_s": [1, 0, 0, 0, 0, 0, 0, 0],
		"dt_h_end": [2, 0, 0, 0, 0, 0, 0, 0],
		"dt_m_s": [5, 0, 0, 0, 0, 0, 0, 0],
		"dt_m_e": [55, 0, 0, 0, 0, 0, 0, 0],
		"dt_s": [1, 0, 0, 0, 0, 0, 0, 0],
		"dt_c": [3, 0, 0, 0, 0, 0, 0, 0]
	}
}

Changing the hourly timers of the device:

  • Request:
{
	"status": "post",
	"message": "th_s",
	"data": {
		"ht_min_st": [45, 0, 0, 0, 0, 0, 0, 0],
		"ht_min_sp": [56, 0, 0, 0, 0, 0, 0, 0],
		"ht_s": [1, 0, 0, 0, 0, 0, 0, 0],
		"ht_c": [3, 0, 0, 0, 0, 0, 0, 0]
	}
}

Change the second device timers:

  • Request:
{
	"status": "post",
	"message": "ts_s",
	"data": {
		"st_h_s": [5, 0, 0, 0, 0, 0, 0, 0],
		"st_m_s": [26, 0, 0, 0, 0, 0, 0, 0],
		"st_d": [125, 0, 0, 0, 0, 0, 0, 0],
		"st_s": [1, 0, 0, 0, 0, 0, 0, 0],
		"st_c": [2, 0, 0, 0, 0, 0, 0, 0]
	}
}

Changing the temperature settings of the device:

  • Request:
{
	"status": "post",
	"message": "te_s",
	"data": {
		"tt_s": [0, 0, 0, 0, 0, 0, 0, 0],
		"tt_m_s": [2200, 2250, 0, 0, 0, 0, 0, 0],
		"tt_m_e": [2700, 2850, 0, 0, 0, 0, 0, 0],
		"tt_c": [5, 0, 0, 0, 0, 0, 0, 0]
	}
}

With a POST request, it is not necessary to specify all the parameters in the data field. When sending values to the device, you can send only those data that changed on the client. For each POST request executed, the answer is the same GET response with the same message parameter, but with the changed data.

Example:

  • Request
  • {
    	"status": "post",
    	"message": "c_s",
    	"data": {
    		"c_t": [1, 1, 1, 2, 3, 2, 2, 2]
    	}
    }

     

  • Response

  • {
    	"status": "get",
    	"message": "c_s",
    	"data": {
    		"cl": [1, 1, 1, 2, 1, 2, 2, 2],
    		"c_t": [1, 1, 1, 2, 3, 2, 2, 2]
    	}
    }

     

  • Note that the answer to POST always comes in its entirety regardless of the parameters that you send.

Format of INFO commands:

Currently, the INFO format requests are used only for internal data transfer between the Arduino and the ESP8266 communication module. In particular, ESP8266 is used to transfer its state and process logging. The use of external clients in this version is not provided.

Example of sending logs of WIFI connection to the device:

{
	"status": "info",
	"message": "wifi_log",
	"log": ""
}

Яндекс.Метрика