Volume change trigger

605 views
Skip to first unread message

AJ Puzon

unread,
Jul 23, 2017, 7:59:04 AM7/23/17
to Tasker
Is there any way to monitor Volume changes via tasker or by a plugin?

Sean Williams

unread,
Jul 23, 2017, 8:16:19 AM7/23/17
to Tasker
Is there any way to monitor Volume changes via tasker or by a plugin?

Yes, several depending on what you want to achieve.

Use a profile Event 'Variable Set' on one of the many global volume variables such as, volume - system '%VOLS'.

Take a look at the variables page of the user guide for more info.

Thom Little

unread,
Jul 23, 2017, 1:50:29 PM7/23/17
to Tasker

(1) Triggering by volume variable change is an interesting idea.  There are some limitations …

 

%VOLA does not trigger

%VOLC does not trigger

%VOLM trigger with change by 1

%VOLD trigger with change greater than 1

%VOLN trigger with change by 1

%VOLR trigger with change by 1

%VOLS trigger with change by 1

 

The seven profiles to trigger …

Profile: VolA (532)
Event: Variable Set [ Variable:%VOLA Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolC (536)
Event: Variable Set [ Variable:%VOLC Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolD (538)
Event: Variable Set [ Variable:%VOLD Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolM (537)
Event: Variable Set [ Variable:%VOLM Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolN (539)
Event: Variable Set [ Variable:%VOLN Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolR (540)
Event: Variable Set [ Variable:%VOLR Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

Profile: VolS (531)
Event: Variable Set [ Variable:%VOLS Value:* User Variables Only:Off ]
Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]

(2) It would be great if I could combine them all into a single profile.

 

… Thom

Sean Williams

unread,
Jul 23, 2017, 2:27:41 PM7/23/17
to Tasker
Hi Thom,

(2) It would be great if I could combine them all into a single profile.

You probably could with an Intent Received, Event.

android.media.VOLUME_CHANGED_ACTION

Thom Little

unread,
Jul 23, 2017, 2:57:21 PM7/23/17
to Tasker
That worked liked a champ.

The three restrictions I documented from the other approach are not present in this approach.  (Another "feature" Pent?)  The profile ...

Profile: VolAll (549)
Event: Intent Received [ Action:android.media.VOLUME_CHANGED_ACTION Cat:None Cat:None Scheme:* Mime Type:* ]


Enter: VolAll (533)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Flash [ Text:a%VOLA c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]


... Thom

Thom Little

unread,
Jul 23, 2017, 10:22:32 PM7/23/17
to Tasker
In the first method there is no way to trigger a BTvoice change because there is no global variable.

In the Intent method a BTvoice change triggers.

... Thom


Sean Williams

unread,
Jul 24, 2017, 1:17:05 PM7/24/17
to Tasker
In the first method there is no way to trigger a BTvoice change because there is no global variable.

In the Intent method a BTvoice change triggers.


BT appears not to be documented.

Use the extras to create your own,

IF, %android_media_extra_volume_stream_type_alias = 6

Var Set, %VOLBT - %android_media_extra_volume_stream_value

Thom Little

unread,
Jul 24, 2017, 2:19:22 PM7/24/17
to Tasker
You have really caught my attention.  I have used intents very little up until now and do not quite understand what you are telling me or what is written in the user guide.

What I would love to have is a variable %VOLBT that contained the value of BT Voice Volume.

Dev2 (217)
A1: If [ %android_media_extra_volume_stream_type_alias eq 6 ]
A2: Variable Set [ Name:%VOLBT To:%android_media_extra_volume_stream_value Recurse Variables:Off Do Maths:Off Append:Off ]
A3: End If
A4: Flash [ Text:%VOLBT Long:Off ]

... Thom

Sean Williams

unread,
Jul 24, 2017, 4:26:20 PM7/24/17
to Tasker
You have really caught my attention. I have used intents very little up until now and do not quite understand what you are telling me or what is written in the user guide.

Sorry. I was referring to androids developer docs.

BT stream isn't documented.


What I would love to have is a variable %VOLBT that contained the value of BT Voice Volume.

Dev2 (217)
A1: If [ %android_media_extra_volume_stream_type_alias eq 6 ]
A2: Variable Set [ Name:%VOLBT To:%android_media_extra_volume_stream_value Recurse Variables:Off Do Maths:Off Append:Off ]
A3: End If
A4: Flash [ Text:%VOLBT Long:Off ]

That task attached to the previously created 'intent' profile should allow you to monitor the BT stream.

Thom Little

unread,
Jul 24, 2017, 8:36:36 PM7/24/17
to Tasker

The following is a profile to set it and a test task to manipulate it.  There are two remaining challenges …

 

It has to be run once to finalize the global variable with the correct value.

There is a half second wait before the Flash.  Without it the Flash was executing before %VOLB as set.

 

Profile: VOLB


Event: Intent Received [ Action:android.media.VOLUME_CHANGED_ACTION Cat:None Cat:None Scheme:* Mime Type:* ]

Enter: Anon
A1: Variable Set [ Name:%VOLB To:%android_media_extra_volume_stream_value Recurse Variables:Off Do Maths:Off Append:Off ] If [ %android_media_extra_volume_stream_type_alias eq 6 ]

 

Test

A1: Alarm Volume [ Level:7 Display:Off Sound:Off ]
A2: BT Voice Volume [ Level:15 Display:Off Sound:Off ]
A3: In-Call Volume [ Level:8 Display:Off Sound:Off ]
A4: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A5: Variable Set [ Name:%VOLB To:?  Recurse Variables:Off Do Maths:Off Append:Off ] If [ %VOLB !Set ]
A6: Flash [ Text:a%VOLA b%VOLB c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:On ]

… Thom

Sean Williams

unread,
Jul 25, 2017, 2:38:06 PM7/25/17
to Tasker
Hi Thom,

It has to be run once to finalize the global variable with the correct value.

Why bother to initiate the variable it will be set when a corresponding event occurs?

Thom Little

unread,
Jul 25, 2017, 7:26:18 PM7/25/17
to Tasker
I was trying to create a real %VOLB.  I would like to report the current value as the first reference.

I use the following a lot ...
A1: Flash [ Text:a%VOLA b%VOLB c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]
... and would like to use it before the user sets %VOLB.


... Thom

Thom Little

unread,
Jul 25, 2017, 10:56:08 PM7/25/17
to Tasker
Is there a way to fake it out?  If uninitialized do something like set one of the other volumes with a value that it already has and then access the value for %VOLB?

I'm still a newbie in this area and experimentation  didn't turn anything up.

.... Thom

Sean Williams

unread,
Jul 26, 2017, 7:11:07 AM7/26/17
to Tasker
I use the following a lot ...
A1: Flash [ Text:a%VOLA b%VOLB c%VOLC m%VOLM • d%VOLD n%VOLN r%VOLR s%VOLS Long:Off ]
... and would like to use it before the user sets %VOLB.


If you're displaying the current value you shouldn't rely on the intent instead check what the actual value is.


Java actions,

Ret, audiomgr Class,AudioManager Function, new Par, CONTEXT

Ret, %VOLB Class,audiomgr Function, getStreamVolume Par, 6

Thom Little

unread,
Jul 26, 2017, 10:32:31 AM7/26/17
to Tasker
My first time on this path ... ever.  Any help would be greatly appreciated.  The following fails ...

getVOLB
A1: JavaScriptlet [ Code:Ret, %VOLB Class, audiomgr Function, getStreamVolume Par, 6 Libraries: Auto Exit:On Timeout (Seconds):45 ]
A2: Flash [ Text:%VOLB Long:Off ]


... Thom

Sean Williams

unread,
Jul 26, 2017, 11:20:00 AM7/26/17
to Tasker
Hi Thom,

My first time on this path ... ever. Any help would be greatly appreciated. The following fails ...

You'll need to use Java (not JavaScript).

See below,

Audio BT (610)
A1: Java Function [ Return:audiomgr Class Or Object:AudioManager Function:new
{AudioManager} (Context) Param:CONTEXT Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:%VOLB Class Or Object:audiomgr Function:getStreamVolume
{int} (int) Param:6 Param: Param: Param: Param: Param: Param: ]
A3: Flash [ Text:%VOLB Long:Off ]

Thom Little

unread,
Jul 26, 2017, 1:19:26 PM7/26/17
to Tasker
Never been here before ...

In Code / Java Function / Function I entered ...

[ Return:audiomgr Class Or Object:AudioManager Function:new
{AudioManager} (Context) Param:CONTEXT Param: Param: Param: Param: Param: Param: ]

... and when I clicked the back arrow it gave the error ...

Function: Invalid value

... Thom

Sean Williams

unread,
Jul 26, 2017, 2:54:16 PM7/26/17
to Tasker
You could try using the magnifying glass and or coffee cup to populate the fields.

Also create another Java function for Action 2.

Thom Little

unread,
Jul 26, 2017, 3:38:44 PM7/26/17
to Tasker
I got it working.

As the first ever function I can testify that data entry is obscure.

Thanks for the help.

Reporting on 8 instead of 7 volume levels is more complete.  Perhaps Pent will consider adding %VOLB.

Thanks again.

... Thom


On Wednesday, July 26, 2017 at 2:54:16 PM UTC-4, Sean Williams wrote:
Reply all
Reply to author
Forward
0 new messages