Tutorial - Display dynamically widgets (KWGT or Zooper) according to AutoRemote messages

Manage your widget display according to informations received with AutoRemote

  1. AgP42

    this tutorial is on the same familly than this one (Tutorial - Receive featured notifications from your home automatisation system) : https://forum.joaoapps.com/index.ph...ons-from-your-home-automatisation-system.393/

    On this tutorial, I will explains how to use AutoRemote messages (can be direct AutoRemote messages, or Actions on the notification messages), to update the display of a widget on your android screen.

    For example here is my widget screen for home automation, fully updated with AutoRemote messages ! (Yes... I am a big fan of AutoRemote ! ;))


    To do so, we will need :
    • Any system able to send an http request according to an event, here we will consider an home automation system.
    • Tasker + AutoRemote
    • an android widget app, it can be : "Zooper" (not available anymore on android market but easy to find on internet for free and still perfectly working on android 9) or "KWGT". I will describe both on this tutorial, personally I am still using Zooper.
    Let's take as an example this widget that display the light status (and is able to toggle it, see the "bonus" at the end of this tutorial...) :

    Let's start from the AutoRemote request, we want to send the message "light=:=On" or "light=:=Off".
    Please open the url given on your AutoRemote for field description and for test purpose.
    The info that will trigger an action can be send by AutoRemote by any of the following fields :
    - Send a message : field "message" (will generate the url part "&message=light=:=On")
    - Send a notification :
    • field "Action on Receive" (will also generate the url part "&message=")
    • "Action on Tap" (generate &action=)
    • "Action on Dismiss" (generate &actionondismiss=)
    • "Action Button 1" or 2 or 3 (generate &action1=, &action2= or &action3=)
    So on my home automation system, I have set up the http request for "send a message" with the message to be sent "light=:=On" or "light=:=Off" each time the light status changes.

    Now let's go on Tasker !

    First we must "listen" for the AutoRemote event, so let's create a "Profile" for it :
    1. Add a new profile and name it what you like
    2. Choose "Event"/"Plugin"/"AutoRemote"/"AutoRemote"
    3. On the configuration, for "Message filter", set "light"
    4. (note that now the variable %arcomm will represent the "On" or "Off" received by this "light" trigger)
    5. return several time up to the choice of the Task you want to associate
    Now we need a Task that will be executed when we receive the correct filter "light" :
    1. Choose "Create new task" and name it what you like
    2. Add an action / Plugin / then choose "Kustom Widget" if you want to use "KWGT" or "Zooper Widget Pro" to use Zooper
    Let's start with KWGT, so :
    1. choose "Kustom Widget" and then"KWGT Send Variable"
    2. On "Configuration", set the "Tasker String" to %arcomm and Variable Kustom to any name you will want to use in KWGT, let's say here "light" :

    Or for Zooper :
    1. choose "Zooper Widget Pro"
    2. On "Configuration", set Variable ZW to any name you will want to use in Zooper, let's say here "light" and the "Text ZW" to %arcomm

    Now you can send your message with the message "light=:=On" to run the profile and to init the variables

    Now let's go on KWGT to see how to use that information :
    1. Long press your android desktop to create a new KWGT widget and clic on it to open the editor
    2. Choose any template or an empty one
    3. Select the + on the right top of the screen to add an object and choose to add a text
    4. Click on the text field to configure it and choose the formula "br", then the first example that is $br(tasker, FOOBAR)$
    5. Replace "FOOBAR" by "light" and see the magic occurs : the Text overview displays "On" !!!
    6. Validate everything to see the widget on your home screen and send another notification with "light=:=Off" and you will see the widget display "Off" !
    Ok, wonderful ! That way you can display all the text you want from AutoRemote to any widget. Now how to use that information to change the image or the color displayed ?
    1. Add another KWGT element on your widget, this time select "Image"
    2. Select the first line "Bitmap"/"Choose an Image" to make new menu appears on the top of the screen. On this menu choose the icon "calculator". Then the icon "calculator" appears at the bottom on the line "Bitmap", clic on it
    3. Here start a wonderfully complex journey ! On this page, you are able to play with if condition to be able to dynamically choose the bitmap path according to any variable value. Here is an example of what to set to display the image "Home_1.png" when the message received is "On" and "Home_2.png" otherwise. Of course you can have fun with much more complexe formular !

    Now you can test again to send the 2 messages and see the images changes dynamically !

    And for Zooper, the idea is really similar :
    • To display the text, create a "enhanced text", then on the field "manuel edition of text", write the variable "#Tlight# to see "On" or "Off" be displayed
    • To display the image, create a "bitmap" and on "advanced params" :
    (here I have a tasker variable "path" that know the path of my images to avoid too many modification if the path has to change for any reason, but you can do with absolute path)

    And that's it !

    So a lot of small steps that require to be precise, but then with some time you can make a very nice result with real time display directly on your home screen !

    BONUS :
    Small bonus for the brave readers that reach the end of this tutorial : how to launch a Tasker task by clicking on any widget part :
    • On KWGT :
    1. Select the element you want to add a reaction, for example the bitmap image
    2. on the bottom part, go to the tab "touch" an click on the field "Action"
    3. On the action list, select "Launch a shortcut"
    4. On this shortcut list, you have the possibility to send an AutoRemote message (Direct Message) or you can choose Tasker "Task shortcut"
    5. Select "Task shortcut" and it will gives you the list of all your task, select the one you want to lauch ! (You cannot create one from here, you have to prepare it inTasker before)
    6. This Task can do for example : open an URL, open a Tasker scene, send an http request to launch a scenario on your home automation system, .......
    • On Zooper :
    1. Select the element you want to add a reaction, for example the bitmap image
    2. on "Module OnTap", go to the 3rd tab "Shortcut"
    3. Select AutoRemote "Direct message" or Tasker "Task shortcut" to select the tasker task you want
    Enjoy and please let me know if some part has to be more detailed or can be improved !