This is the continuation of https://forum.chipchop.io/post/310/ on the IoT Notification feature
New ImprovementThis is a small improvement to the Notifications system. You have now the option to automatically append to the notification message the status of the component you are monitoring.
This almost works as if you were triggering the notification directly from a device and you can enable/disable it anytime.
You will find a tick box under the notification message field labeled "Include Component Status". When ticked (default) the status of the component will be added after the message
You can see one example in the picture below. The other option where this becomes really interesting is that you can create an extra "fake" component and use it to create whatever status you want like sending a completely custom message from the device each time.
Small downsideThis particular setup would require you to sacrifice one component to act as a "notifier" so if you need all 10 components it may be a problem but I will see if I can automatically allocate the "notification" component as a built in part of every device.
The plan is anyway to eventually add a notificationEvent() but that will take time.
Steps:1. In the Dev Console add a fake "Text" component to your device and name it something like "notifier"
2. On your device based on whatever logic you have you can simply set the status of the "notifier" component and pass it to ChipChop like it was any other real component.
...you've done some logic here and you want to notify yourself immediately with a custom message
ChipChop.triggerEvent("notifier","sensors 1 & 2 failure detected"); //sends the status immediately
// use some keyword that will not trigger the notification action (see Action explanation below)
ChipChop.updateStatus("notifier", "STOP"); //<< this is important to prevent a flood of messages
3. Create a new action and set
Trigger Device = Motion Sensors
Trigger Component = Notifier
Value is Not Equal != "some short stop value" <<<< use whatever you know you will never send like "stop", "STOP", "pause", "###" etc. This is the keyword we have used in the example above
Target = Notification
Notification Text = "Motion Sensors Warning -> " //<< I've added "-> " on purpose at the end with an extra space
Include Component Status = Ticked
That's it!
The notification that you will receive would look like this
Motion Sensors Warning -> sensors 1 & 2 failure detectedSo, what is happening here. We are creating an action rule that will execute and trigger the notification on any message (status)
except when it encounters the stop keyword. (double negative I guess)
The code on the device is using a triggerEvent to instantly send the message and we are immediately changing the status of the "notifier" component to the stop word so on the next heartbeat the action's logic will be invalid and will be ignored
Enjoy!