You need to properly setup an HTTP profile in order to send and/or receive HTTP messages as well as for using REST API and JSON API.
Go to Plugins –> Big6 –> Profiles Configuration
Select HTTP from the top menu and click “+” to create a new HTTP profile or “edit” whatever the case might be.
Name: pick any name that you will refer later to
Method: GET for most common applications and for “listening” mode (see below), Use POST, PUT and DELETE for REST API and JSON API mainly after coordinating closely with your API provider.
URL: The URL of your destination for outgoing HTTP profiles. For incoming (listening) HTTP profiles – The URL of your HS4 server plus port number plus name of the script.
Example: If your device is sending out an HTTP request like this
http://192.168.1.242:83/myapp.asp?name=sensor1&temp=72&hum=66&sensor=on
than your icoming (listening) HTTP profile must have URL setting like this
http://192.168.1.242:83/myapp.asp
IMPORTANT NOTE HTTP GET (non listening) MUST have ${input} at the end.
Put your main URL in the HTTP profile found in Big6 settings plus ${input} at the end like this
Example: http://www.for-example.com/api?${input}
${input} will be replaced with whatever you put in Big6 action box in HS4 event. This allows for great flexibility and reduces the number of HTTP profiles.
For the above Example: if you put “get_me_data_” in Big6 HTTP action box in HS4 events than the URL that will go out as part of your GET HTTP action will be
http://www.for-example.com/api?get_me_data
Authentication (new 6 authentication modes are supported now)
Check your remote site/device for the kind of Authorization that it requires (if any). If your remote side needs username/password than it is “Basic Authorization” most likely. If you need a long weird string of characters like this a.k.a. “token”
5443414337:AAHRboF-SC58r6q9XZr21UIawe32sW451fJ-WVjcQ
than the Authorization method is Bearer Token most likely
oAuth2 is the most complex of them all Click here for detailed explanation and example of how to use oAuth2.
Request/Response body. The effect of this optional box depends on the profile
Put any additional strings in the Big6 HTTP action box (see p.1 and 2 above)
For HTTP POST, PUT and DELETE Output profiles the content of this box will be sent out each time the profile is addressed by HS4 Big6 HTTP action from the action drop-down menu of HS4 event. Please note that this duplicates the action. So you have two choices to setup the content in the Action menu and keep the box empty in the HTTP profile or vice versa keep the action box empty and fill the body in the profile setup. Do not do both !
For ALL HTTP listening profiles, the role of this box is to setup a custom response to any reference to this profile (GET, PUT, POST or DELETE).
The body has the standard Big6 expression format as you would use in HTTP Action body.
Examples:
${ “any text here” }
${ val1411 } – will send out the value of HS4 device 1411
${ if (val123 > val234 than “level=high”, “level=low”)}
Extra headers: To be used as needed most likely with REST API and JSON API. Multiple headers are possible. Each one on new line.
Listen mode: VERY IMPORTANT ! If checked than this profile will act as HTTP (Web) Server. External devices will be able to communicate with HS4 in fashion similar to the above Example. If unchecked (default) than this Big6 profile will act HTTP (Web) client.
IMPORTANT ! If “listen mode” is checked your profile is a server if unchecked it is a client.
Note: Output (non listening) HTTP profiles can also create HS4 devices and trigger HS4 events, by the input received as a result of an output action. For example if you have output HTTP profile GET it may return some valuable information that could be used to create HS4 devices and store values.
Training: Create HTTP GET profile based on this URL
http://httpbin.org/get
and use Big6 triggers to trigger HS4 event by string matcher for the word “Mozilla”
Root name ID:
The box called “Root name ID (optional)” is used ONLY for a “listening” HTTP profile to create multiple HS4 devices with the same name prefix, found in the input.
Example: if the input to the listening HTTP profile is this
192.168.1.1:84/wireless.asp?temp=71.50&name=Kitchen&event=0&hilo=1&hum=28.126
and you put “name” in the “Root name ID” box than the string “Kitchen” will be retrieved from the input …name=Kitchen … and used as the name of the root device created/updated by Big6.
Root device – Kitchen
Features
temp (78.50)
event (0)
hilo (1)
hum (28.126)
Locked: If checked than Big6 will not create new HS4 devices but will keep updating existing ones.
Num as string: If this box is checked than the input will be imported both as HS4 device value and as HS4 device string. If the box is unchecked than the input will be imported as HS4 device value only.
Device affect expression (optional): Must be logical expression resulting in “true” or “false”. New HS4 devices will be created only if true. Existing HS4 devices will be updated only if it is “true”. Details about expressions in Big6 are available here and here as well .
Device name expression (optional) for both root and feature : Used to extract device names from the input. The device names will be used for creating/updating HS4 devices. Details about expressions in Big6 are available here and here as well . Extrating device names from the input allows for great flexibility, however in simple cases you may want to use a static device name(s) that are not retrieved from the input. Yes, you can do that however do not forget to put the name within straight quotes.
Example: “Input Status”
Device value expression (optional) : Used to extract device values from the input. The device names will be used for creating/updating HS4 devices.
Example: If the HTTP input is
Confirmation 201 keypad: gate button: 6 pressed: 0
than you can use this simple expressions to fetch name “gate” and the button number as value.
Name expression: Words(input)[2]
Value expression: Numbers(input)[1]
This will create HS4 device with name “gate” and value 6.
Training: What HS4 device name and value will be created by same Big6 profile if the input changes to
Confirmation 201 keypad: entry button: 2 pressed: 0
Training: Create name and value expressions to fetch the status of the button pressed.