Manage android device

This is the third attempt to make friends with the smart home android, I remind you that the first attempt to control android devices via HTTP, was using the Paw Server application. This application allowed using the BeanShell language to embed your code in the xhtml page and interact with it, retrieve data or manage it. To integrate with the smart home server (ioBroker) the driver was written, but for its first setup it was necessary to manually load the scripts. Further, already through the driver, the scripts were updated, which allowed adding new functions and correcting errors, but also imposed a number of restrictions in trying to deviate from the methods incorporated in the Paw Server to implement new functions.

The second attempt was to build your source-based application from the Paw server. The main goal was to simplify the configuration process for the user, as well as add new features that could not be implemented in the previous version.

In the same version, it was decided to completely abandon the Paw server and rewrite the application and driver for ioBroker. Add new connection methods, besides the existing HTTP, also MQTT. Add more settings for the selection of events, both from the system itself and from the built-in sensors. Of course, the first thing the application will be optimized for ioBroker, but can easily be integrated into other systems.

Google play

The application allows you to:

  1. Get the status of the system settings (backlight brightness, screen status, volume level, battery, etc.)
  2. Receive data from incoming calls, speech recognition
  3. Receive data from embedded sensors.
  4. Get location coordinates.
  5. Get a list of installed applications and run them.
  6. Manage system settings (backlight brightness, volume level, etc.)
  7. Make calls.
  8. Create notifications and "dialog" windows.
  9. Send text to speech synthesis.
  10. Interact with tasker.
  11. Send files to devices (HTTP only).


The appearance of the application is not final and may vary. I would like to change or add many things, but this is all over time.

With navigation through the application, I think, there should be no difficulties. When you first start the application briefly informs about the current changes in the new version and will offer to use the "assistant". Going to the application settings, you can change the basic operation settings, select the type of connection, select the events that will be transmitted to the server, and also allow or deny access to some data (phonebook, messages, call list and photos)

On the main screen, you can see the "tiles", while this is a trial version, but over time I plan to expand their capabilities. Of the available "tiles" at the moment, there is: a button, dimmer, time, list, color, information. The main task of the “tiles” is to send or receive data (commands) from the server or control other devices. There is no general picture of how everything should work, so I will not describe all the nuances now.


Now, about connections and control commands, the application has two options for connecting via HTTP and MQTT. Each method has its own advantages and disadvantages, which connection method you decide to choose.


This method involves connecting via Wi-Fi to a local network. The application “raises” its web server (ip-address and port can be viewed in the notification when connecting) and gives access to manage it. This can be done either directly (through the browser), or in integration with the server of the database, using POST or GET requests.

Answers from requests will be returned in JSON format, in the response body the device name, ip address and command status are transmitted. Some requests call for an additional “callback”, for example, when sending text for speech synthesis, the application will send a request to the server to start speaking the text and its completion. In the same way, the application transmits data about events and indications of embedded sensors to the server. Therefore, to complete the work, it is required that the UD server is able to process them.


The MQTT protocol is quite popular and supported by various CA systems; this makes it easy to integrate the application into them. When choosing this connection method, you can use both local and external MQTT broker.

When connecting to the MQTT broker, the main branch is created / PAW /, then comes the name of the device (for each device it must be its own), which in turn are divided into two branches of the topic / info / and / comm /, from the name you can guess that the info (information) branch publishes all the incoming information from the device, and the comm (command) branch of the topic to manage it. This is done for clarity, to better understand which topic is responsible for what.

Also in the main branch there is / all_devices / In this thread there are topics for which all devices subscribe, which allows you to manage all devices at once.

For universality, in those topics whose values ​​can be true (true) or false (false), they can take different values, that is, 1, on, auto, true – this is the true value, but 0, off, false, manual – this is false. Another feature of the application is that to verify the execution of the command, if it is successful, the same topic is published null. And if the value after publication has not disappeared, it means that an error occurred while executing the command or the value does not correspond to the correct one for this topic. For example, if you change the volume level, if the value does not match the number or goes beyond the maximum, for this type of volume level, it will return an error.

Also in this version, the set of commands for notifications and “dialogues” has been expanded, they allow you to display more detailed information and also interact with the user if the device is used as an informer. When building them, a large number of parameters are required, so it is necessary to publish the value in the JSON format to the corresponding topic.

For topic notifications / comm / notification / create (below is an example of the meaning)

 "noti": "Any text",
 "title": "Title 2",
 "info": "Any text",
 "vibrate": true
 "sound": true
 "light": true
 "id": 2

For the "dialogues" topic / comm / notification / alert. The answer from the "dialogues" comes in JSON format and is published in the topic / info / alert / response

 "alert": "Turn the lights off?",
 "title": "Light",
 "negative": "No",
 "positive": "Yes",
 "neutral": "Neutral",
 "sound": true
 "id": 2

IoBroker integration

Embedding into the application the ability to work through the MQTT protocol, I just wanted to simplify integration with the system and get rid of writing a separate driver. But some functions cannot be implemented through the MQTT protocol and for this reason we cannot do without a driver.

The structure of driver objects is similar to the structure of MQTT, and is also divided into two branches / info / and / comm /, has similar commands for management and the same reaction to incorrect data. I will not describe the configuration and operation of the driver here, all relevant information will be updated on GitHub.


Regarding the management of system settings (backlight brightness control, waking from sleep, etc.) – different devices will react differently, or not respond, to commands. Due to the wide variety of devices, SDK versions, firmwares, it is difficult to set one model behavior per command. Here you need to select the action according to your device, for example, for most devices turning off the screen (send it to sleep) just change the timeout for the backlight, but on some devices it will not work. The same situation is with other system settings, for most devices changes will occur immediately, but for others it is necessary to send the device to sleep and then wake it up so that the changes take effect. The smallest problems of this kind arise with the SDK 19 (Android 4.4), but this is not accurate.) Just do not forget that there is support for Tasker, and if you lack a function, you can add it and interact through the application.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *