Mobile App
The Mobile App integration is how Home Assistant talks to its companion apps for Android and iOS. Among other things, it sends notifications to your phones and tablets.
A notification can carry buttons. Home Assistant tells you when somebody taps one, but waiting for that tap takes a blueprint, or a wait_for_trigger on an event with IDs you make up yourself. Spook adds an action that asks the question, waits for the answer, and hands it back in one go.
Actions
Spook adds one action for the companion apps. You find it wherever you add an action, marked with a 👻.
Ask
Sends a notification with buttons to one or more phones, waits for somebody to tap one, and answers with what they tapped.
The run waits right there, until somebody answers or the time is up. The first tap counts, from whichever phone. The question is then taken away from the other phones, so nobody answers a question that was already answered. When the time is up, it is taken away from every phone, and the answer is empty. That is not an error: the run goes on, and you decide what nobody answering means.
Stop the automation while it waits, or let a mode: restart automation start over, and the question is taken away from every phone as well.
You get one to three answers. Android shows three buttons at most and quietly leaves out the rest, so Spook holds every phone to three. A question asks the same on every phone.
How to use it
- Open the automation or script that should ask, and select Add action.
- Search for ask, and select Mobile App: Ask 👻.
- Under Devices, choose the phones to ask.
- Fill in the Message, and a Title if you like.
- Under Answers, add the buttons, like
Close itandLeave it. - Set Timeout to how long to wait for an answer. It is ten minutes if you leave it.
- Under Response variable, give the answer a name, like
reply. The steps after this one can use it. - Select Save.
Just want to see it work? Try this action opens it in your Home Assistant, ready to run once. The answer shows up below the action once somebody taps.
| Action properties | |
|---|---|
| Action | Mobile App: Ask 👻 |
| Action name | mobile_app.ask |
| Action targets | No targets |
| Action response | Yes, the answer, the device that answered, and whether the time ran out |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
device_id | string | list of strings | Yes | 0123456789abcdef0123456789abcdef |
message | string | Yes | The garage door is still open. Close it? |
title | string | No | Garage |
answers | list of strings | Yes | ["Close it", "Leave it"] |
timeout | time period | No | 00:10:00 |
data | object | No | {"priority": "high", "ttl": 0} |
The response:
| Attribute | Type | Description |
|---|---|---|
answer | string | The text of the button tapped, or empty when nobody answered. |
device_id | string | The device it was tapped on, or empty when nobody answered. |
timed_out | boolean | Whether the time ran out before anybody answered. |
The answers have to differ from each other. Two buttons saying the same thing leave no way to tell which one was meant, so that is refused.
Anything in data goes along with the notification, like priority, ttl, channel, image or push. The companion app documentation lists what each app understands. Leave out actions and tag: Spook sets those itself, to find the answer back and to take the question away again, and refuses a call that sets them.
A device that does not exist, is not a phone or tablet with the companion app, or whose app does not take notifications, is refused before anything is sent.
Ask whether to close the garage door, and do what the answer says:
- action: mobile_app.ask
data:
device_id:
- 0123456789abcdef0123456789abcdef
- fedcba9876543210fedcba9876543210
title: Garage
message: The garage door is still open. Close it?
answers:
- Close it
- Leave it
timeout:
minutes: 10
response_variable: reply
- choose:
- conditions: "{{ reply.answer == 'Close it' }}"
sequence:
- action: cover.close_cover
target:
entity_id: cover.garage_door
- conditions: "{{ reply.timed_out }}"
sequence:
- action: notify.persistent_notification
data:
message: Nobody answered about the garage door.
Anything you want to do with a "Leave it" goes in a third branch. Or nowhere: leaving it is what it says.
- The run waits until somebody answers or the time is up, a day at most. A restart of Home Assistant in between stops the run, and the question may be left on the phones.
- Three answers at most, because that is what Android shows. Typing a reply is not supported.
- A phone Home Assistant cannot send the question to fails the action. The question is taken away again from the phones it did reach. A push the push service turns down, like on a rate limit, only ends up in the log, as with any notification: that phone never gets the question, and the action waits for the others or for the time to run out.
- Only taps count. Swiping the notification away is not an answer, so the action keeps waiting until the time is up.
Missing something here?
An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.
