Tasker if connected to bluetooth

Tasker: Start and play Spotify when connected to bluetooth

When going motorcycling, or just generally commuting by motorcycle, I often want to have some tunes playing in the helmet. Since I have a Cardo Scala G4 bluetooth intercom installed on my helmets, it’s a given to use that to play Spotify while riding. To be able to do this, is actually why I got Tasker in the first place. I have since branched out a lot and automated a lot of stuff, but that’s another article coming. My base for this Tasker project is outlined at http://richardpeacock.com/blog/2015/09/make-spotify-start-playing-over-bluetooth-when-you-get-your-car-or-any-other-bt-device-.
After having followed Mr Peacock’s excellent guide I was quite happy for a long time, until something in Spotify or Android changed, and the music didn’t auto-play on BT-connection anymore.
Further trouble-shooting was needed, and I did find a solution. These tweaks are noted inline in the Guide-part. Tasker strictly speaking does not need root access. If you however want to delve deeper with automation and Tasker on Android devices, you may want to investigate rooting! Note! This guide uses a Cardo intercom unit, but any bluetooth enabled intercom should work. This also includes bluetooth-enabled car media systems.

Assumptions

I’m going to assume the reader is fairly accustomed to working with Tasker. If you, the reader, runs into any problems, please search the ‘net for solutions or just ask below in the comments field. I’ll do what I can to help.

Hard- and software list

Rooted and using SuperSU.
http://www.supersu.com/ TWRP v3 recovery installed.
https://twrp.me/

Got a new phone from work again, replacing the previous. This time it was a OnePlus 8 Pro with 8 GB internal RAM and 128 GB externally.
Importing the Tasker tasks, profiles etc to the new phone was a breeze and all tasks and profiles work as is on the Oneplus. Samsung Galaxy S9 64 GB
https://www.gsmarena.com/samsung_galaxy_s9-8966.php Android 9 Pie
https://en.wikipedia.org/wiki/Android_Pie OnePlus 8 Pro 128GB/8GB
https://www.gsmarena.com/oneplus_8_pro-9919.php Android 11
https://en.wikipedia.org/wiki/Android_11 OxygenOS 11
https://en.wikipedia.org/wiki/OxygenOS Latest Spotify app installed.
https://www.spotify.com/
https://play.google.com/store/apps/details?id=com.spotify.music Latest Tasker app installed. Please buy it and support the dev! The app is well worth it.
https://tasker.joaoapps.com/
https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en Cardo Scala G4 Teamset
https://www.cardosystems.com/support/g4/

Guide

In which we will make the android device connect to the intercom over bluetooth, when the android device detects the intercom is switched on, and then starts the Spotify app.

Make your mobile device and the intercom talk to each other

Pair your mobile phone and Cardo unit and make it works properly. Instructions for pairing a Cardo Scala G4 Teamset unit is available on page 9 at https://www.cardosystems.com/wp-content/uploads/guides/manual/en/g4.pdf.

Create the Tasker profile

  1. In Profiles tab, press +.
  2. Select State.
  3. Select Net.
  4. Select BT Connected.
  5. Press the magnifier icon next to Name and select which BT-unit you want to trigger the connection with.
  6. Press the magnifier icon next to Address and select the same device as above.
  7. Back out to the Profiles tab and confirm the creation of the new task. Name it if you want to, preferrably something meaningful like «BT Connected Start Play Spotify» or some such.
Читайте также:  Elm327 vgate scan obd2 bluetooth

Launching Spotify

In which we edit the previously created task to launch Spotify.

  1. In Profiles tab, press +.
  2. Select App.
  3. Select Launch app.
  4. Select Spotify.
  5. Back out to the Profiles tab.

Pause a short while Spotify gets its things together

In which we add a wait-timer.

  1. In Profiles tab, press +.
  2. Select Task category.
  3. Select Wait.
  4. Set Seconds to ten. The referenced guides show five, but ten is what my OPO needed to fire things up.
  5. Back out to the Profiles tab.

Adjust media volume

In which we max out the mobile device media volume in order to not cap the intercom volume.

Note! Remember that loud sounds may damage your hearing irrevocably!

  1. In Profiles tab, press +.
  2. Select Audio.
  3. Select Media Volume.
  4. Select Level to set the volume to max. Use your discretion here. My OPO is maxed out at «14».
  5. Back out to the Profiles tab.

Making stuff happen!

In which we add the automagics to the task, in other words «press play already!».

  1. In Profiles tab, press +.
  2. Press System.
  3. Press Send Intent.
  4. Edit the following fields. Be sure to write exactly as stated below. No spaces, upper case etc!
    1. Action: com.spotify.mobile.android.ui.widget.PLAY
    2. Cat: None
    3. Package: com.spotify.music
    4. Target: Broadcast Receiver

    Testing

    Turn off your Cardo, then turn it on again.

    It should connect to your mobile device over bluetooth and launch the Spotify app after the set pause.

    Which then leads us to the next chapter — troubleshooting the infernal device.

    Troubleshooting why Spotify doesn’t start playing

    So, Spotify launched as expected but nothing happened afterwards. It just sits there. Woe of woes!

    Step 1

    Long-press the Cardo unit’s A-button (front, side) to toggle the play/pause function. You should hear a too-whit! If you hear a too-whuut! it’s now paused.

    Long-press it again to make sure no funny business is going on.

    Still nothing? Proceed to step 2.

    Step 2

    Search the web for the problem. For the honoured reader’s convenience, here is a possible solution.

    This particular solution will sadly always skip forward one track, but it does work. Call it a workaround!

    Go back to the task called Making stuff happen. Edit and replace PLAY with NEXT instead.
    Note! Only change PLAY with NEXT, leave everything else unchanged.

    1. In Profiles tab, press the task that launches Spotify.
    2. Edit the following field
      1. Edit Action: com.spotify.mobile.android.ui.widget.PLAY
      2. Replace with Action: com.spotify.mobile.android.ui.widget.NEXT

      Still nothing? Proceed to step 3.

      Step 3

      This is a bonus step. I got my task working in step 2!

      Search the web some more for the problem. For the honoured reader’s convenience, here is a another possible solution.

      Replace the above play action in step 2 with this.

      1. In Profiles tab, press +.
      2. Select Media.
      3. Select Media Control.
      4. Select Play (simulated only).
      5. Set App as Spotify.
      6. Back out to the Profiles tab.
      7. Press the check-mark on the main page to commit the changes.

      Turn off your Cardo yet again and then on again to see if Spotify starts playing now.

      I actually did try this last solution too, just for fun. It started playing the last media file played by the default Android media player, in my case the ring tone.

      Kinda’ worked though, just not quite as expected; YMMV.

      Conclusion

      If everything worked out, you’re now ready to go out and try it for real.

      Источник

      Bluetooth Connection Event

      I realized that there was no easy way to check what device had just connected/disconnected from your phone via BT, so I created this event.

      You’ll get a bunch of variables back with the info about the device, like device name, mac address, type (classic, LE), class (audio, computer, peripheral, etc) and more!

      Here’s a demo for that: https://www.youtube.com/watch?v=HmcNmtJvSvw

      Full Changelog

      • Added Bluetooth Connection event: triggers when a BT device is connected/disconnected; sets local variables for the device;
      • Added Bluetooth Connection action: connect or disconnect to a BT device at will
      • Added «Ignore Unlaunchable Apps» option to App Info action
      • Added «enabled» to App Info
      • Added «Trust Any Certificate» option in HTTP Request action
      • Added Usage Stats permission request to App Changed event
      • Fixed not being able to post a body with HTTP Request action
      • Fix some issues with HTTP Auth
      • Fixed Allow All and Deny All in Network Access action
      • Fixed issue where sometimes task or profile list would be blank until Tasker was restarted
      • Fixed crash when showing task list on some devices
      • Made some wrong error messages disapear from the Tasker log
      • Try to not crash on Android 7.1 sometimes when showing toasts

      Enjoy and let me know how it works! 🙂

      Источник

      Tasker if connected to bluetooth

      UPDATE: this is resolved, with help from the developer
      The problem is that when you rename your bluetooth devices in phone > settings > bluetooth, that «name» you give it is not visible to Tasker. Tasker can only see the «factory» name of the device (which is no longer visible to you in your phone settings, after you rename it). But you can work around this. When setting up your tasker profile, don’t manually enter the bluetooth device name. Rather, use the magnifying glass icon, and choose the bluetooth device from the list. In the list, you’ll notice the factory names for your paired devices, not your custom labels.

      I have a Profile that is triggered when a certain device connects to my phone via bluetooth. This Profile has worked very well for a very long time.

      Recently the Profile is failing. Tasker doesn’t seem to recognize that the bluetooth device has connected, and it doesn’t trigger the task. I think this may have started with the recent Tasker update (I’m now running version 5.11.14).

      Anyone have insights, or solutions?

      — I have checked the name of the bluetooth device in my profile.- I have tried using a different bluetooth device in the same profile.- I have tried setting up test Profiles using either BT connected *event* or BT connected *state*, neither one works- I have tested the Tasks manually, and they still work.- I have rebooted phone- Tasker status in the windowshade says «no active profiles» even though BT device is connected

      I’m running Android, fully updated, on a Pixel XL.

      My other Profiles and Tasks seem fine.

      Источник

      Как использовать Tasker для автоматизации Bluetooth-соединений

      Если вы хотите подключиться и отключиться от устройства Bluetooth, обычно проще всего выключить устройство Bluetooth, но это легче сказать, чем сделать для некоторых устройств Bluetooth, таких как приемники аудио-видео с поддержкой Bluetooth и Прицел Bluetooth адаптеры. Для этого вам обычно нужно зайти в настройки и вручную отключиться. К счастью, Tasker , удобный плагин и хороший лаунчер позволяют легко подключаться и отключаться.

      Сегодня мы собираемся воспользоваться множеством плагинов Tasker, используя Bluetooth Auto Connect для фактического подключения и отключения устройств Bluetooth, поэтому загрузите его и сам Tasker, прежде чем мы начнем.

      1. Открыть Tasker
      2. На вкладке Задачи нажмите + в правом нижнем углу.
      3. Назовите свою задачу и нажмите галочку . Открыть TaskerНовое заданиеНазовите вашу задачу
      4. Нажмите + в правом нижнем углу.
      5. Найдите и выберите задачу Bluetooth Auto Connect .
      6. Нажмите карандаш рядом с Конфигурация. Новая акцияBluetooth Auto ConnectНастройка
      7. Снимите флажок Глобальные настройки.
      8. Нажмите Профили .
      9. Для устройства Bluetooth без микрофона требуется только проверка Media Audio . При подключении к устройству Bluetooth, которое можно использовать для вызовов, также установите флажок « Аудио вызова» .
      10. Нажмите кнопку назад . Снимите флажок Глобальные настройкипрофилиМедиа Аудио
      11. Нажмите « Устройства» .
      12. Снимите все устройства, кроме того, к которому вы хотите подключиться.
      13. Перетащите устройство, к которому вы хотите подключиться, вверх по списку.
      14. Нажмите кнопку назад . приборыСнимите флажок и измените порядок
      15. Нажмите Действие профиля .
      16. Нажмите « Подключиться» .
      17. Нажмите кнопку назад три раза . Действие профиляConnect
      18. Нажмите на значок из девяти точек в нижней средней части экрана задач.
      19. Нажмите значок приложения .
      20. Нажмите Bluetooth Автоподключение .
      21. Нажмите кнопку назад . Установить иконкуЗначок приложенияблютус

      Повторите эти шаги, чтобы создать вторую задачу, установив в этот раз действие профиля на отключение . Теперь, когда у нас есть задача отключить и восстановить соединение, нам нужен способ их запуска. Есть несколько способов сделать это:

      • Задачи Tasker могут быть добавлены на домашний экран в виде виджетов быстрого вызова 1×1.
      • Задачи Tasker можно назначать ярлыками жестов в средствах запуска, таких как Nova Launcher и Action Launcher .
      • Джоао Диас, создатель AutoApps и многих удивительных плагинов Tasker, даже имеет метод привязки Tasker Tasks к Google Assistant, чтобы вызвать их своим голосом.

      Я использую метод ярлыков жестов, проводя двумя пальцами вверх, чтобы подключиться к моему адаптеру Bluetooth в моей спальне, и проводя двумя пальцами вниз, чтобы отключиться. Это даже не похоже на Tasker, когда он настроен таким образом, он просто ощущается как естественная часть моего запуска на домашнем экране. Кроме того, эти задачи делают подключение и отключение моего Bluetooth-приемника намного проще, чем копаться в настройках Bluetooth каждое утро и ночь.

      Вопросы? Комментарии?

      Нужна дополнительная помощь с Tasker? Дайте нам знать, ниже, и мы поможем как можно лучше!

      Источник

Оцените статью
Adblock
detector