HomeTaskerAndroid Power Menu for your DIY smart home

Android Power Menu for your DIY smart home

You are in charge of what goes in!

I’ve grown sceptical over the direction of the Android development, ever since they removed NavBar icon support for 3rd party apps. Apart from making one of my favourite projects completely unusable on devices with Android 10+ (Smart NavBar actions), it indicated that stock Android is no longer the environment where customisation matters. Power Menu tiles are used right now by a handful of smart assistant ecosystems (Google Home, Xiaomi Mi Home) and are limited to template actions offered by these ecosystems.

It’s time to change that.

What is Power Menu

Hidden under the long press of the power button (or in the Status Bar as an option for Xiaomi MiUI based devices like Xiaomi Mi11 (review) enables smart home ecosystems to drop most used devices and associated actions as handy shortcuts. Other than enabling and disabling the tile, the user has very little control over what goes on it.

Tiles are split into 5 categories (stock Android tiles are more bland):

Tile Name Options


Image
Display No options available
Image Shortcut Acts like a shortcut
Image Range Acts like a slider
Image Toggle Acts like a toggle to turn things on/off
Image Range + Toggle Acts like a toggle and slider at the same time

What goes on tiles is determined by the app that supports it. That’s all. To make things worse, at any given time you can only have one ecosystem displaying tiles in the power menu. Changing this is easier on stock Android than MiUI, which makes it even more frustrating for me.

Data first, privacy second

These tiles are great but only available to users who are willing to submit their data to the cloud. If you are a privacy concerned person and you like to keep your automation offline as much as possible (a healthy amount of paranoia is good), then Power Menu may not be for you.

When the Internet goes down, the Power Menu becomes unusable, and the automation falls apart. It shouldn’t be this way.

Tasker enables Power Menu to do more

Thanks to Tasker you can change that (if you are new, do check my start-up guide). It enables Android users to customise Power Menu tiles, assign custom functions and create DIY automation scenario for every Smart Home. Watch this short demo to watch Tasker-enabled Power Menu in action.

Things that you can do with Tasker:

  • ✅ Display devices from multiple ecosystems
  • ✅ Add devices without cloud integration
  • ✅ Make personal shortcuts
  • ✅ Display custom information
  • ✅ Update existing tiles
  • ✅ LAN & WAN controls
  • ❌ Automatically add/remove active tiles

Apart from setting your own DIY smart home tiles, you can take over the multiple properties of the tiles themselves like: title|subtitle|icon, and intercept: toggle and range changes, act on shortcut actions. As usual, the sky is the limit here, but I will take it a step further and I will show you how to integrate the tiles with NodeRED, how to sync these and apply basic automation actions.

Power Menu powered by Tasker

In this article, I will focus on explaining how the integration works, how to deploy it and how to work with it to achieve the best results. In the follow-up articles, I will cover interesting scenarios inspired by the demo from my video and the best ideas submitted to me via social media. The current lineup of tiles includes:

  • Main Smart Lights – Toggle
  • Mood Smart Lights – Toggle & Range
  • Roller Shutters – Range
  • Wake on Lan – Button
  • Temp Sensor – NoAction
  • BONUS 3D printer notification – this is a mock-up. I made a similar solution here.

These are just example use cases. Thanks to Tasker, you are in charge of how the Power Menu behaves. For example: if you rather have the slider control over the bulb colour temperature than brightness you can do it yourself, or use the toggle-range tile to toggle between brightness and colour temperature changes.

Privacy first, data… who needs your data

Tasker doesn’t just only remove the need for cloud but with a NodeRED setup, you can control the lights and get the feedback without the internet (after the initial setup). All you need is access to your local network. A win-win situation for anyone concerned about their privacy! This way you can have your Power Menu without selling your soul to an evil corporation.

It is possible to remove the need for NodeRED and resolve everything using Tasker alone, but the bulk of my automation lives in NodeRED, so my efforts were focused there. If you never considered NodeRED – you probably should, especially that the server can live on inexpensive devices like $5 Raspberry Pi Zero.

Setup

To use Power Menu, you will need the following:

  • Tasker app – best Android automation tool
  • Join app – from the same dev, one of the best utility apps for Android
  • NodeRED
Tasker Setup

To enable Power Menu – you have to assign Tasker as your application that is serving you tiles. This menu is located elsewhere on different mobiles, so search settings for Power Menu or Smart Home to locate it and set the Tasker as your app.

Unfortunately, Tasker will list ALL the tasks that you. If you had been using Tasker for a long time, your list will be long, thankfully, new tiles will appear on the top of the list so you don’t have to scroll much. Tasker offers 2 Power Menu Actions: add/edit and Delete. These will edit the list of the tiles available in the Power Menu, but the actions WON’T add the tiles automatically to the list of active tiles. You will have to handpick the tiles yourself. It’s a shame as adding and removing tiles would be awesome!

Use the TaskerNet link (see bottom of the article) to import the project. Inside you will find 2 Profiles and 3 Tasks. The only thing that you have to do at this point is to create your tiles (sample tiles are included). I have included icons from icons8.com and the folder should be placed in the Tasker folder.

Unique Tiles

To create your own tiles, use a unique TileID for each tile, and the project is clever enough to figure out the rest. There is one bit of the information that is made for each tile in the setup process – the command field:

PowerMenu=:=button=:={"tileID":"button","title":"PC","subtitle":"Turned off","icon":{"on":"path","off":"path"},"range":{"min":0,"max":100,"step":1,"format":" "}}

Each part after =:= corresponds to:

  1. PowerMenu – command – don’t change this
  2. button – tile type, can be button|toggle|noAction|rangeToggle|range
  3. tileConfig – JSON formatted entry that contains tilte|subtitle|icon_path for on & off and range info for sliders

Tiles are quite limiting, so there is only so much information you can add to it.

  • Title – 17 characters
  • Subtitle 8 characters
  • Icon – icons/pictures etc

Two profiles in Tasker: PT Tile Update and PT Push Update handle communication with NodeRED server via Join app. Please check the Join action in the Task PT Push Update, to send the information to your Join instance in NodeRED.

Deep dive into NodeRED

I hate bashing on HA, but one of the reasons I love NodeRED is that things like this are possible if you are willing to put some thoughts into it. I love what Home Assistant does for DIY automation enthusiasts, but it lacks the degree of control I adore in NodeRED. If you would like to hone your NodeRED skills – here is a 7 part series that will ease you into NodeRED.

NodeRED accepts a Join push which contains tile information, command and extra variable which can be set through Tasker. This information is stored individually for each tile (based on tileID) and NodeRED syncs this information with NodeRED based dashboard and other phones. This way, you can control your smart home from any Android phone and see updates across all devices.

NodeRED setup

To create a “tile” you need to deploy a pair of processing nodes for each tile (Tile Type & Prep Response) these will ping the information back and forth between tiles, allowing you to use various Dashboard elements and Smart Home integrations in-between. Once the setup process is complete, activating the tile is as simple as using it once. The system will bind the tileID from Tasker to NodeRED and keep it for all interactions moving forward.

Tile Type

The node comes with 3 outputs. Each one is suited for different controls. To control your device, you have to determine what type of payload the device accept. For example, a smart lightbulb could use a range (number) for brightness and toggle (bool) for on and off settings, while a power plug would work best with a toggle (bool).

The same node is used for all tiles, so there is no need to change anything. You can customise the messages sent from that node, or add extra values if you wish. I tried to be descriptive in my code, so you can have an easier life, modifying it further.

Output 1

Suited for shortcuts, custom commands and updates. You can set any custom data assigned to variable %extra in Tasker. This could be a specific command or data set to display or process in NodeRED. The following information is sent over from Android tiles:

  • title
  • subtitle
  • extra data
msg.data = {"title": title, "subtitle": subtitle};
msg.extra = extra;

Output 2

Suited best for toggles. If something has ON|OFF states this is where you can get true|false output from tiles that support it. It carries the following information:

  • title
  • subtitle
  • toggle state
  • extra data
msg.payload = toggle;
msg.extra = extra;
msg.data = {"title": title, "subtitle": subtitle};

Output 3

Best suited for sliders and anything that requires numeric values. Sliders in Tasker can have custom ranges (0-10 or 1-100) and this output sends that as payload. It carries the following information

  • title
  • subtitle
  • range state
  • extra data
msg.payload = rangeCurrent;
msg.extra = extra;
msg.data = {"title": title, "subtitle": subtitle};

Note, that you can use output 2 & 3 together when using rangeToggle tile which supports both actions.

Prep response

This node requires a small setup. Visit Join API to get your API key for NodeRED Push config (tutorial) and list visit On Start tab to provide that info. The input should look like this:

///Visit https://joinjoaomgcd.appspot.com/ to get your Join API ID
//name devices here 
var sourceID = "Mi 11,Pixel 3";

//specify the tile 
var data = {"tileID": "button", "sourceID": sourceID }; 
context.set("lastTileID", data);

In this tile, you can also change the basic tile properties. By default, the tile will inherit the title and subtitle that it was set up with. You can change these based on your actions. If you want to set a different subtitle once a toggle is pressed, this tile allows you to modify this. See the node comments for more info.

This tile (with exception of the tileID) is also universal. An instance of this node will work with any tile type as long as you set the tileID correctly. In addition to that, the Prep node has the ability to accept true|false and numbers in msg.payload. The input is recognised automatically, and the tile is updated accordingly.

Bonus: noAction

No Action tiles cannot be updated in the same way. These don’t send information from Android phone but can be passively updated. I could add these into the Prep node, but it’s much easier to compose individual update nodes instead.

The below example shows how to turn the noAction tile into a sensor node. You can also create a timer that will cycle through different sensors displaying the temperature and humidity from all the sensors sequentially in your noAction tile

// if message is passing through, reverse the state to update the tasker tile
var date = new Date();
var tileType = "noAction";
var tileID = "noAction";
var title = "Office: T:" + Math.round(msg.payload.temperature) +"/H:"+ Math.round(msg.payload.humidity);
var subtitle = date.getHours() +":" +date.getMinutes();
var icon = "Tasker/icons/PowerMenu/temp.png";

var sourceID = "Mi 11,Pixel 3";
comm = "TileUpdate"+"=:="+ tileType +"=:="+ tileID +"=:="+ title +"=:="+ subtitle +"=:="+ icon;

msg.push = {"devices" : sourceID, "text": comm};

return msg;

Dashboard elements and DIY smart home

You can add elements in between both nodes. As long as the message is passed over from TileType to Prep Response node, it will all stay in 3 sync. If you check the example, controlling lights is as simple as linking the output stored in msg.payload to the node handling lights. Sometimes extra nodes may be required to translate the payload from true|false to ON|OFF or changing brightness from 0-100% to 0-255 value, but these are simple modifications included in the sample flow.

It’s not just dashboard elements that can be added to this flow. You can add smart speaker feedback from Alexa and Google Home so changes made via voice assistants are reflected in the Power Menu. I covered the use of Alexa in NodeRED and Google Home (via Smart Nora) so check these out too.

This tutorial won’t cover individual cases as there are no agreed standards between devices, so you will have to work out on your own how to like these. If you check my website you will find the most popular NodeRED integrations for IKEA, Aqara, Tuya, MiHome and many more. These will give you ideas on how to link the payloads from this tutorial with specific products.

Remote access and note on privacy

For all of you who would like to use the tiles remotely, forwarding port 1920 (can be customised in Join config) will fix that for you. Just bear in mind if you do so, Join will use Google’s GCM system to send messages and files through your own Google Drive account. Remote access no longer limits these messages to LAN, therefore bear that in mind if you are particularly sensitive to privacy settings.

Final Thoughts

With Join’s ability to send pushes locally, the system works without the internet after the initial setup, so you can sleep in peace knowing that no one is spying on you. I’m planning to add one more tile to the mix to show my 3D printer updates. You have probably seen the WIP version in the video. Let me know what other tiles would you like to see and I may consider a follow-up article handling the best ideas. Feel free to share yours in this Reddit thread.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?