Page 1 of 1

Notification progress

Posted: 09 Dec 2019 07:31
by Lucy
How can i add a static value to a notification?
I mean like, if for example i attach a notification to my battery widget flow... the script for the updated value is..

Code: Select all



global_battery_level = battery_level + "%";
if (battery_status == "1")
{ global_battery_status = "Unknown"; }
else if (battery_status == "2")
{ global_battery_status = "Charging"; }
else if (battery_status == "3")
{ global_battery_status = "Discharging"; }
else if (battery_status == "4")
{ global_battery_status = "Not charging"; }
else if (battery_status == "5")
{ global_battery_status = "Full"; }

if (battery_plugged == "1")
{ global_battery_plugged = "AC adapter"; }
else if (battery_plugged == "2")
{ global_battery_plugged = "USB"; }
else if (battery_plugged == "3")
{ global_battery_plugged = "Wireless"; }
else if (battery_plugged == "0")
{ global_battery_plugged = "Not plugged"; }

if (battery_health == "1")
{ global_battery_health = "Unknown"; }
else if (battery_health == "2")
{ global_battery_health = "Good"; }
else if (battery_health == "3")
{ global_battery_health = "Overheat"; }
else if (battery_health == "4")
{ global_battery_health = "Dead"; }
else if (battery_health == "5")
{ global_battery_health = "Over voltage"; }
else if (battery_health == "6")
{ global_battery_health = "Unspecified failure"; }
else if (battery_health == "7")
{ global_battery_health = "Cold"; }



How can i have that percentage value and battery status show in progress bar but with updated values?

Re: Notification progress

Posted: 09 Dec 2019 17:51
by Desmanto
Just use the variable in the notification text. To eliminate the too many else if, use map

status = newMapFromValues(
1, "Unknown",
2, "Charging",
3, "Discharging",
4, "Not charging",
5, "Full" );
global_battery_status = status[battery_status];

Do the same also for the plugged and health. Later use {global_battery_status} in the notification text.

To get the progress percentage, you can check Show progressbar. Progressbar value is {battery_level} and the max value is 100. The next trigger that it update the value, it will change the batttery level and increase the progressbar.

Re: Notification progress

Posted: 09 Dec 2019 18:34
by Lucy
Lol yeah i know i haven't started maps yet. Thanks for that darling ima fix it