Home assistant Android custom Widgets

In this guide we can see how to use Automagic android app to create useful widgets for Android phones/tablets that can retrieve data from Home assistant. Automagic is a really powerfull and innovative android automation app. Automagic and Home Assistant toghether lets to do a lot of interesting things.
These widgets are completely customisable: we can show any sensor or state from Home assistant entities, change background, colors, transaprency, text color and dimension etc. We can also decide update frequency.

Prerequisites:

in order to interact with Home assistant, a long life certificate needs to be created:

  1. Go to your HA page>Profile>Long lived access token>Create token.
  2. Take note of created token.

1. Store your access data in Automagic

We have to create 2 variables to store IP address and token of our Home assistant in Automagic. These data will be then available within Automagic when needed.

  1. Automagic>left panel>Global Variables>add (+)
  2. Add global_ha_addr variable with your HA ip:port address
  3. Add global_ha_k variable with “Authorization:Bearer YOUR_TOKEN”

2. Import example flows

I created a flows group to retrieve data from Home assistant that can you see on my example widget above and the widget itself. These flows can be used as a base for you own projects.

Get status flows
Widget

Download above files and copy xml files in your android device: when you open these files in a device with Automagic installed, you can choose to directly import them in the App.

RETRIEVING DATA FROM HA

This is one of the example flows group. With this flow we retrieve studio temperature from Home assistant every 30 minutes (see inside first block where there is the timer):

In the second block we have to enter the entity wich we want to retrieve the status, the attibute three (if the attribute that we are searching is not nested we have to use only “attr” leaving attr1 empty) and the unit of the data:

Last block that we have to edit is the last one: in this block we have to create a global variable (with an appropriate name) where we store retrieved data (studio temp. in this case). This global variable is then used in the widget. Leave untouched part = {state+Unit}

After that come back to the flow view, tap on the 3 points at top right and choose “Execute”. You should see flow to run.
Repeat steps above for each sensor you want to read in your widget(s).
To check if data are correctly retrieved (and related global variables created) come back to Automagic home page, swipe left side, tap “global variables”: you should see all global variables that you created with related readings:

Now we are ready to create our widget: swipe left side, tap “Custom Widgets”; open my custom widget taht you have imported before and modify it according to your needs. You can add free text and one, two, all the global variables that we have created; feel free to take inspiration from my imported widget:

!

For more informations about Automagic widgets see here:
https://automagic4android.com/creating_custom_widget_en.html

Links:
Automagic app

2 Likes

Very cool! Makes me want to get rid my iPhone and go back to Android!

This is great! I love automagic, sad to see it slowly die.

Do you know if we are able to create controllable media player widgets with automagic?

Why? the Home assistant widgets on iPhone are so much better
cries in android :frowning:

Automatic is since dead. Is there another app that is the app of choice for something like this?

The official HA app offers a media player widget

The official HA app has several widgets. In the example above you can achieve the same effect creating a template widget.