Bluetooth Batterie logging

x4rfaCe

New member
Hi,

I would like to track and save my different BT devices battery level to check it and notify me when they running low. But in my macro the trigger fires and stores in the wrong variable:

When i connect the Headset it stores also the percentage of the headset in F8 variable which is a BT musicbox. Anybody can tell me why?

Thank you in advance.
x4rfaCe
 

Attachments

  • Screenshot_20220724-132559.png
    Screenshot_20220724-132559.png
    118 KB · Views: 33
  • Screenshot_20220724-132609.png
    Screenshot_20220724-132609.png
    118.8 KB · Views: 29
  • Screenshot_20220724-131948.png
    Screenshot_20220724-131948.png
    172.1 KB · Views: 30

Snurre

Well-known member
No matter which triggers the macro, you are setting both var's, you need to find out which trigger is fired

Try something like this

If trigger fired => T1
Set Variable => V1
Else if trigger fired => T2
Set Variable => V2
 

x4rfaCe

New member
I have found a solution, wasn't familar with the intents: now i store also the device absolute name in another var and can handle it with if's. Thank you anyway :)
 

Attachments

  • Screenshot_20220724-142734.png
    Screenshot_20220724-142734.png
    142.7 KB · Views: 24

x4rfaCe

New member
Hi again 🫣

Is there an intent extra to get back the friendly name in bluetooth?
Was finding "android.bluetooth.device.extra.NAME" but it doesn't return anything.

Btw.: Is there a good page for the intents? Google isn't really helpful by searching for it.

Thanks for a ahort feedback ;)
 

x4rfaCe

New member
And I would like to share what I have that far.

Works well, except the Smartwatch doesn't share any information about the battery.
 

Attachments

  • Screenshot_20220724-160748.png
    Screenshot_20220724-160748.png
    141.3 KB · Views: 25
  • Screenshot_20220724-160732.png
    Screenshot_20220724-160732.png
    167.7 KB · Views: 25
  • Screenshot_20220724-160811.png
    Screenshot_20220724-160811.png
    162.9 KB · Views: 22
  • Screenshot_20220724-160820.png
    Screenshot_20220724-160820.png
    161.6 KB · Views: 23

RSF

Well-known member
Is there an intent extra to get back the friendly name in bluetooth?
Was finding "android.bluetooth.device.extra.NAME" but it doesn't return anything.
According to this link, the NAME extra is only present on NAME_CHANGED and FOUND intents.

You could change your series of IF statements to a simpler dictionary lookup, which would (a) reduce the lines of code and (b) make it somewhat easier to add to the list of devices as they change... Your dictionary could have the MAC addresses as keys, and the friendly name as the values, and you'd have just a single non-changing loop to look for the battery-level-reporting device's MAC:

Device_dictionary.png


Iterate_over_dictionary.png
You could even theoretically detect NAME_CHANGED intents and update the dictionary automatically, but that's probably not worth it unless the names change often.


Btw.: Is there a good page for the intents? Google isn't really helpful by searching for it.
I have not found a comprehensive, easy (MacroDroid-oriented) list of all Android intents and parameters/extras, either for sent or received intents. Some people have found an app called "Shortcut Maker" helpful for intents supported by installed apps, but it wouldn't have helped in this case with the Android system intent. The Android documentation, combined with experimentation, are all that I've found for those (and some Google searches for specific intents and MacroDroid or Tasker).
 

x4rfaCe

New member
Hi again,

I am done with my macro. It's doing now what it should do. Thanks again for your help. Attached my work.

GreeTz
x4rfaCe
 

Attachments

  • Screenshot_20220731-213252.png
    Screenshot_20220731-213252.png
    142.3 KB · Views: 30
  • Screenshot_20220731-213319.png
    Screenshot_20220731-213319.png
    169.5 KB · Views: 28
  • Screenshot_20220731-213330.png
    Screenshot_20220731-213330.png
    168.7 KB · Views: 30
  • Screenshot_20220731-213342.png
    Screenshot_20220731-213342.png
    118.8 KB · Views: 26
  • Screenshot_20220731-213358.png
    Screenshot_20220731-213358.png
    72.5 KB · Views: 22
  • Screenshot_20220731-213417.png
    Screenshot_20220731-213417.png
    120.6 KB · Views: 22
  • Screenshot_20220731-213458.png
    Screenshot_20220731-213458.png
    139.5 KB · Views: 22
  • Screenshot_20220731-213503.png
    Screenshot_20220731-213503.png
    172 KB · Views: 27
  • Like
Reactions: RSF

x4rfaCe

New member
Ok,
I have the next thing to go.
How can i track my smartwatch battery? :)

Thanks for feedbacks
x4rfaCe
 

hutbrummer

New member
Hello,

first of all thank you for sharing your macro.
this is exactly what I needed to monitor the battery of my Bluetooth headset and speakers.

I am very interested in tracking the battery of my smartwatch as well but yet I could not find a solution because it is not sending intents.

After some researches I found out that tizen is the OS running on Samsung smartwatches and sends System infos to the gear app only.

The only way to get the battery info is either
a) to write a watch app to send Bluetooth intents on specified events
b) write a phone app that somehow access the data of the wearable app on the phone
c) write a watch and phone app which communicate with each other and can send the info to macrodroid

I have no idea how to do any of this but in case anybody is interested I think this is what is needed on the watch

 
Top