Package: Shelly

Author: HCA Central
Version: 1
Added to Library: 10-Nov-23
HCAVersion needed: 17.0.41
Keywords: Class
Extra Info Link: Here

Package Description:
This is the BASIC package for Shelly support. A more advanced package is available. Review technical note #615 and then contact technical support to purchase the advanced package if wanted.

Program: CompareIP

Program Description:
Compares to IP addresses for equality. DOes it section by section in case one has "0" and the other "00" for example.

Return value: yes, if the two are the same, no otherwise.

Parameters:

Name Type Description Default
IPA Value IP A  
IPB Value IP B  

Program: Create error result

Program Description:
Creates an error Result in JSON format

Return value: JSON format

Parameters:

Name Type Description Default
Code Value error code  
Description Value error description  

Program: DeviceForIPAddress

Program Description:
Find a device of the given class with the give IP address.

Parameters:

Name Type Description Default
IPAddress Value IP Address given a a.b.c.d  
ClassName Value Class name prefix  

Program: GetParameter

Program Description:
Given a URL with parameters, finds the value for a named parameter.

The URL is expected to be structured as: <stuff>?name1=value1&name2=value2&name3=value3

Return value: A BOOL result if the parameter is not found. If found the parameter value as a string.

Parameters:

Name Type Description Default
url Value URL  
name Value Name of parameter  

Program: JSONHelper

Program Description:
Takes two parameters: A JSON encoded message and a CSV list expressing the path to the data to retrieve.

Return value: The extrated data value

Parameters:

Name Type Description Default
jsonMessage Value Message oin Json format  
path Value CSV path of the value to extract  

Program: Receive HTTP Message

Program Description:
Received messages from Shelly devices and processes those. Before this can be used you must configure the devices to send messages to HCA.

Assume IP address of HCA Server computer 192.168.0.144

Assume HCA Generic Server interface named "Shelly" on port 8082

Assume device is named Outside-Gate in HCA

Configure settings using the Shelly UI from a browser. You want the "Action" section. Set any of the six actions - configure only the ones you need. Enter the URLs as follows:

Output Switch on URL

http://192.168.0.144:8082/HCA?action=on&name=Outside-Gate

Output Switch off URL

http://192.168.0.144:8082/HCA?action=off&name=Outside-Gate

Button switched off URL

http://192.168.0.144:8082/HCA?action=buttonOff&name=Outside-Gate

Button switches on URL

http://192.168.0.144:8082/HCA?action=buttonOn&name=Outside-Gate

Button long pressed URL

http://192.168.0.144:8082/HCA?action=buttonLong&name=Outside-Gate

Button short pressed URL

http://192.168.0.144:8082/HCA?action=buttonShort&name=Outside-Gate

Add a tag to the properties of the device to run a a program on a reception. The tag is named ShellyAction and its value is a CSV list of the form:

action1,program1,action2,program2,...

Where the actions are "on", "off", "buttonOn", "buttonOff", "buttonShort", and "buttonLong"

The programs are the 2-part names of the program to run on that action.

For example:

buttonShort,Outside-GateShort,buttonLong,Outside-GateLong

On a short button press the program "Gate-GateShort" is run and on a long button press the program "Gate-GateLong" is run.

Return value: Possible errors are:

100 - request not properly formatted

101 - request doesn't start with /HCA

200 - Necessary parameters for an operation not provided

Parameters:

Name Type Description Default
Received Value Data received  
FromIP Value From IP Address  

Program: Shelly Relay

Program Description:
Implements Shelly relay

Parameters:

Name Type Description Default
HCAName Value HCA Name of the device  
Id Value Class id of the device  
action Value What to do  
percent Value Extra data of what to do  

Program: Shelly Sensor

Program Description:
Implements a Shelly device that is a sensor

Parameters:

Name Type Description Default
HCAName Value HCA Name of the device  
Id Value Class id iof the device  
Action Value Operation to perform  
Percent Value Data for the change percent and set percent operations