This tutorial shows how to use Automagic android app to interact with 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.
in order to interact to home assistant by http commands a long life certificate needs to be created in HA:
- Go to your HA page>Profile>Long lived access token>Create token.
- 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.
- Automagic>left panel>Global Variables>add (+)
- Add global_ha_addr variable with your HA ip:port address
- Add global_ha_k variable with “Authorization:Bearer YOUR_TOKEN”
2. Import example flows
I created 2 flows: one to send commands to HA and one to retrieve informations from HA. These flows can be used as a base for you own projects.
WHen you open these links in a device with Automagic installed, you can choose to directly open them in the App.
PART 1: CALLING HA SERVICES FROM AUTOMAGIC
This is the related flow:
in the second block we have to enter HA sevice to call and related entity id:
That’s all. We can test the flow entering your service/entity data and using “Execute” on the top right menu. If it is working you can clone the flow and use it with differents triggers etc.
PART 2: RETRIEVING DATA FROM HA
This is the related flow:
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:
In this flow the retrieved data is shown as a notification on the status bar. That’s all. We can test the flow entering your entity and other data and using “Execute” on the top right menu. If it is working you can clone the flow and use it with differents triggers etc.
PART 3: NFC TAG TO START HOME ASSISTANT SERVICE
The Http Call service Flow contains an NFC trigger. This usage is very useful because using a cheap self adesive tag you can send commands (safely) to HA only approaching your phone to the tag. You need writable tags to do so.
Starting from the example flow:
Tap on the trigger block (the first one), write down a code of your choise and tap on the WRITE button:
Then approach a writable NFC tag; it will be written with the code you choosen:
Now every time you approach the phone to the tag, the flow can start your Home assitant service (for example to open a door or similar).