Getting Started with Sponge and the Sponge Remote Mobile App


14 Aug 2020 - Marcin Paś

After reading this article you will learn:

  • What are Sponge and Sponge Remote?

  • What are the problems that Sponge and Sponge Remote solve?

  • What are the main advantages of Sponge and Sponge Remote?

  • How to connect to a remote Sponge service using the Sponge Remote mobile app and how to run a simple action?

  • Are Sponge and Sponge Remote the best choices for you?

1. What you need

  • About 5 minutes.

  • An Android phone or tablet with an Internet connection.

  • Basic programming knowledge.

2. What are Sponge and Sponge Remote?

Sponge is an open-source, Java-based action and event processing service.

Sponge Remote is an open-source mobile application that provides an opinionated, minimalistic, generic user interface to call remote actions.

Currently Sponge Remote is in alpha phase and supports only a limited set of Sponge features.

3. What are the problems that Sponge and Sponge Remote solve?

Suppose you have an idea of a service that everyone (or just you) needs. :-)

The service that can be used (managed, monitored or whatever) remotely via a mobile app. The service that will be available in the Internet or only in a local network.

There are many possibilities to do that.

But suppose that:

  • You don’t want to concentrate on programming a new mobile app or on tedious tasks of creating your backend service.

  • You want to do it fast with less coding.

  • You just want to write only the necessary code for your idea and use it.

  • You don’t even care if the mobile app would be minimalistic. Besides, you will find out soon that you are be able to create your own mobile app based on Flutter and the Sponge Flutter API that Sponge Remote is built upon.

Well, it would be a lot easier to just install the mobile app, open it and connect to the service.

This is where Sponge and Sponge Remote come into play.

4. What are the main advantages of Sponge and Sponge Remote?

  • You don’t have to program your mobile app if you are comfortable with the Sponge Remote app user interface. Just install it as it is.

  • To provide the core functionalities of your idea you would only write your own actions in the service. The actions will be rendered by the mobile app. You can even change your action source code in the service and run a hot reload in your Android device to instantly see the changes.

  • Sponge and Sponge Remote can be useful in such diverse areas as task automation, IoT, edge computing, etc. They can aid in learning scripting languages (e.g. Python, Ruby, Groovy) and possibly even make it more fun :-) by allowing you to edit the input and to see the output data structures in a mobile app.

5. Install the Sponge Remote mobile app on your Android device

In your Android phone or tablet go to the Play Store, search for and install the Sponge Remote app. Google Play and the Google Play logo are trademarks of Google LLC.

Get it on Google Play

6. Open and setup the app

When you open the app you will be shown the actions screen with a prompt. First you have to activate a connection to a remote Sponge service. To do so, tap the prompt text.

01 100 actions not connected

Now you have a choice to add a new connection or select the predefined Demo Service.

01 110 connections not connected

To do so, tap the Demo Service.

01 120 connections connected

You will be navigated back to the Actions page.

7. What are all these actions?

The actions page is now titled Demo service. This is the name of the selected connection.

01 130 actions connected

What you can see now, are the actions published in the remote Demo Service, arranged into tabs. Each tab corresponds to an action category that is configured in the service.

8. Running a remote action

For the purpose of this article, let’s open the Hello World action by tapping it. You will be shown the action call screen.

01 140 action hello world with no data

Fill in the text field. This text field corresponds to the action argument.

01 150 action hello world with data

Then tap the RUN button to call the action remotely.

The action result will be shown beneath the action name in the actions page. This an elementary case because here the action result is simply displayed.

01 160 actions hello world result

Some of the most useful actions are not callable (there would be no button to run the action) but they initiate a two-way communication with the service by using so called provided and submittable arguments. For more information see the other articles about Sponge Remote.

9. Where is the actual action code?

The action code is stored in the remote service.

An action can be written in one of the several supported scripting languages, i.e. Python, Ruby, Groovy, JavaScript as well as in Java or Kotlin.

The Python code of the Hello world action is just a class definition.

class HelloWorldAction(Action):
    def onConfigure(self):
        self.withLabel("Hello world").withDescription("Returns a greeting text.")
        self.withArg(StringType("name").withLabel("Your name").withDescription("Type your name."))
        self.withResult(StringType().withLabel("Greeting").withDescription("The greeting text."))
    def onCall(self, name):
        return u"Hello World! Hello {}!".format(name)

In order to be visible in the Sponge Remote app an action class must:

  • extend the base Action class,

  • override the onConfigure method, define its arguments (withArg or withArgs) and the result (withResult),

  • override the onCall method (if the action is callable).

10. How does it work?

When you press the RUN button, the onCall method will be invoked remotely with the arguments you entered and the result will be sent back to the app.

11. Are Sponge and Sponge Remote the best choices for you?

Of course Sponge and Sponge Remote are not the best choices for everyone.

In their basic use case they would rather be suitable for lightweight or low-cost solutions. In more advanced cases you will need to build your own mobile app using the Sponge Flutter API.

It’s up to you to evaluate the pros and cons given your goals.

12. Summary

Congratulations! Now you are familiar with the basics of Sponge and the Sponge Remote mobile app.

However the real journey begins with creating your own Sponge service, writing your own actions and using them in the same mobile app you’ve already installed. So, I encourage you to read the next articles.

Link to the Medium article.