What am I doing wrong? Variable woes

kaz984

New member
I have one macro that plays rain music while I sleep (rain macro). Then I have another macro to wake up, that plays an alarm sound (wake up macro). I created a global variable WakeUpRunning set to false. So when wake up macro is triggered, first action is set value of variable WakeUpRunning as true.

Then rain macro has a constraint to only run if variable WakeUpRunning is false, which works fine. But, it has a trigger that if WakeUpRunning has any change, then to stop sounds. But it does not work, when wake up macro triggers, the two sounds continue at the same time and is driving me bonkers.

In rain macro I changed the WakeUpRunning trigger to be true and then to stop sounds, but it does not work either. I tried inverting false and true and does not work either.

What am I doing wrong?
 

Attachments

  • Screenshot_20240331-090804.jpg
    Screenshot_20240331-090804.jpg
    211.7 KB · Views: 8
  • Screenshot_20240331-090730.jpg
    Screenshot_20240331-090730.jpg
    218.2 KB · Views: 9

dhj49er

Well-known member
The reason it fails is the constraint wakeuprunning false prevents rain macro running when the variable changes to true.

I suggest you ditch the wakeuprunning variable and instead have a rainrunning variable.

In rain macro add

A set rainrunning true

Then in the wakeup macro add a check

A If rainrunning is true
A Stop sounds
A set rainrunning false
A End if
 

Dm114

Well-known member
I have one macro that plays rain music while I sleep (rain macro). Then I have another macro to wake up, that plays an alarm sound (wake up macro). I created a global variable WakeUpRunning set to false. So when wake up macro is triggered, first action is set value of variable WakeUpRunning as true.

Then rain macro has a constraint to only run if variable WakeUpRunning is false, which works fine. But, it has a trigger that if WakeUpRunning has any change, then to stop sounds. But it does not work, when wake up macro triggers, the two sounds continue at the same time and is driving me bonkers.

In rain macro I changed the WakeUpRunning trigger to be true and then to stop sounds, but it does not work either. I tried inverting false and true and does not work either.

What am I doing wrong?
Your problem seems simple enough and well explained but there are some things I don't really understand.

You run "Rain" macro by clicking on the.Blue MD button if "Wake up" macro is not running (the general constraint) so you need the Blue button trigger and the MacroDroid variable change firing when global variable WakeUpRunning is True. You don't need the Airplane mode trigger : it's an action you will run inside the macro.

When WakeUpRunning trigger fires just Stop music playing and Cancel macro

When "Wakeup macro" runs Wait 1 second or 2 after setting WakeUpRunning toTrue (to let Rain macro stop music)
 

kaz984

New member
The reason it fails is the constraint wakeuprunning false prevents rain macro running when the variable changes to true.

I suggest you ditch the wakeuprunning variable and instead have a rainrunning variable.

In rain macro add

A set rainrunning true

Then in the wakeup macro add a check

A If rainrunning is true
A Stop sounds
A set rainrunning false
A End if
Wow, it worked! thanks soooo much!! 🌷💖
 
Top