Author Topic: Issuing HTTPS post to send event outside system  (Read 1540 times)

Offline Finalist

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Issuing HTTPS post to send event outside system
« on: September 16, 2016, 02:14:18 pm »
Where would I put an HTTPS post to an outside "alternate" server that can receive and log the JSON content that your application collects.
I have an AppService running that will accept HTTPS post events and would like to use your plug in to correctly pull the events but I want to send them to my AppService for advanced analytics over time.
Thoughts?
thanks in advance - Scott.

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 10091
  • Karma: +764/-142
Re: Issuing HTTPS post to send event outside system
« Reply #1 on: September 16, 2016, 05:51:15 pm »
Vera Alerts supports a SYSLOG  profile ... to send to a SYSLOG server.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6204
  • Karma: +276/-70
  • "Less is more"
Re: Issuing HTTPS post to send event outside system
« Reply #2 on: September 16, 2016, 07:00:23 pm »
The Alternate Event Server functionality of EventWatcher does not, alas, work under UI7, since that firmware has a flawed implementation of the event handler.

The syslog capability of EventWatcher, however, would be a possible alternative, although it uses a UDP protocol, rather than HTTPS.

Other options rather depend on what events you are after.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Finalist

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Issuing HTTPS post to send event outside system
« Reply #3 on: September 19, 2016, 11:01:04 am »
Same events you are exposing here.  Instead of using a SYSLOG server I want to send each event to an HTTPS service endpoint.  It is close to what was being done with the alternate event log server in the past so that is why I reference it.
In your plug in I am assuming I could create a function to send almost exactly what the SYSLOG is receiving.  I was wondering if you had any other advice since it is your code base.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6204
  • Karma: +276/-70
  • "Less is more"
Re: Issuing HTTPS post to send event outside system
« Reply #4 on: September 19, 2016, 12:59:26 pm »
In your plug in I am assuming I could create a function to send almost exactly what the SYSLOG is receiving.  I was wondering if you had any other advice since it is your code base.

Yes, that should be straight-forward.  You simply need to send the request with the following line of Lua:

Code: [Select]
ssl.https.request (your_url_request)

What you actually put into your_url_request will depend entirely on your server's requirements.

Every event calls this function:
Code: [Select]
local function event (time, devNo, name, var, arg) -- constructor and formatter for event types

and you will see where it optionally calls syslog and also writes the event to a file.  All the event data is in a variable e and you can model your output on the format routine that the file write uses .
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Finalist

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Issuing HTTPS post to send event outside system
« Reply #5 on: September 19, 2016, 03:22:56 pm »
perfect!  Was looking into doing just that.
I actually want the event to be a JSON string just like the format of the old Alternate Events Server this way I would not have to change my receiving code.  If not it is not the end of the world I can make the changes on either side.

FYI - I take the events and send them to a Web Service in Azure for processing and machine learning on my events.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6204
  • Karma: +276/-70
  • "Less is more"
Re: Issuing HTTPS post to send event outside system
« Reply #6 on: September 19, 2016, 03:47:36 pm »
I actually want the event to be a JSON string just like the format of the old Alternate Events Server this way I would not have to change my receiving code. 

The documentation from Vera that I included in EventWatcher says:

Quote
UI5:
Vera will send the event as a standard HTTPS (secure) GET to yourserver/alert
with the arguments passed on the URL, like this (assuming your server is myserver.me.com):

 
Code: [Select]
https://myserver.me.com/alert?
 PK_AccessPoint=[serial number of Vera; in Lua you can get it with luup.pk_accesspoint]
 &HW_Key=[hardware key of Vera; in Lua you can get it with luup.hw_key]
 &DeviceID=[device id that is associated with the alert]
 &LocalDate=[the time the alert happened as human readable text]
 &LocalTimestamp=[the time the alert happened as a unix timestamp in UTC]
 &AlertType=[one of the alert types below]
 &SourceType=[one of the source types below]
 &Argument=[an optional argument depending on the alert type]
 &Format=[a file format, not normally used]
 &Code=[a code for the alert, usually the variable that changed]
 &Value=[the value corresponding to the code above]
 &Description=[a human readable description of the event, or comments regarding it]
 &Users=[a comma separated list of user id's that should be notified of the event]
and
Code: [Select]
--local AlertType = {"Image", "Video", "Trigger", "Variable", "Logon", "Gateway Connected",
-- "System Error", "Validate Email", "Validate SMS", "System Message"}
 
--local SourceType = {"User", "Timer", "Trigger", "Variable"}
 
--local FileFormat = {"JPEG", "MJPEG", "MP4"}

You should be able to construct the required string quite easily, but ask again if you have trouble.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline sre

  • Full Member
  • ***
  • Posts: 110
  • Karma: +0/-1
Re: Issuing HTTPS post to send event outside system
« Reply #7 on: September 22, 2016, 12:50:58 pm »
Hi,

I am a newbie and trying to understand the system and it working so that I could use it fully.  I have installed eventwatcher (has got a Vera edge with Ui7).  I really don't know how to use it  For example under conditions I have Links to reports:Variable and Event Log etc..  When I click the link I get the data.  The data is only from last Vera restart.  Csn you tell me or show the links where the information such as how to capture this info continuously somewhere ?  I did some search but not getting to the correct location.  Thanks for the plug in anyway as I have the info what I am looking for.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6204
  • Karma: +276/-70
  • "Less is more"
Re: Issuing HTTPS post to send event outside system
« Reply #8 on: September 22, 2016, 01:02:46 pm »
It rather depends on what sort of logging you want to do as to whether EventWatcher is the plugin for you, or not.  For long-term storage and plotting of sensor-like data (temperature, humidity, etc.) then either DataYours or dataMine are worth looking at:  http://forum.micasaverde.com/index.php/board,43.0.html

However, EventWatcher is able to send events elsewhere for external storage (across restarts) either using the standard (Unix) application 'syslog' or just writing it to a flat file on a remote file system (eg. network mount or USB.)  On its own, EventWatcher is really just a tool which gives much simpler event information than the Vera logs, and allows you to investigate some aspects of the system (scenes, etc.)

Rather than struggling with the awful UI7 interface to Vera, you might also consider the AltUI plugin, http://forum.micasaverde.com/index.php/board,78.0.html, which provides an alternative, much more functional, and prettier interface than the native Vera one.  It also allows easy access to logs, scene scripts, and the like.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline sre

  • Full Member
  • ***
  • Posts: 110
  • Karma: +0/-1
Re: Issuing HTTPS post to send event outside system
« Reply #9 on: September 22, 2016, 01:07:53 pm »
HI @akbooer

Thank you very much for your prompt response.  Appreciated. Let me go through this so that I could digest it.  I may have to take some more of your valuable time, should I need some more info.  Regards,