Page 1 of 1

Battery status notification

Posted: Mon Jun 08, 2009 1:30 pm
by drmacchi
Hello Domotica World [:D], who does know a software (windows) that can send emails when battery level is low? I'm looking for a sw that monitors laptop batteries, not UPS battery. Cheers, Lorenzo

Battery status notification

Posted: Mon Jun 08, 2009 2:00 pm
by Alexander
You can use powercfg.exe for this purpose and run an e-mail commandline tool.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
/BATTERYALARM, /B {LOW|CRITICAL} Displays or configures the specified
battery alarm. Using this option without any switches will
display the current settings.
The following switches can be specified:
/activate <on|off>
Enables or disables the alarm.
/level <percentage (0 - 100)>
The alarm will be activated when the power level
reaches this percentage.
/text <on|off>
Turns the text notification on or off.
/sound <on|off>
Turns the audible notification on or off.
/action <none|shutdown|hibernate|standby>
Specifies the action to take when this alarm goes
off. Not all actions are always available.
/forceaction <on|off>
Force stand by or shutdown even if a program stops
responding.
<b>/program <on|off>
Specifies whether the system will run a program
when the alarm goes off. When this option is used,
the output will be the taskname that can be used
with schtasks.exe /change to configure the program.</b>
/HELP, /? Displays information on command-line parameters.

Examples:
POWERCFG /LIST
POWERCFG /QUERY scheme
POWERCFG /QUERY
POWERCFG /CREATE scheme
POWERCFG /DELETE scheme
POWERCFG /SETACTIVE scheme
POWERCFG /CHANGE scheme /monitor-timeout-dc 15
POWERCFG /CHANGE scheme /monitor-timeout-dc 0
POWERCFG /HIBERNATE on
POWERCFG /EXPORT scheme /file file
POWERCFG /QUERY number /NUMERICAL
POWERCFG /GLOBALPOWERFLAG on /OPTION BATTERYICON
POWERCFG /AVAILABLESLEEPSTATES
POWERCFG /BATTERYALARM low
POWERCFG /BATTERYALARM critical /ACTIVATE on /LEVEL 6 /ACTION hibernate<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Battery status notification

Posted: Mon Jun 08, 2009 3:40 pm
by drmacchi
Thanks for the tip!.... Sorry, i can not create the line with schtasks , i don't understand how to launch outlook express. Lorenzo

Battery status notification

Posted: Mon Jun 08, 2009 4:09 pm
by Alexander
Lorenzo, outlook express hasnt got the commandline interface we need for this.
Use a script or command line tool, like: http://www.petri.co.il/send_mail_from_script.htm

Battery status notification

Posted: Mon Jun 08, 2009 8:02 pm
by Fantic
or use blat, a command line mail util.

Regards, Maarten.
Never let a computer know you're in a hurry.

Battery status notification

Posted: Mon Jun 08, 2009 8:58 pm
by Alexander
blat was the one i was searching for, but the one in the link has the same functionality.

Battery status notification

Posted: Mon Jun 08, 2009 10:43 pm
by drmacchi
some problems in powercfg there's option PROGRAM , what do i have to type to start commandline tools like "sendmail" or blat?, if i type the path of the .exe file it doesn't work and schtask is not recognized (windows xp home)

Battery status notification

Posted: Tue Jun 09, 2009 1:52 am
by Alexander
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
1. run "powercfg /b low /program on" or "powercfg /b critical /program on" depending on your needs
2. echo back will be simular like "Low Battery Alarm Program". An scheduled task has been created by that name. Edit that scheduled task to start the mail command with parameters.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

schtask.exe is the command line tool for scheduled tasks.

Battery status notification

Posted: Tue Jun 09, 2009 9:45 am
by drmacchi
1) i didn't have schtasks in windows..... i copied from internet
2) created the task, this task points to a .bat file, because i use "mailsend.exe -v <msg.txt" as -v is not accepted by schtasks that sees that it like a wrong parameter
3) this task , called (mailsend), should be "inserted" in powercfg, but I CAN NOT DO IT.
i use : powercfg /b critical /level 15 /activate on /program on mailsend
WHERE IS ERROR?

Battery status notification

Posted: Tue Jun 09, 2009 10:23 am
by Alexander
Lorenzo, please read my post from last night. You are not following my given solution. "mailsend" after the "on" is not allowed.
You can open the scheduled tasks in its GUI. You don't need the schtasks.

Battery status notification

Posted: Wed Jun 10, 2009 12:29 am
by drmacchi
Ok , i got it! I have the task in graphical interface and it can send emails. now another problem powercfg with option /level , is this the REMAINING level of battery life? i'm pretty sure , but i have a warning like "minimal value is 85". Then i don't set any scheduling, is it right? it should run on that level battery.

Battery status notification

Posted: Wed Jun 10, 2009 1:07 am
by Alexander
It will not act on a schedule indeed. Powercfg wil trigger an alarm. You just created a alarm that runs a scheduled task (wrong name in this context).

Battery status notification

Posted: Wed Jun 10, 2009 10:55 am
by drmacchi
Perfect! last problem is that 85% value. I also see it in GUI battery management with scrolling bar to set the desired value, if i move the bar , when i leave mouse it returns automatically on 85% !!! . may be some problems in windows register?