Automating Blokada's behaviour with Tasker

One of the most requested features in Blokada is a Tasker integration. Both Blokada 4 and Blokada 5 support Tasker integration.

Tasker with Blokada 4

Starting with Blokada 4.3, it was shipped and you can control the following:

  • Turn on/off Blokada
  • Enable/disable the set DNS server in Blokada
  • Enable/disable Blokada Plus

You can automate the above things with anything that Tasker is capable to do. In my example below, I’ll turn off the DNS when I connect to my home network:

  1. In Blokada’s menu - DNS I enable one of the 3rd party DNS servers
  2. Then, open Tasker, I go to PROFILES , there tap on the + sign in the bottom right corner to create a new profile
  3. Give it a name
  4. I choose State , there Net , there Wifi Connected
  5. I choose my home’s SSID and save this profile
  6. Then Tasker gives me the option to choose one already existing task or I can create a new one. I choose New Task , give it a name
  7. Choose the + sign in the bottom right corner to add a new action
  8. Choose Plugin , there choose Blokada
  9. We arrive to the Configuration screen. Tap on the pencil in the top right corner
  10. Because I want to disable the set DNS server, I choose Blokada DNS . Notice that it is a switch. If it’s orange, that enables the DNS feature, if it is grey, it disables. On the Configuration screen you should see DNS - Turn off
  11. Save this task, go back to Tasker’s main screen and tap on the check mark in the top right corner

Note that Tasker’s default behaviour is that when the profile’s inverse is true (in this case you aren’t connected to your home wifi) the previous state will be restored (3rd party DNS server will be enabled).

The same way you can enable Blokada Plus if you are connected to a given network, you can turn off Blokada if a given application is running.

Tasker with Blokada 5

Starting with Blokada 5.16, Tasker integration is available. Here we have taken different approach that should be more future proof. This integration allows you to configure a command that Blokada should execute on a given Tasker action.

You simply need to enter the command to execute.

Commands

  • on - Turns Blokada on. This is equivalent to tapping the power button in the app, meaning Blokada will configure in your latest configuration (ie if Blokada Plus was activated, it will activate also).
  • off - Turns Blokada off. This is equivalent to tapping the power button in the app.

More commands will be added in future versions.

6 Likes

Blokada does not show in tasker 3rd party or Plugins,… running latest beta

This is currently not present in version 5.

I have Blokada 5.16 installed and I can’t seem to get this to work. I was able to set up the tasks and I can see that they are firing. I’m even getting a toast telling me that Blokada is turning on or off. However, it never actually changes state. Is there another setting that I’m missing?

No, that should be it. Are your commands correct? Try checking what you see in Blokada log after firing the command. There should be a confirmation that the event was received and that the command has been recognized.

I’m having the same issue as Rabbid10, sometimes it does work and sometimes it no longer works through tasker.

I’ve uploaded my logs here (hopefully with all sensitive/irrelevant information removed).

It seems that Blokada receives the input from Tasker but does nothing with it sometimes.

Please try to activate Keep Alive (Settings → This device), and let me know if the behavior changes.

I already had Keep Alive enabled, even re-enabling it doesn’t fix it.

This is the same for me.

I can get it to work by having Tasker launch the Blokada app, wait a second, send the command, and then press “back”, but it’s kind of jarring to have the app pop up every time I want to change the status…

1 Like

What other tasker setups you guys use (which apps), and if they work fine for you?

Same Problem for me, in the log I can see that blokada received the command:
TaskerRece Executing command from Tasker: on
But nothing happened…
Other apps like openhab work fine.

1 Like

I forgot… Galaxy S20 FE 5g with android 11

1 Like

After update to 5.18, issue still exists.

Samsung S20FE Android 11, last Update.

Any Ideas?

Same issue here

Same issue on Oneplus 7 with Android 11

And still the same problem here.
It works if I have task open in tasker open or if Blokada is open and run the task.
If neither app is open in front of me, I run the task from QS tile, it doesn’t work.

Any solutions?

I downgrade to version 4 and it is working fine. Waiting for a fix to update back.

I found a solution, everyone. Tasker has an activity service that you should/must run before running the actual tasker blokada action. This activity is known as commandactivity; when in launching app section for the task, long click tasker to select the commandactivity task. Running this activity prior to the blokada tasker on/off command GUARANTEES that blokada will be turned off or on. If more information is required to set this up, simply ask.

3 Likes

You may want to disable Blokada’s notifications to hide the annoying toasts everytime the blokada task is run.^

2 Likes

First tests were successful. Thanks for the tip

1 Like