Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varmqtttopic assistance with tasker #84

Open
DarkStorm99 opened this issue Nov 17, 2020 · 4 comments
Open

Varmqtttopic assistance with tasker #84

DarkStorm99 opened this issue Nov 17, 2020 · 4 comments

Comments

@DarkStorm99
Copy link

At the moment I am trying to use this app with tasker so that when motion is detected, an android tablet unlocks. When there is no motion, the android tablet locks.

This app has a lot of potential but I am struggling with the tasker configuration.

I am subscribed to a topic: home/input/livingpir_detection
This has 2 messages:
"detected" if motion has been detected
"clear" if no motion has been detected for 5 minutes.

I was wanting to make it so if the message is received as "detected", the screen unlocks. If the message is "clear", the screen locks through tasker.

In the plugin for the "Clear" event I have set up, it is as follows:
topic: home/input/livingpir_detection
varmessage: clear

It would appear that varmqtttopic is compulsory. So I have tried putting in "clear" into this box.

In the plugin for the "detected" event I have set up, it is as follows:
topic: home/input/livingpir_detection
varmessage: detected
varmqtttopic: detected

Unfortunately both tasker profiles trigger, when any message is received, not explicitly the one I put into varmessage. I suspect the varmqtttopic is causing issues, or I am doing something completely wrong here.

Can someone point me in the right direction? Thanks

@crowbarz
Copy link

crowbarz commented Nov 17, 2020

I believe varmqtttopic and varmessage are the Tasker variable names that the MQTT topic and payload are respectively set to when a message with the selected MQTT topic is received and a Tasker task is executed. In my Tasker task, I have conditional actions that depend on the contents of the message in the variable name that is specified in varmessage, eg. to turn on/off the screen.

So for example if you set varmessage to the value mqttpayload, then set your Tasker task to check %mqttpayload for the MQTT payload and act accordingly.

I don't use varmqtttopic in my setup as I have different Tasker tasks associated with different MQTT topics, but I guess it may be useful if you are using wildcard topic subscriptions.

@tireks
Copy link

tireks commented Jul 13, 2021

I don't use varmqtttopic in my setup as I have different Tasker tasks associated with different MQTT topics, but I guess it may be useful if you are using wildcard topic subscriptions.

Can you explain pls? When setting up event, if leaving varmqttopic's field blank, i'm getting an error : invalid topic variable. How you "dont use varmqttopic"?

@crowbarz
Copy link

crowbarz commented Jul 13, 2021

Yes, you need to put some Tasker variable names in the varmqtttopic and varmqttmessage fields when you set the event up, but my point is that you don't have to actually use those Tasker variables anywhere in the task that is executed. For example, varmqtttopic isn't very useful when wildcards (# or +) are not used in a subscription - the referenced Tasker variable will always be set to the subscribed topic.

Here's how MQTT Client and Tasker are generally set up on my device:

In MQTT Client:

  1. Set up broker as required
  2. Tap on the broker. On the received messages screen, subscribe to the topic(s) that you want Tasker to respond to.

In Tasker:

  1. In Profiles, add Event > Plugin > MQTT Client > Message Arrived
  2. Tap pencil icon to add MQTT Client configuration.
  3. Select one of the topics that you subscribed to previously in MQTT Client - this profile will be triggered whenever a message on that topic is received
  4. For varmessage enter mqttaction, and for varmqtttopic enter mqtttopic
  5. Add a task with some actions. In your actions, you can refer to Tasker variable %mqtttopic to use the topic received in the MQTT message, and %mqttaction for the payload. You could for example test the value of %mqtttopic in an if action.

@tireks
Copy link

tireks commented Jul 14, 2021

oh, awesome, thx for such a detailed answer! i've used instructions from here, so i thought, that it's neccessary using varmqtttopic in tasks' if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants