-
Notifications
You must be signed in to change notification settings - Fork 4
Events
Whenever something happens on Thinglator an event is triggered and logged. All these events can be accessed using a REST API.
For example, an API request is received to turn a lightbulb on - this is the event that is created:
{
"_id":"57b874d54e861754ee019bf7",
"eventType":"device",
"driverType":"light",
"driverId":"lifx",
"deviceId":"1cc0fb99f3b867ab0035c6d67b797d8c",
"event":"state",
"when":"2016-08-20T15:18:45.618Z",
"value": {
"colour":{
"brightness": 0.50,
"saturation": 1,
"hue": 229.99679560540167245
},
"on":true
}
}
If you call GET /event/device then this event (along with any others) would be returned in a JSON array in order of occurrence. This API could be used to keep a home automation user interface up to date (the above event has enough information to show that the Lifx lightbulb is on and blue at a brightness of 50%). All events are consistent - it wouldn't matter if this was a Lifx or Philips Hue lightbulb, the event would look exactly the same.
###GET event/:eventType _E.g. GET event/device
Returns a list of device events in order of occurrence.
An optional (but recommended) query parameter of ?from=:eventId can be used to paginate the requests (it will then only return events that occurred after the specified event id). This is useful to avoid re-downloading and re-processing events that have already been dealt with.
_E.g. GET event/device?from=57b878ac4e861754ee019bf8