Ir al contenido principal

Tasker: Profiles with priorities

Hi!

If you read Tasker docs, you may find that with Tasker its not possible to establish actions based on profile priorities if you have two of them activated at the same time; in the other hand Setting Profiles is a unmantained old app that can do this, but have no scripting capabilities like Tasker.

Here is the solution using Tasker powerful environment. The main idea is to do this:

Profiles/Init (44)
A1: If [ %Profiles_pactivelast Is Set & %Profiles_pactivelast !~ %PACTIVE ]
A2: Perform Task [ Name:Profiles/Profile/Default Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] 
A3: Variable Set [ Name:%profile_priority To:Work,Class,Study,Sleep,Low battery, Charging weak,Charging strong Do Maths:Off Append:Off ] 
A4: Variable Split [ Name:%profile_priority Splitter:, Delete Base:Off ] 
A5: For [ Variable:%profile Items:%profile_priority() ] 
A6: [X] Flash [ Text:%profile Long:Off ] 
A7: [X] Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] 
A8: If [ %PACTIVE ~R .*,%profile,.* ]
A9: Flash [ Text:Activo %profile Long:Off ] 
A10: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] 
A11: Perform Task [ Name:Profiles/Profile/%profile Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] 
A12: End If 
A13: End For 
A14: End If 
A15: Variable Set [ Name:%Profiles_pactivelast To:%PACTIVE Do Maths:Off Append:Off ] 

Then you may have several profiles with several conditions, and when any profile actives it will call to "Init" task, so when the are active, the %PACTIVE variable would list them. For example, I have 4 profiles (in priority order, from high to low):

Profiles/Profile/Charging weak (12)
A1: WiFi [ Set:On ] 

Profiles/Profile/Low battery (14)
A1: WiFi [ Set:Off ] 
A2: Vibrate On Ringer [ Set:Off ] 
A3: Auto Brightness [ Set:Off ] 
A4: Display Brightness [ Level:0 Disable Safeguard:Off Ignore Current Level:Off Immediate Effect:Off ] 
A5: Display Timeout [ Secs:15 Mins:0 Hours:0 ] 

Profiles/Profile/Sleep (7)
A1: Silent Mode [ Mode:On ] 
A2: Auto Brightness [ Set:Off ] 
A3: Display Brightness [ Level:0 Disable Safeguard:Off Ignore Current Level:Off Immediate Effect:Off ] 
A4: Display Timeout [ Secs:0 Mins:1 Hours:0 ] 
A5: Media Volume [ Level:2 Display:Off Sound:Off ] 

Profiles/Profile/Default (16)
A1: WiFi [ Set:On ] 
A2: Bluetooth [ Set:On ] 
A3: Silent Mode [ Mode:Off ] 
A4: Default Ringtone [ Type:Alarm Sound:Oxygen ] 
A5: Haptic Feedback [ Set:Off ] 
A6: Alarm Volume [ Level:7 Display:Off Sound:Off ] 
A7: BT Voice Volume [ Level:15 Display:Off Sound:Off ] 
A8: Media Volume [ Level:15 Display:Off Sound:Off ] 
A9: Notification Volume [ Level:7 Display:Off Sound:Off ] 
A10: Ringer Volume [ Level:7 Display:Off Sound:Off ] 
A11: System Volume [ Level:7 Display:Off Sound:Off ] 
A12: Notification Pulse [ Set:On ] 
A13: Display Rotation [ Set:On ] 
A14: Auto Brightness [ Set:On ] 
A15: Display Timeout [ Secs:30 Mins:0 Hours:0 ] 

Finally the Tasker conditions that activates them

Profile: Charging weak (41)
State: Power [ Source:USB ]
Enter: Profiles/Init (44)
Exit: Profiles/Init (44)

Profile: Low battery (39)
State: Battery Level [ From:0 To:20 ]
State: Not Power [ Source:Any ]
Enter: Profiles/Init (44)
Exit: Profiles/Init (44)

Profile: Sleep (6)
State: Calendar Entry [ Title:Dormir* Location:* Description:* Available:Any Calendar:Google:[Sched]Borja ]
Enter: Profiles/Init (44)
Exit: Profiles/Init (44)



Comentarios

Entradas populares de este blog

Use rclone to mount cloud storage

I realized that the fat clients that allows you to sync your contents are not only wasting CPU cycles but also lots of disk space. Yes, that enables you to have the file opened almost instantly, no matter its size, but for me that use case is almost never needed, I use the cloud storage to save stuff that is in the range of a few MiB. Here is where rclone comes into play, it allows you to mount your storage as if it were a regular disk, and it handles the communication with the cloud servers on the go. As there are many different combinations I'll cover only two Linux w/ Dropbox curl https://rclone.org/install.sh | bash # Use rclone config to add a new remote called db for dropbox MAIN_USER=$SUDO_USER MAIN_USER_HOME=$(grep ^$SUDO_USER: /etc/passwd | head -1 | cut -d: -f6) mkdir /media/db chown $MAIN_USER:$MAIN_USER /media/db cat <<EOF > /lib/systemd/system/rclone-db.service [Unit] Description=Dropbox rclone mount After=multi-user.targetrclone [Service] Type=simple User=$ M...