There is often a necessity to attach a certain action to “one button”. This function is very successful among various smart home systems, Wi-Fi sockets and other cloud IoT gadgets. But the cloud is not always convenient and acceptable. For example, you do not want to expand the perimeter of the network or simply do not trust the clouds of manufacturers of such equipment. In this case, the scheme for sending the command directly to the device is suitable, but it is often not very convenient, especially for the devices whose main application cases differ from current needs, for example, our monitoring devices and IPPDU. Let`s analyze in two brief examples how you can implement a relay switching or other actions with one or two “buttons” from a mobile phone via HTTP API and SMS commands.
Here, you can successfully use the application Android application «HTTP Shortcuts». This is an open source application available on GitHub. Its capabilities are extensive enough, but we will use only the basic function - creating HTTP shortcuts on the desktop and if you tap on them, this will cause an access to the HTTP API of our device. We will not describe the process of how to install the application, this procedure is quite simple, and any user of an Android smartphone can easily cope with it.
You can add a new shortcut by tapping on the blue plus in the lower right corner of the screen (1), now we are interested in the "Regular HTTP Shortcut" (2).
Then, you can see various shortcut settings:
The Shortcut Name/Description
The main request settings are URL for controlling a specific object on our device, for example, a relay, and the HTTP method, in our case it is GET.
Basic Request Settings - you can add any necessary information to the headings, in our case there is no need in it.
Request body/Parameters - not applicable in our case. For POST, for example, you can set some variables.
Authentication is an important point, in our case, “Basic”, and you have to enter the login/password from the device’s web interface.
Response Handling — the way how the response will be displayed from the device. You can leave the default “Response in notification”, then a notification from the device will appear at the bottom of the screen. It is useful for understanding if a command has been executed.
Misc Settings- are different minor settings, we are not going to write about them here.
Advanced Technical Settings - for people who know what they`re doing
We will make a reset shortcut for the NetPing 2 IP PDU GSM3G 203R15 power socket (the same methods are applicable to our other devices), in order to do this we just need to fill out the following:
Shortcut Name/Description: for example, 2PWR Socket 1/switch.
Basic Request Settings: the method — GET, URL — http://ip:port/relay.cgi?r1=f,3, where ip:port — is an IP-address и a web server port on the device, and «/relay.cgi?r1=f,3» is switching the first outlet in an inverse state for 3 seconds and vice versa according to the documentation. In order to work from the outside, we recommend you to use a white static address or DDNS / DNS, an open port, or other methods that will allow you to access the device from the outside.
When you save the settings, a new shortcut will appear in the general list. In order to add it to the screen, you need to call the context menu with a long tap (1) and click on the “Place on home screen” item (2) in it.
After the above described procedures, the shortcut should appear on one of the phone’s desktops, only after that you can check the operation by clicking on it (1) - after a couple of seconds the message relay_result ('ok') (2) will appear at the bottom of the screen, this is a response from our NetPing device, which indicates that the command is accepted. If the device is in close proximity to you, you will hear two clicks of the relay at intervals of 3 s.
Unfortunately, this option could not be implemented into a “one button”. You will need two buttons. This time we suggest you use the "Shortcut Creator" application.
After installing the application, you will see the main screen. We are interested in the "Message Template" item.
When you tap this item, you will see the settings for adding a new shortcut:
Name - is the name which it will be displayed with.
Message for SMS - put the checkbox, the sending channel is SMS.
Message is the text of the message itself. According to the documentation, this command reset the power outlet 1 for 3s.
Additional parameters - here you need to add the phone number to which SMS will be sent. Several numbers are available.
Open in application - select the application with help of which the SMS will be sent. In this case, it is the standard system "Messages".
Next step, to save and add it to the screen, you need to tap on the plus in the upper right part of the screen and “On launcher”.
After it, you will see it on one of the phone’s desktops:
After tapping on this new created shortcut, the specified application will be opened, there will be a dialogue with the specified recipient (s) in it, and the text which you entered will be inserted into the message field for sending.
This concludes the brief description of two simple “one-button” control methods. We hope that this information was useful to you. If you have your own examples of automation and simplification of managing and working with our devices, send them to us at firstname.lastname@example.org