[SOLVED] Change local variables from notification's Action Button

anonymous_

New member
I don't think there's an option to modify local variables from notification's action button. As you can see here, the only thing I can run from here is macros and Action Blocks. I could easily change the behavior of triggers by changing the local variables from notification. It would be much much better if there was an option to modify the local variables from here,
Screenshot_20220630-014556_MacroDroid.png
 

RSF

Well-known member
Create an action block that simply takes its input variable and assigns it to its output variable:
Screenshot 2022-06-29 2.23.04 PM.png

Then configure the button to call that Action Block, and pass whatever you want to set your local variable to, as its input parameter; and the local variable, as its output parameter:
Screenshot 2022-06-29 2.26.32 PM.png

Screenshot 2022-06-29 2.27.04 PM.png
 

anonymous_

New member
Create an action block that simply takes its input variable and assigns it to its output variable:
View attachment 2962

Then configure the button to call that Action Block, and pass whatever you want to set your local variable to, as its input parameter; and the local variable, as its output parameter:
View attachment 2964

View attachment 2967
I did what you've said but it's not working. First to test it, I made a test macro that will display a dialog if a local variable has changed. Here's the photo of this macro,
Screenshot_20220705-121120_Trebuchet.png
To get a notification using which I can change the local variable, I set a application launched trigger. The notification I have set is this,
Screenshot_20220705-121501_Trebuchet.png
Configure input/output is,
Screenshot_20220705-121755_Trebuchet.png
The local variable by default is set to true,
Screenshot_20220705-121810_Trebuchet.png
The action block is this,



Screenshot_20220705-121613_Trebuchet.png
Now in the notification when I press change variable, a dialog box should appear, but it doesn't appear. Though it appears if I change the local variable manually by editing that specific macro. Later on I have set a vibration to check if it's working and not showing, but the vibration didn't happen.
 

RSF

Well-known member
The action block looks fine. I suspect the issue may be in the Display Notification action. Does it have two action buttons, each of which invokes the action block, with parameters set like below (one button setting to true and the other set to false)?

Screenshot_20220705-091024.png

Screenshot_20220705-091031.png
 

anonymous_

New member
I've told you, it takes an boolean input and outputs the same thing. In here it takes true/false and assigns it to the local variable. I did exactly what you have told me the first time.
 

RSF

Well-known member
If there's only one Action Button, it can take and set only one value, either true or false.
Can you post a screen shot of the Action Button configuration, or post the .macro file?
 

anonymous_

New member
Yeah I think you'll understand better if I send you the macro. Here it is,
 

Attachments

  • test.macro
    3.8 KB · Views: 6

RSF

Well-known member
The Notification's button is configured to do nothing -- it was set to "(Button off)" (see highlight below):
Screenshot 2022-07-07 4.01.46 PM.png
Therefore, pressing it won't do anything.

In any case, to have the button set your variable to e.g. False:
  1. Change the Run when pressed dropdown to point to your action block "Returns boolean output (out=in)"
  2. Then tap Configure input/output params, and put False for in and Test Variable for out (as you had in your earlier screenshot)
If you're actually looking to switch the value of the variable from True to False and back, each time the button is pressed, then:
  1. Create a new action block, called "Returns boolean output (out= NOT in)". It'll be the same as your existing action block, but with an added Set Variable action at the end, to invert the value before returning it to your macro:
    Screenshot_20220707-160041.png
  2. Back in the macro, configure the notification action, and change the Run when pressed dropdown to point to that new action block
  3. Then tap Configure input/output params, put (Local) Test variable for in and Test Variable for out
Attached is a macro that does the second scheme (it switches the value from true to false and back each time the button is pressed). Note that I don't have Sudoku, so it looks for the "Clock" app to be launched; you'd want to change that.
 

Attachments

  • Tst2.macro
    5 KB · Views: 7

anonymous_

New member
Actually what happens is, when you send a macro, by default button sets itself to off. The macro you sent me, I've imported it and the button was off. So importing a macro basically sets button to off. I have actually set an action block that is configured to set to false (actually don't want to set the opposite cause I want to do something different) but it doesn't really work. Take a look at this screen recording.
I don't know why it's not working. You can literally see that the local variable didn't change.
 

Attachments

  • Screenshot_20220708-002629_Trebuchet.png
    Screenshot_20220708-002629_Trebuchet.png
    2.4 MB · Views: 8

RSF

Well-known member
Ah. Didn't know that importing a macro would change its Notification actions to remove their button tap behaviors. That's not helpful. Perhaps similarly, the screen recording is just a single screenshot of your home screen -- not a multi-step recording.

In any case, if you're saying that
  • the variable is True when you display the notification, and
  • you tap the notification's button and
  • it stays True vs. getting set to False, even though
  • you've got the button configured to send False to the action block (and thus the local variable) ...
I have no idea; it works for me. Sorry I can't see what's not working.
 

MacroDroidDev

Administrator
Staff member
That macro export does not seem to have exported the referenced action block along with it. I'm guessing the fact that it's referenced by the notification action is not being correctly identified and therefore it's not being bundled with the macro correctly.

I tried to recreate the above issue by creating my own action block and everything seems to be working for me I'm afraid.
 

anonymous_

New member
Ok, I probably misclicked hence it just sent a screenshot lol.
I think the issue I had was in the ROM I was using. I flashed another ROM yesterday and set everything up. Suddenly this thread came up in my mind then I went ahead and tried everything from the beginning. It's working. When I click the notification action button it changes my arbitrary local variable to true/false. Sorry for the complication. I did the exact thing I did today before. I wonder why that didn't work back then. So I highly suspect it was for the custom ROM that I was using.
Again, sorry for the inconvenience, and thanks for helping me out.
 
Top