Simple Forwarding
A Cloud Action can be used to forward Events to another Stream. For example, you could use this to compute a status like an alert state in the cloud, and generate a new Event with the alert information including the device, value, the date/time when the alert was posted into the company stream for alerts, etc.:
The following is an example of a Cloud Action that parses the name of a device received in an Event, and forwards a new alert Event to a Stream named /my_company/alerts
indicating that the device has become too hot:
function(event) {
var deviceName = event.path.split("/")[3];
return {
"/my_company/alerts": [{"elems": {"device": deviceName, "alert": "too Hot!"}}]
}
}
The Stream with path
/my_company/alerts
must first exist before it can be read/written to in the Cloud Action. Create the Stream using the Cloud > Streams screen.
Updated over 4 years ago