- Posts: 62
- Thank you received: 3
wget --ca-certificate=/usr/share/ca-certificates/freemobile/RapidSSLCABundle.crt -O /dev/null "https://smsapi.free-mobile.fr/sendmsg?user=xxxxxx&pass=yyyyyy&msg=RPi speaking..."
--2015-02-25 20:40:02-- https://smsapi.free-mobile.fr/sendmsg?user=xxxxxx&pass=yyyyyy&msg=RPi%20speaking...
Résolution de smsapi.free-mobile.fr (smsapi.free-mobile.fr)... 212.27.40.200
Connexion vers smsapi.free-mobile.fr (smsapi.free-mobile.fr)|212.27.40.200|:443...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: non spécifié
Sauvegarde en : «/dev/null»
[ <=> ] 0 --.-K/s ds 0s
2015-02-25 20:40:29 (0,00 B/s) - «/dev/null» sauvegardé [0]
Please Log in or Create an account to join the conversation.
Xavier wrote: Hi,
Is it a way to send a wget command through automation? For me, it would be an easy way to send SMS alert for free.
My French provider (Free Mobile) offers an API that permit to send myself an SMS from the shell :Response is :wget --ca-certificate=/usr/share/ca-certificates/freemobile/RapidSSLCABundle.crt -O /dev/null "https://smsapi.free-mobile.fr/sendmsg?user=xxxxxx&pass=yyyyyy&msg=RPi speaking..."As you can see the wget returns only when SMS is sent, here it last 30s.--2015-02-25 20:40:02-- https://smsapi.free-mobile.fr/sendmsg?user=xxxxxx&pass=yyyyyy&msg=RPi%20speaking... Résolution de smsapi.free-mobile.fr (smsapi.free-mobile.fr)... 212.27.40.200 Connexion vers smsapi.free-mobile.fr (smsapi.free-mobile.fr)|212.27.40.200|:443...connecté. requête HTTP transmise, en attente de la réponse...200 OK Longueur: non spécifié Sauvegarde en : «/dev/null» [ <=> ] 0 --.-K/s ds 0s 2015-02-25 20:40:29 (0,00 B/s) - «/dev/null» sauvegardé [0]
Is it a problem?
Please Log in or Create an account to join the conversation.
const String testNode = "N2S0";
const float maxValue = 65;
const float minValue = 45;
const String hiMsg = "RPi Alert.\r";
const String loMsg = "Alert closed.\r";
const String FreeID = "xxxxxxx";
const String FreePW = "yyyyyyy";
/*
====================================================================
This code is running one time when program is enabled
====================================================================
*/
public void Setup()
{
// Gets a NumberFormatInfo associated with the en-US culture.
System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo( "en-US", false ).NumberFormat;
EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine("\n => Alerte: " + m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
if (m.Domain == "MySensors" && m.Address == testNode && p.Property == "Sensor.Humidity" && p.Value != "NaN")
{
float fValue = Convert.ToSingle(p.Value,nfi);
// float fValue = float.Parse(p.Value.Replace('.',','));
if (fValue >= maxValue)
SendSMS(hiMsg);
else if (fValue <= minValue)
SendSMS(loMsg);
}
return true;
});
}
/*
====================================================================
This code is running periodicaly when program is enabled.
Cron job determine running period.
====================================================================
*/
public void Run()
{
}
/*
====================================================================
This function send a SMS using SMSAPI from Free mobile.
The RapidSSLCABundle.crt certificat (used by Free mobile) must be
installed first for the https request to complete.
====================================================================
*/
private void SendSMS(String message)
{
string msgURL = "https://smsapi.free-mobile.fr/sendmsg?user="+FreeID+"&pass="+FreePW+"&msg="+message;
Console.WriteLine("Send SMS :" + message + "/n -> Status=" );
try
{
System.Net.WebRequest request = System.Net.WebRequest.Create(msgURL);
request.Method = System.Net.WebRequestMethods.Http.Head;
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusCode);
*/
// Close everything.
response.Close();
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
}
// return 0;
}
Please Log in or Create an account to join the conversation.
Xavier wrote: Hi,
Here is my script. It seems to compile OK but it doesn't work. I even suspect it makes silently crash EasyIot so that I have to restart the server when an error occurs. Do you see something wrong?
const String testNode = "N2S0"; const float maxValue = 65; const float minValue = 45; const String hiMsg = "RPi Alert.\r"; const String loMsg = "Alert closed.\r"; const String FreeID = "xxxxxxx"; const String FreePW = "yyyyyyy"; /* ==================================================================== This code is running one time when program is enabled ==================================================================== */ public void Setup() { // Gets a NumberFormatInfo associated with the en-US culture. System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo( "en-US", false ).NumberFormat; EventHelper.ModuleChangedHandler((o, m, p) => { Console.WriteLine("\n => Alerte: " + m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value); if (m.Domain == "MySensors" && m.Address == testNode && p.Property == "Sensor.Humidity" && p.Value != "NaN") { float fValue = Convert.ToSingle(p.Value,nfi); // float fValue = float.Parse(p.Value.Replace('.',',')); if (fValue >= maxValue) SendSMS(hiMsg); else if (fValue <= minValue) SendSMS(loMsg); } return true; }); } /* ==================================================================== This code is running periodicaly when program is enabled. Cron job determine running period. ==================================================================== */ public void Run() { } /* ==================================================================== This function send a SMS using SMSAPI from Free mobile. The RapidSSLCABundle.crt certificat (used by Free mobile) must be installed first for the https request to complete. ==================================================================== */ private void SendSMS(String message) { string msgURL = "https://smsapi.free-mobile.fr/sendmsg?user="+FreeID+"&pass="+FreePW+"&msg="+message; Console.WriteLine("Send SMS :" + message + "/n -> Status=" ); try { System.Net.WebRequest request = System.Net.WebRequest.Create(msgURL); request.Method = System.Net.WebRequestMethods.Http.Head; System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); Console.WriteLine(response.StatusCode); */ // Close everything. response.Close(); } catch(Exception e) { Console.WriteLine(e.StackTrace); } // return 0; }
Please Log in or Create an account to join the conversation.
It took me a while to understand this sentence .EasyIoT wrote: Use console mode and console output to debug your program
sudo mono EasyIoT.exe
2015-02-27T22:13:18.1279240+01:00 INFO System System started
2015-02-27T22:13:24.5143530+01:00 DEBUG MySensors Mysensors Start driver.
2015-02-27T22:13:24.9956220+01:00 DEBUG MySensors Read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:62.5
2015-02-27T22:13:25.3717880+01:00 INFO MySensors N2S0 Sensor.Humidity 62.5 -
=> Alerte: MySensors N2S0 in program id 16 property Sensor.Humidity value 62.6
2015-02-27T22:14:28.7547280+01:00 DEBUG MySensors Read: 2-2-0 s=1,c=1,t=0,pt=7,l=5:20.3
2015-02-27T22:14:28.7621220+01:00 INFO MySensors N2S1 Sensor.Temperature 20.3 -
2015-02-27T22:14:28.7907270+01:00 DEBUG MySensors Read: 2-2-0 s=2,c=1,t=1,pt=7,l=5:61.4
2015-02-27T22:14:28.7979410+01:00 INFO MySensors N2S2 Sensor.Humidity 61.4 -
2015-02-27T22:14:28.8217310+01:00 DEBUG MySensors Read: 2-2-0 s=3,c=1,t=0,pt=7,l=5:20.0
2015-02-27T22:14:28.8287340+01:00 INFO MySensors N2S3 Sensor.Temperature 20.0 -
Unhandled Exception:
System.FormatException: Input string was not in the correct format
at System.Double.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
at System.Single.Parse (System.String s, IFormatProvider provider) [0x00000] in <filename unknown>:0
at System.Convert.ToSingle (System.String value, IFormatProvider provider) [0x00000] in <filename unknown>:0
at EasyIoT.Automation.ScriptingInstance+<Setup>c__AnonStorey0.<>m__0 (System.Object o, GenericDriver.Module m, GenericDriver.DriverPropertyChangedData p) [0x00000] in <filename unknown>:0
at EasyIoT.Automation.AutomationEngine.ProcessEvent (System.Object source, GenericDriver.Module m, GenericDriver.DriverPropertyChangedData obj) [0x00000] in <filename unknown>:0
at EasyIoT.EasyIoTService.processInternalEvent (System.Object eventData) [0x00000] in <filename unknown>:0
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.