I received my cm1102 today. Connecting & configuring the device went perfect. However, it refuses to send the custom http requests. I enabled the debug mode but still I don't get any details about why the request failed. If I copy & paste the URL in the browser it works fine. The log data:
CustomHTTPDest::process
CustomHTTPDest::invoke =
https://miehat-functions.azurewebsites.n...res=999.13
Error Code: -1 = connection refused
Failed
SerialDumpDest::process
Any ideas what might go wrong here? SSL / certificate issues?
Aahhh.. thank you for testing with Azure, i also had plans to test how it works, but sadly - not enough time!
It fails because it uses TLS v1.2 which is supported by a newer version of the WiFi module firmware that i use. I've delayed moving to it for a few months as i had some trouble with my build environment - but apparently - now it is time.
I would appreciate it if you can wait for a couple of days, as i need to setup the build and then do a couple of tests - whether some regressions are introduced
Sure, no rush at all. My other challenge will be getting the data to my Vera home automation gateway, so i'll work on that first :-) I'll be happy to test new firmware, once you've had time to update the module.
The Azure endpoint I created is an 'Azure Function'. Another logical endpoint would be an Azure Logic App, those unfortunately only support HTTP POST. In case you someday have a need/wish to add POST support; a sample endpoint would be:
https://prod-06.westeurope.logic.azure.c...vVP7PHXD_Q
In a logic app you define a json schema for the data, the endpoint above expects the following body:
{
"co2": 701.34,
"temp": 24.53,
"hum": 44.43,
"pres": 999
}
Then there are several other Azure endpoints, depending on the scenario. The thing I like about the 'Azure Function' is that it allows me to accept the data from the device and store it in 'Azure table storage' with just a few lines of code:
Code:
#r "Microsoft.WindowsAzure.Storage"
using System.Net;
using Microsoft.WindowsAzure.Storage.Table;
using System.Globalization;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, IAsyncCollector<CO2DataPoint> co2Table, TraceWriter log)
{
log.Info($"Incoming CO2 data");
// parse query parameter
var parameters = req.GetQueryNameValuePairs();
double co2 = GetDbl(parameters, "co2");
double temp = GetDbl(parameters, "temp");
double hum = GetDbl(parameters, "hum");
double pres = GetDbl(parameters, "pres");
var timestamp = DateTime.Now;
log.Info($"data received at {timestamp}, CO2 is {co2}.");
var dataPoint = new CO2DataPoint() {
PartitionKey = $"{timestamp.Year}-{timestamp.Month}-{timestamp.Day}",
RowKey = $"{timestamp.Hour}-{timestamp.Minute}-{timestamp.Second}",
CO2 = co2,
Temperature = temp,
Humidity = hum,
Pressure = pres
};
await co2Table.AddAsync(dataPoint);
return req.CreateResponse(HttpStatusCode.OK, "Thanx");
}
public static double GetDbl(IEnumerable<System.Collections.Generic.KeyValuePair<string, string>> parameters, string name)
{
string value = parameters
.FirstOrDefault(q => string.Compare(q.Key, name, true) == 0)
.Value;
return double.Parse(value, CultureInfo.InvariantCulture);
}
public class CO2DataPoint : TableEntity
{
public double CO2 {get;set;}
public double Temperature {get;set;}
public double Humidity {get;set;}
public double Pressure {get;set;}
}
interesting... I will spend some time to research this
and about vera.. google about esp8266 and vera.. looks like some people haf success.. ive looked into this some time ago but honestly lately when I was checking about all typical home automation systems I forgot about it
I spent some few hours trying to make this run, but unfortunately unsuccessfully. Apparently some other people have succeeded (or at least it looks like this), so i will need to dig a bit deeper to see what they have done