AlternateEventServer
(22 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | Vera calls | + | [[Category:Services]] |
+ | Vera calls MiOS's event servers to report events, like sensor tripped, triggers, etc. MiOS's event servers send out text messages and emails to report these events. | ||
− | Some very advanced users have asked to setup their own event server that Vera will call to report events. If you add your own, alternate event server, Vera will still send events to | + | Some very advanced users have asked to setup their own event server that Vera will call to report events. If you add your own, alternate event server, Vera will still send events to MiOS's event server unchanged, however Vera will also post the same event to the alternate server of your choice. |
− | Vera will send the event as a standard HTTPS (secure) GET to <tt>yourserver/alert</tt> with the arguments passed on the URL, like this (assuming your server is <tt>myserver.me.com</tt>): | + | == UI5 == |
+ | * On '''UI5''' Vera will send the event as a standard HTTPS (secure) GET to <tt>yourserver/alert</tt> with the arguments passed on the URL, like this (assuming your server is <tt>myserver.me.com</tt>): | ||
https://myserver.me.com/alert? | https://myserver.me.com/alert? | ||
Line 20: | Line 22: | ||
&Users=[a comma separated list of user id's that should be notified of the event] | &Users=[a comma separated list of user id's that should be notified of the event] | ||
+ | The page on your event server must respond with a plain text response which should look like this: | ||
+ | HTTP/1.1 200 OK | ||
+ | Content-Length: n | ||
+ | |||
+ | PK_Alert:x | ||
+ | |||
+ | - '''x''' is some number to identify the alert recorded on the server. It can be any number, and just ''PK_Alert:0'' if you don't assign a number to the alert. Whatever it is will be put in Vera's logs along with the alert for cross reference.<br /> | ||
+ | - '''n''' is the content length, which is 9 plus the length of '''x''' (e.g. for ''PK_Alert:0'' the content length is ''10''). The ''Content-Length'' parameter is optional. | ||
+ | <br /><br/> | ||
+ | == UI7 == | ||
+ | * On '''UI7''' Vera will send the event as a standard HTTPS (secure) POST to <tt>yourserver/event/event/event</tt>, passing the data as a json, like this (assuming your server is <tt>myserver.me.com</tt>): | ||
+ | |||
+ | https://myserver.me.com/event/event/event | ||
+ | |||
+ | { | ||
+ | "PK_Device":, // Serial number of Vera; in Lua you can get it with [http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#variable:_pk_accesspoint luup.pk_accesspoint] | ||
+ | "PK_Account":, // The account ID which the Vera unit is assigned to | ||
+ | "LocalDate":"", // The time when the alert was generated, as human readable text | ||
+ | "Severity":, | ||
+ | "EventType":, // One of the alert types below | ||
+ | "SourceType":, // One of the source types below | ||
+ | "Argument":, // An optional argument depending on the alert type | ||
+ | "Code":"", // A code for the alert, usually the variable that changed | ||
+ | "NewValue":"", // 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 IDs that should be notified of the event | ||
+ | "Icon":"", | ||
+ | "LocalTimestamp":, // The time when the alert was generated, as an Unix timestamp in UTC | ||
+ | "DeviceID":, // The ID of the device that generated the alert * | ||
+ | "DeviceName":"", // The name of the device that generated the alert * | ||
+ | "DeviceType":"", // The type of the device that generated the alert * | ||
+ | "Room":"", // The room where the device that generated the alert is * | ||
+ | "Category":, // The category of the device that generated the alert * | ||
+ | "SubCategory":, // The subcategory of the device that generated the alert * | ||
+ | "Expiration":"" // When the alert expires | ||
+ | } | ||
+ | |||
+ | ''* This info appears in the alert only if it was generated by a device.'' | ||
+ | |||
+ | The page on your event server must respond with a plain text response which should look like this: | ||
+ | { | ||
+ | "PK_Event":1234, | ||
+ | "Key":"12345678" | ||
+ | } | ||
+ | |||
+ | {{Warning|'''PK_Event''' must be a number, i.e. not surrounded by double quotes.}} | ||
+ | {{Warning|There must be no characters between <code>"PK_Event":</code> and the number.}} | ||
+ | {{Warning|"PK_Event" and "Key" are '''case sensitive'''.}} | ||
+ | {{Info|"PK_Event" can be any valid integer (e.g. 471993). "Key" can be any string, however, it's preferable to be a string representing a number (e.g. "85729059").}} | ||
+ | <br/> | ||
+ | |||
+ | == Setup == | ||
To use this alternate event logging set the top level user_data tag "AltEventServer" to the domain of your server. If your server is <tt>myserver.me.com</tt>, do this by changing the 'ip' to be the IP of Vera, and opening this URL: | To use this alternate event logging set the top level user_data tag "AltEventServer" to the domain of your server. If your server is <tt>myserver.me.com</tt>, do this by changing the 'ip' to be the IP of Vera, and opening this URL: | ||
− | http://ip:3480/data_request?id=variableset&Variable=AltEventServer&Value=myserver.me.com | + | http://ip:3480/data_request?id=variableset&Variable=AltEventServer&Value=myserver.me.com |
Then click ''Reload'' in Vera's UI to reload the engine with the changes. You can watch Vera send the data by logging into Vera's console as explained in [[Logon Vera SSH]] and then typing: | Then click ''Reload'' in Vera's UI to reload the engine with the changes. You can watch Vera send the data by logging into Vera's console as explained in [[Logon Vera SSH]] and then typing: | ||
− | tail -f /var/log/cmh/LuaUPnP.log | grep 'RAServerSync::SendAlert' | + | tail -f /var/log/cmh/LuaUPnP.log | grep 'RAServerSync::SendAlert' |
To stop logging to your own server, call the <tt>variableset</tt> again but leave the Value empty. | To stop logging to your own server, call the <tt>variableset</tt> again but leave the Value empty. | ||
Line 32: | Line 86: | ||
==== Alert Types ==== | ==== Alert Types ==== | ||
− | + | {| class="wikitable" | |
− | + | |style="text-align:right; padding:0px 10px 0px 20px;"| 1 | |
− | + | |style="padding-left:5px;"| ALERT_IMAGE | |
− | + | |- | |
− | + | |style="text-align:right; padding-right:10px;"| 2 | |
− | + | |style="padding-left:5px;"| ALERT_VIDEO | |
− | + | |- | |
− | + | |style="text-align:right; padding-right:10px;"| 3 | |
− | + | |style="padding-left:5px;"| ALERT_TRIGGER | |
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 4 | ||
+ | |style="padding-left:5px;"| ALERT_VARIABLE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 5 | ||
+ | |style="padding-left:5px;"| ALERT_LOGON | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 6 | ||
+ | |style="padding-left:5px;"| ALERT_GATEWAY_CONNECTED | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 7 | ||
+ | |style="padding-left:5px;"| ALERT_SYS_ERROR | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 8 | ||
+ | |style="padding-left:5px;"| ALERT_VALIDATE_EMAIL | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 9 | ||
+ | |style="padding-left:5px;"| ALERT_VALIDATE_SMS | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 10 | ||
+ | |style="padding-left:5px;"| ALERT_SYS_MESSAGE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 11 | ||
+ | |style="padding-left:5px;"| ALERT_TEST_SMS_EMAIL | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 12 | ||
+ | |style="padding-left:5px;"| ALERT_BURGLARY | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 13 | ||
+ | |style="padding-left:5px;"| ALERT_FIRE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 14 | ||
+ | |style="padding-left:5px;"| ALERT_INTERNET_DOWN | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 15 | ||
+ | |style="padding-left:5px;"| ALERT_GATEWAY_OFFLINE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 16 | ||
+ | |style="padding-left:5px;"| ALERT_DEVICE_OFFLINE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 17 | ||
+ | |style="padding-left:5px;"| ALERT_INSTALLER_ACCESS | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 18 | ||
+ | |style="padding-left:5px;"| ALERT_INSTALLER_ACCESS_ACTIVE | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 19 | ||
+ | |style="padding-left:5px;"| ALERT_WELCOME_EMAIL | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 20 | ||
+ | |style="padding-left:5px;"| ALERT_INSTALLER_WELCOME_EMAIL | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 21 | ||
+ | |style="padding-left:5px;"| ALERT_ACCOUNT_INVITATION_EMAIL | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 25 | ||
+ | |style="padding-left:5px;"| ALERT_NETWORK_INTERFACE_CHANGE | ||
+ | |} | ||
==== Source Types ==== | ==== Source Types ==== | ||
− | + | {| class="wikitable" | |
− | + | |style="text-align:right; padding:0px 10px 0px 20px;"| 1 | |
− | + | |style="padding-left:5px;"| SOURCE_USER | |
− | + | |- | |
+ | |style="text-align:right; padding-right:10px;"| 2 | ||
+ | |style="padding-left:5px;"| SOURCE_TIMER | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 3 | ||
+ | |style="padding-left:5px;"| SOURCE_TRIGGER | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 4 | ||
+ | |style="padding-left:5px;"| SOURCE_VARIABLE | ||
+ | |} | ||
==== File Formats ==== | ==== File Formats ==== | ||
− | + | {| class="wikitable" | |
− | + | |style="text-align:right; padding:0px 10px 0px 20px;"| 1 | |
− | + | |style="padding-left:5px;"| FORMAT_JPEG | |
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 2 | ||
+ | |style="padding-left:5px;"| FORMAT_MJPEG | ||
+ | |- | ||
+ | |style="text-align:right; padding-right:10px;"| 3 | ||
+ | |style="padding-left:5px;"| FORMAT_MP4 | ||
+ | |} |
Latest revision as of 15:32, 12 February 2018
Vera calls MiOS's event servers to report events, like sensor tripped, triggers, etc. MiOS's event servers send out text messages and emails to report these events.
Some very advanced users have asked to setup their own event server that Vera will call to report events. If you add your own, alternate event server, Vera will still send events to MiOS's event server unchanged, however Vera will also post the same event to the alternate server of your choice.
Contents |
[edit] UI5
- On 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):
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]
The page on your event server must respond with a plain text response which should look like this:
HTTP/1.1 200 OK Content-Length: n PK_Alert:x
- x is some number to identify the alert recorded on the server. It can be any number, and just PK_Alert:0 if you don't assign a number to the alert. Whatever it is will be put in Vera's logs along with the alert for cross reference.
- n is the content length, which is 9 plus the length of x (e.g. for PK_Alert:0 the content length is 10). The Content-Length parameter is optional.
[edit] UI7
- On UI7 Vera will send the event as a standard HTTPS (secure) POST to yourserver/event/event/event, passing the data as a json, like this (assuming your server is myserver.me.com):
https://myserver.me.com/event/event/event
{ "PK_Device":, // Serial number of Vera; in Lua you can get it with luup.pk_accesspoint "PK_Account":, // The account ID which the Vera unit is assigned to "LocalDate":"", // The time when the alert was generated, as human readable text "Severity":, "EventType":, // One of the alert types below "SourceType":, // One of the source types below "Argument":, // An optional argument depending on the alert type "Code":"", // A code for the alert, usually the variable that changed "NewValue":"", // 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 IDs that should be notified of the event "Icon":"", "LocalTimestamp":, // The time when the alert was generated, as an Unix timestamp in UTC "DeviceID":, // The ID of the device that generated the alert * "DeviceName":"", // The name of the device that generated the alert * "DeviceType":"", // The type of the device that generated the alert * "Room":"", // The room where the device that generated the alert is * "Category":, // The category of the device that generated the alert * "SubCategory":, // The subcategory of the device that generated the alert * "Expiration":"" // When the alert expires }
* This info appears in the alert only if it was generated by a device.
The page on your event server must respond with a plain text response which should look like this:
{ "PK_Event":1234, "Key":"12345678" }
PK_Event must be a number, i.e. not surrounded by double quotes. |
There must be no characters between "PK_Event": and the number.
|
"PK_Event" and "Key" are case sensitive. |
"PK_Event" can be any valid integer (e.g. 471993). "Key" can be any string, however, it's preferable to be a string representing a number (e.g. "85729059"). |
[edit] Setup
To use this alternate event logging set the top level user_data tag "AltEventServer" to the domain of your server. If your server is myserver.me.com, do this by changing the 'ip' to be the IP of Vera, and opening this URL:
http://ip:3480/data_request?id=variableset&Variable=AltEventServer&Value=myserver.me.com
Then click Reload in Vera's UI to reload the engine with the changes. You can watch Vera send the data by logging into Vera's console as explained in Logon Vera SSH and then typing:
tail -f /var/log/cmh/LuaUPnP.log | grep 'RAServerSync::SendAlert'
To stop logging to your own server, call the variableset again but leave the Value empty.
[edit] Alert Types
1 | ALERT_IMAGE |
2 | ALERT_VIDEO |
3 | ALERT_TRIGGER |
4 | ALERT_VARIABLE |
5 | ALERT_LOGON |
6 | ALERT_GATEWAY_CONNECTED |
7 | ALERT_SYS_ERROR |
8 | ALERT_VALIDATE_EMAIL |
9 | ALERT_VALIDATE_SMS |
10 | ALERT_SYS_MESSAGE |
11 | ALERT_TEST_SMS_EMAIL |
12 | ALERT_BURGLARY |
13 | ALERT_FIRE |
14 | ALERT_INTERNET_DOWN |
15 | ALERT_GATEWAY_OFFLINE |
16 | ALERT_DEVICE_OFFLINE |
17 | ALERT_INSTALLER_ACCESS |
18 | ALERT_INSTALLER_ACCESS_ACTIVE |
19 | ALERT_WELCOME_EMAIL |
20 | ALERT_INSTALLER_WELCOME_EMAIL |
21 | ALERT_ACCOUNT_INVITATION_EMAIL |
25 | ALERT_NETWORK_INTERFACE_CHANGE |
[edit] Source Types
1 | SOURCE_USER |
2 | SOURCE_TIMER |
3 | SOURCE_TRIGGER |
4 | SOURCE_VARIABLE |
[edit] File Formats
1 | FORMAT_JPEG |
2 | FORMAT_MJPEG |
3 | FORMAT_MP4 |