Wakeup Android tablet screen with Home Assistant?

FredsterNL

New member
Hi all,

New to MacroDroid, so I am struggling making a macro to wake up a screen.

I want to setup a cheap tablet running Android, to show a Home Assistant screen with Weather info, and a couple of switches to turn lights on or off.

In order to avoid the screen being on constantly, I only want the tablet screen to switch on automatically when someone is actually in the room. Unfortunately the tablet does not have any (useful) sensors I could use.

My question:

I have a PIR sensor in that room where the tablet is (Managed by Home Assistant, zWave type). Is it possible to have Home Assistant activate a MacroDroid macro, when Home Assistant receives a 'movement detected' from the sensor?

If this is possible, is a tutorial available that could help me executing macros from a HomeAssistant event?

Any help is greatly appreciated!
 

Endercraft

Moderator (& bug finder :D)
What actions are available to you when the Home assistant event is triggered ? You could try launching a macro shortcut for example.
 

FredsterNL

New member
Hi,



Thank you for your query for more info.



Quite a few actually, on an invent trigger from the PIR SENSOR 'detected motion', Home Assistant, can do several things (called ACTIONS there):



1) Call a Service (For instance: 'Climate: Turn ON' (Starting my Airco unit). Every new device imported into Home Assistant 'adds' a number of call's specific to that device.



2) Perform an action depending on other parameters (if light is ON, send SMS 'alert' or if light is OFF, send a SMS 'all lights turned OFF)



3) Test a value on OTHER zwave device, Boolean actions testing true/false depending on the state of whichever devices you want to test (light must be OFF on floor 1 & floor 2, NOT porch light)



4) Setting a variable, used in a subsequent action (ie: set variable 'dimmer to 25%' and switch on lamp)



5) activating a device (siren for example)



6) Conditional actions: Turn on Airco, but only if it is 30 degrees inside, else only Turn on a power socket with a regular fan



7) ''manually start an event", for instance a button on an overview screen that closes all curtains and turns off the lights downstairs, when movement is present in an upstairs bedroom



8) Play media from your mp3 collection



9) repeat an action x times



10 ) run actions in parallel with other actions



11) Activate a 'scene' (predefined earlier')⁷



12) Execute a 'Stop'/'Halt' of further processing (Like a breakpoint)

]1

13) Wait until a 'scene' executing' evaluates to True



14) Wait for another trigger to happen



15) A simple delay





Biggest issue is however: Home Assistant is running on a dedicated Linux platform, not on the android tablet that I am trying to wakeup.



What, if any , are the possibilities to trigger a Macro in MacroDroid, when the trigger comes from a different device (like a webhook?)
 

Endercraft

Moderator (& bug finder :D)
There are webhook triggers in MacroDroid. Recently there has been an IP address whitelisting feature added (v5.36), so you can make sure only you can trigger your macros.
If you can call an url from the home assistant, you should use this method.
 

FredsterNL

New member
I think that should be possible, got to figure out how to do that in Home Assistant, but MacroDroid having webhooks ( and the added ip security ) should open a lot of possibilities.

Will keep you posted of any progress, thanks!
 

FredsterNL

New member
There are webhook triggers in MacroDroid. Recently there has been an IP address whitelisting feature added (v5.36), so you can make sure only you can trigger your macros.
If you can call an url from the home assistant, you should use this method.

Hi Endercraft,

As a followup, I have managed to use the WebHook feature of MacroDroid to initiate actions from Home Assistant (The application that manages my PIR sensor (Called 'MultisenSensor 7')

Maybe some other users can use the info, so I include the steps (and screenshots) needed (and a suggestion feature + question for MacroDroid).

I needed to run 2 separate Macro's defined in MacroDroid:
  • A macro to wakeup a screen on Android tablet, when a user was detected by a PIR sensor manged by 'Home Assistant'
  • A macro to put the screen to sleep, when no users are detected by the PIR sensor managed by 'Home Assistant'

Steps followed:
  1. Created 2 separate macro's in MacroDroid and copied the URL's created
  2. In order to enable the URL's to be called as an action from Home Assistant, they have to be added to Home Assistants 'configuration.yaml'
  3. As the 'configuration.yaml' is only read upon boot or restart, boot Home Assistant after the modification
  4. Configure the PIR sensor automation scripts in Home Assitant to call the appropriate URL's (They can now be selected after boot)
  5. Done!

Suggestion:
- Add a Local Only option, as both machines are on the local LAN
- I was unable to add a IP address constraint that worked (using networking/ip allowed). should i use something else? Or should I use the WAN ip address instead of the LOCAL ip address?
 

Attachments

  • Home Assistant WebHook Configuration 01.jpg
    Home Assistant WebHook Configuration 01.jpg
    171.6 KB · Views: 17
  • Home Assistant WebHook Configuration 02.jpg
    Home Assistant WebHook Configuration 02.jpg
    69 KB · Views: 16
  • Home Assistant WebHook Configuration 03.jpg
    Home Assistant WebHook Configuration 03.jpg
    93.8 KB · Views: 16
Last edited:

Endercraft

Moderator (& bug finder :D)
- Add a Local Only option, as both machines are on the local LAN
- I was unable to add a IP address constraint that worked (using networking/ip allowed). should i use something else? Or should I use the WAN ip address instead of the LOCAL ip address?
You need to update to v5.36 to have the whitelisting option.

 
Top