|
||
|
![]() |
![]() |
Avisos |
Tasker Para hablar de todo lo relacionado con la aplicación tasker |
![]() |
|
Herramientas |
#1
|
||||
|
||||
[PROYECTO] Monitor Bateria (no root)
Aquí os traigo un pequeño proyecto para estar al tanto del estado de nuestra bateria al momento de cargala, como también al usarla (no conectada a la corriente). Y funciona sin root, ya que no necesita leer el valor en crudo directamente de los archivos localizados en /sys/class/power_supply.
Dos son los modos en los que funciona: automático, activándose al detectar inicio de carga; y manual, si queremos conocer alguna medición de manera puntual, haciendo uso de un "Quick Settings Tile" (AutoNotification requerido) en Android Nougat. Y estos son los datos que nos proporcionará mediante una notificación permanente en barra de estado: · Porcentaje de bateria (%) · Temperatura actual (ºC) · Voltaje (V) · Carga/Suministro en miliamperios hora (mAh) · Tipo de conexión, si existe (AC, USB, Wireless) · Tiempo total aproximado de carga/descarga (TESTING) Para descarga los XMLs actualizados, click aquí. Y para ver mis otros aportes, click aquí. -PRINCIPAL- Código:
Profile: X - Conexión Dispositivo State: Power [ Source:Any ] Enter: X - Monitor Bateria (on) A1: Java Function [ Return:(BatteryManager) temp Class Or Object:CONTEXT Function:getSystemService {Object} (String) Param:batterymanager Param: Param: Param: Param: Param: Param: ] <Porcentaje Bateria (%)> A2: Java Function [ Return:%temp1 Class Or Object:temp Function:getIntProperty {int} (int) Param:4 Param: Param: Param: Param: Param: Param: ] <Miliamperios Hora (mAh)> A3: Java Function [ Return:%temp2 Class Or Object:temp Function:getIntProperty {int} (int) Param:2 Param: Param: Param: Param: Param: Param: ] A4: Variable Set [ Name:%temp2 To:abs(%temp2) Recurse Variables:Off Do Maths:On Append:Off ] A5: Variable Set [ Name:%temp2 To:round((%temp2)/1000) Recurse Variables:Off Do Maths:On Append:Off ] A6: Variable Set [ Name:%temp2x To:%temp2 Recurse Variables:Off Do Maths:Off Append:Off ] A7: Variable Set [ Name:%temp2 To:-%temp2 Recurse Variables:Off Do Maths:Off Append:Off ] <Tiempo Descarga> A8: Variable Set [ Name:%temp3 To:round((((2300 / 100) * %temp1) / %temp2x) * 60) Recurse Variables:Off Do Maths:On Append:Off ] A9: If [ %temp3 > 1439 ] A10: Variable Set [ Name:%temp31 To:floor(%temp3 / (24 * 60)) Recurse Variables:Off Do Maths:On Append:Off ] A11: Variable Set [ Name:%temp32 To:floor((%temp3 % (24 * 60)) / 60) Recurse Variables:Off Do Maths:On Append:Off ] A12: Variable Set [ Name:%temp33 To:floor((%temp3 % (24 * 60)) % 60) Recurse Variables:Off Do Maths:On Append:Off ] A13: Variable Set [ Name:%temp3 To:~ %temp31 d %temp32 h %temp33 m Recurse Variables:Off Do Maths:Off Append:Off ] A14: Else If [ %temp3 > 60 & %temp3 < 1440 ] A15: Variable Set [ Name:%temp31 To:floor(%temp3 / 60) Recurse Variables:Off Do Maths:On Append:Off ] A16: Variable Set [ Name:%temp32 To:%temp3 % 60 Recurse Variables:Off Do Maths:On Append:Off ] A17: Variable Set [ Name:%temp3 To:~ %temp31 h %temp32 m Recurse Variables:Off Do Maths:Off Append:Off ] A18: Else A19: Variable Set [ Name:%temp3 To:~ %temp3 m Recurse Variables:Off Do Maths:Off Append:Off ] A20: End If A21: Notify [ Title:Monitor Bateria Text:%temp1 % • - - °C • - - V • %temp2 mAh • - - • %temp3 Icon:mw_device_battery_unknown Number:0 Permanent:On Priority:5 ] A22: Profile Status [ Name:X - Intent (estado bateria) Set:On ] Exit: X - Monitor Bateria (off) A1: Profile Status [ Name:X - Intent (estado bateria) Set:Off ] A2: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] A3: Notify Cancel [ Title:Monitor Bateria Warn Not Exist:Off ] Código:
Profile: X - Intent (estado bateria) Event: Intent Received [ Action:android.intent.action.BATTERY_CHANGED Cat:None Cat:None Scheme:* Mime Type:* Stop Event: On ] Enter: X - Monitor Bateria A1: Java Function [ Return:(BatteryManager) temp Class Or Object:CONTEXT Function:getSystemService {Object} (String) Param:batterymanager Param: Param: Param: Param: Param: Param: ] A2: If [ %plugged ~ 0 ] <Porcentaje Bateria (%)> A3: Java Function [ Return:%temp1 Class Or Object:temp Function:getIntProperty {int} (int) Param:4 Param: Param: Param: Param: Param: Param: ] <Temperatura (°C)> A4: Variable Set [ Name:%temp2 To:%temperature * 0.1 Recurse Variables:Off Do Maths:On Append:Off ] <Voltaje (V)> A5: Variable Set [ Name:%temp3 To:%voltage * 0.001 Recurse Variables:Off Do Maths:On Append:Off ] <Miliamperios Hora (mAh)> A6: Java Function [ Return:%temp4 Class Or Object:temp Function:getIntProperty {int} (int) Param:2 Param: Param: Param: Param: Param: Param: ] A7: Variable Set [ Name:%temp4 To:abs(%temp4) Recurse Variables:Off Do Maths:On Append:Off ] A8: Variable Set [ Name:%temp4 To:round(%temp4 / 1000) Recurse Variables:Off Do Maths:On Append:Off ] A9: Variable Set [ Name:%temp4x To:%temp4 Recurse Variables:Off Do Maths:Off Append:Off ] A10: Variable Set [ Name:%temp4 To:-%temp4 Recurse Variables:Off Do Maths:Off Append:Off ] <Tipo Conexión> A11: Variable Set [ Name:%temp5 To:N/A Recurse Variables:Off Do Maths:Off Append:Off ] <Tiempo Descarga> A12: Variable Set [ Name:%temp6 To:round((((2300 / 100) * %temp1) / %temp4x) * 60) Recurse Variables:Off Do Maths:On Append:Off ] A13: If [ %temp6 > 1439 ] A14: Variable Set [ Name:%temp61 To:floor(%temp6 / (24 * 60)) Recurse Variables:Off Do Maths:On Append:Off ] A15: Variable Set [ Name:%temp62 To:floor((%temp6 % (24 * 60)) / 60) Recurse Variables:Off Do Maths:On Append:Off ] A16: Variable Set [ Name:%temp63 To:floor((%temp6 % (24 * 60)) % 60) Recurse Variables:Off Do Maths:On Append:Off ] A17: Variable Set [ Name:%temp6 To:~ %temp61 d %temp62 h %temp63 m Recurse Variables:Off Do Maths:Off Append:Off ] A18: Else If [ %temp6 > 60 & %temp6 < 1440 ] A19: Variable Set [ Name:%temp61 To:floor(%temp6 / 60) Recurse Variables:Off Do Maths:On Append:Off ] A20: Variable Set [ Name:%temp62 To:%temp6 % 60 Recurse Variables:Off Do Maths:On Append:Off ] A21: Variable Set [ Name:%temp6 To:~ %temp61 h %temp62 m Recurse Variables:Off Do Maths:Off Append:Off ] A22: Else A23: Variable Set [ Name:%temp6 To:~ %temp6 m Recurse Variables:Off Do Maths:Off Append:Off ] A24: End If A25: Else <Porcentaje Bateria (%)> A26: Java Function [ Return:%temp1 Class Or Object:temp Function:getIntProperty {int} (int) Param:4 Param: Param: Param: Param: Param: Param: ] <Temperatura (°C)> A27: Variable Set [ Name:%temp2 To:%temperature * 0.1 Recurse Variables:Off Do Maths:On Append:Off ] <Voltaje (V)> A28: Variable Set [ Name:%temp3 To:%voltage * 0.001 Recurse Variables:Off Do Maths:On Append:Off ] <Miliamperios Hora (mAh)> A29: Java Function [ Return:%temp4 Class Or Object:temp Function:getIntProperty {int} (int) Param:2 Param: Param: Param: Param: Param: Param: ] A30: Variable Set [ Name:%temp4 To:abs(%temp4) Recurse Variables:Off Do Maths:On Append:Off ] A31: Variable Set [ Name:%temp4 To:round(%temp4 / 1000) Recurse Variables:Off Do Maths:On Append:Off ] <Tipo Conexión> A32: Variable Set [ Name:%temp5 To:AC Recurse Variables:Off Do Maths:Off Append:Off ] If [ %plugged ~ 1 ] A33: Variable Set [ Name:%temp5 To:USB Recurse Variables:Off Do Maths:Off Append:Off ] If [ %plugged ~ 2 ] A34: Variable Set [ Name:%temp5 To:WIRELESS Recurse Variables:Off Do Maths:Off Append:Off ] If [ %plugged ~ 4 ] <Tiempo Carga> A35: Variable Set [ Name:%temp6 To:round(((2300 - ((2300 / 100) * %temp1)) / %temp4) * 60) Recurse Variables:Off Do Maths:On Append:Off ] A36: If [ %temp6 > 1439 ] A37: Variable Set [ Name:%temp61 To:floor(%temp6 / (24 * 60)) Recurse Variables:Off Do Maths:On Append:Off ] A38: Variable Set [ Name:%temp62 To:floor((%temp6 % (24 * 60)) / 60) Recurse Variables:Off Do Maths:On Append:Off ] A39: Variable Set [ Name:%temp63 To:floor((%temp6 % (24 * 60)) % 60) Recurse Variables:Off Do Maths:On Append:Off ] A40: Variable Set [ Name:%temp6 To:~ %temp61 d %temp62 h %temp63 m Recurse Variables:Off Do Maths:Off Append:Off ] A41: Else If [ %temp6 > 60 & %temp6 < 1440 ] A42: Variable Set [ Name:%temp61 To:floor(%temp6 / 60) Recurse Variables:Off Do Maths:On Append:Off ] A43: Variable Set [ Name:%temp62 To:%temp6 % 60 Recurse Variables:Off Do Maths:On Append:Off ] A44: Variable Set [ Name:%temp6 To:~ %temp61 h %temp62 m Recurse Variables:Off Do Maths:Off Append:Off ] A45: Else If [ %temp6 = 0 ] A46: Variable Set [ Name:%temp6 To:¡CARGADA! Recurse Variables:Off Do Maths:Off Append:Off ] A47: Else A48: Variable Set [ Name:%temp6 To:~ %temp6 m Recurse Variables:Off Do Maths:Off Append:Off ] A49: End If A50: End If A51: Notify [ Title:Monitor Bateria Text:%temp1 % • %temp2 °C • %temp3 V • %temp4 mAh • %temp5 • %temp6 Icon:mw_device_battery_unknown Number:0 Permanent:On Priority:5 ] Código:
Profile: QS - Monitor Bateria Event: com.joaomgcd.autonotification.activity.ActivityConfigConditionTaskerEvent [ Configuration:Event Behaviour Filter: battery=:= ] Enter: QS - Quick Settings Tiles <Monitor Bateria> A1: If [ %ancomm ~ battery ] A2: If [ %QS_tile4 ~ 0 ] A3: *Unknown Plugin* [ Configuration:Tile: AutoNotification 4 Command: battery=:=battery Label: Monitor Bateria Icon: /storage/emulated/0/Tasker/Resources/Quick Settings Tiles/battery.png State: Active Timeout (Seconds):60 ] A4: Perform Task [ Name:X - Monitor Bateria (on) Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] A5: Variable Set [ Name:%QS_tile4 To:1 Recurse Variables:Off Do Maths:Off Append:Off ] A6: Stop [ With Error:Off Task: ] A7: Else If [ %QS_tile4 ~ 1 ] A8: *Unknown Plugin* [ Configuration:Tile: AutoNotification 4 Command: battery=:=battery Label: Monitor Bateria Icon: /storage/emulated/0/Tasker/Resources/Quick Settings Tiles/battery.png State: Inactive Timeout (Seconds):60 ] A9: Perform Task [ Name:X - Monitor Bateria (off) Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] A10: Variable Set [ Name:%QS_tile4 To:0 Recurse Variables:Off Do Maths:Off Append:Off ] A11: End If A12: End If - En las acciones referidas al control del proyecto mediante el Quick Tile hacen referencia todos a '4', tanto en variables, como en nº de baldosa, porque tengo otros configurados. - Al momento de la conexión, o de activación manual es normal que quizás no aparezcan algunos de los valores actualizados, o establecidos durante los primeros segundos, o quizás minutos. Eso es debido a que Tasker debe esperar a que el intent recoja todos los datos correspondientes. (por ello he modificado las tareas para que aquellos valores sin valor alguno, aparezcan como '- - x') - En las tareas 'X - Monitor Bateria' y 'X - Monitor Bateria (on)' hará falta ajustar el valor '2300' por la cantidad de mAh que tenga nuestra bateria de serie. Última edición por SmartPhoneLover Día 27/07/18 a las 18:25:16. |
Los siguientes 3 usuarios han agradecido a SmartPhoneLover su comentario: | ||
|
#2
|
||||
|
||||
![]() ![]() ![]() ![]() |
Los siguientes 2 usuarios han agradecido a SmartPhoneLover su comentario: | ||
#3
|
||||
|
||||
Buen proyecto!
|
Gracias de parte de: | ||
#4
|
||||
|
||||
Me alegro que te guste ;)
Por otra parte, si lo deseas puedes seguir el otro hilo en Reddit para los cambios, además de que otro usuario compartió otro proyecto asociado del mismo tipo. Otra versión. Y actualmente estoy mezclando su proyecto con con el mio para crear otra más chula. https://www.reddit.com/r/tasker/comm...nitor_no_root |
Gracias de parte de: | ||
#5
|
||||
|
||||
Me alegro que te guste ;)
Por otra parte, si lo deseas puedes seguir el otro hilo en Reddit para los cambios, además de que otro usuario compartió otro proyecto asociado del mismo tipo. Otra versión. Y actualmente estoy mezclando su proyecto con con el mio para crear otra más chula. https://www.reddit.com/r/tasker/comm...nitor_no_root ![]() |
#6
|
||||
|
||||
seria interesante si tuviera un botón para activar el modo anti-robo. Que consiste en si el user saca el teléfono del cargador y no coloca la contraseña en 30 seg el teléfono empieza a sonar y si esta sonando por más de 3 min que envíe la ubicación a un número de teléfono especifico
![]() B) Creo que sería mejor el planteamiento siguiente: si el user saca el teléfono del cargador y no coloca la contraseña en 30 seg el teléfono emite dos bip seguidos y un flash con el texto: Batería cargada al 90% (o el porcentaje que corresponda). Eso te sirve a ti como recordatorio para meter la contraseña, y al ladrón no le extrañará ese informe porque acaba de desenchufar el teléfono del cargador. Tras eso, si transcurren otros 30 segundos sin poner la contraseña, se puede asumir que el teléfono ha sido robado, pero el ladrón no se sentirá incómodo ni alertado. C) Creo que no es buena idea enviar la ubicación a otro teléfono (¿Whatsapp?); sería mejor enviarla a una dirección de correo electrónico, cosa que es más fácil de hacer desde Tasker. Además, puedes consultar el email desde cualquier ordenador (o incluso desde cualquier smartphone que tenga un navegador), y así no dependes de un teléfono concreto que tal vez no esté accesible cuando lo necesites. D) Creo que todo esto tiene poco sentido, por lo siguiente: sí tú pones el teléfono a cargar y te lo roban, no necesitas que un minuto después te de la ubicación porque no puede estar muy lejos del sitio donde lo pusiste a cargar. Por otro lado, si alguien te roba el teléfono, antes o después lo pondrá a cargar y luego lo desenchufará... pero seguramente que antes de hacer eso le haya hecho un reset de fábrica para limpiarlo y evitar sistemas de rastreo, con lo cual las tareas de Tasker no sobreviven. Para obtener la ubicación hay otros métodos mejores, que incluso sobreviven a un reset de fábrica. El más sencillo (gratis, sin instalar ninguna app) es https://myaccount.google.com/find-your-phone Este sistema no solo permite localizar el teléfono (en el momento que quieras), también ofrece otras opciones interesantes como bloquearlo, borrarlo, cerrar la sesión, hacerlo sonar, etc. Si quieres más opciones tienes la app Cerberus, que es perfecta para quienes tienen Root (si lo preparas bien también resiste un reset de fábrica) y ofrece muchas más posibilidades como por ejemplo obtener fotos con la cámara del teléfono robado.
__________________
Firmado: Caravantes, miembro del equipo que promueve el Subforo de Tasker
|
#7
|
||||
|
||||
Muchas gracias por la aclaración!
Yo tengo la app de cerberus instalada en mi teléfono, el método anti-robo que he mencionado luego arriba era solo una medida para poder dejar el teléfono en el corredor de la universidad mientras estoy no más de 100 metros de el. Sobre el método de rastreo llevas toda razón! |
![]() |
![]() |
||||||
|