Please complete Part 1 of this tutorial
- This recipe is a continuation of the Avnet to Alexa Smart Home Demo (AV04), so make sure that you have part 1 completed first.
Configure your Node RED Code
- In Node RED, configure the node â€śOutput to dashboardâ€ť as follows, where XXXX is the four digits of your device ID:
Register your Device
Go to your bluemix consoleÂ and scroll down to select the appropriate iotf service.
- Click on â€śLaunchâ€ť to access your Bluemix Services dashboard:
- Hover your mouse over the icons to the left to open up the pop-out menu, then select â€śDevicesâ€ť. Click â€śAdd Deviceâ€ť in the top right corner of the screen.
- Click on â€śCreate device typeâ€ť, then click â€śCreate device typeâ€ť again.
- Enter â€śZentriDeviceâ€ť for the Name and add an optional description and click next to skip through rest of the windows until you reach the last page – Metadata. Click â€śCreateâ€ť and you should now see a â€śZentriDeviceâ€ť device type.
- Click â€śNextâ€ť and enter in your â€śzentri_XXXXâ€ť device ID from earlier. Skip through the remaining windows and click the â€śXâ€ť when finished.
Create a Device Schema
- You will now need to create a device schema – Select the â€śManage Schemasâ€ť tab on the top menu from the devices page to create a device schema.
- Click â€śAdd Schemaâ€ť In the top right corner, select â€śZentriDeviceâ€ť for your device type and press â€śnextâ€ť.
- Click â€śAdd Propertyâ€ť and select the â€śFrom Connected Tabâ€ť, which will automatically import published properties.
- Tell Alexa to â€śstart publishingâ€ť to see properties appear on the menu. Select all by checking the box next to property.
- Click â€śFinishâ€ť. You should now see a schema listed as â€śZentriDeviceâ€ť back in the Schemas menu:
Create a Rule
- Hover your cursor over the icons to the left of the page again to open the pop-up menu again. Select â€śRulesâ€ť and then click on â€śCreate Cloud Ruleâ€ť.
- Enter a name for your rule, an optional description and select the â€śZentriDeviceâ€ť schema in the â€śApplies to:â€ť box.
- Click next and you should see an â€śIF/THENâ€ť Diagram. Under the IF condition, click the â€śNew Conditionâ€ť box and â€śSelect Propertyâ€ť to choose the property for the IF condition. Click on the triangle icon next to â€śdâ€ť to open up a drop-down list of additional nested properties select the â€ślight_levelâ€ť property.
- Leave the operator as â€ś>â€ť and enter an arbitrary value for the â€śValue:â€ť box as we are comparing whether the light is on or off. For this example, the value 200 is used. Click â€śOKâ€ť
- Now select the â€śNew actionâ€ť box to create a response to the IF condition. Click on â€śAdd Actionâ€ť to open up a new menu for editing. Give your action a unique name and description, then select â€śsend emailâ€ť for â€śTypeâ€ť. Press â€śNextâ€ť when complete.
- Now to configure your email, edit the subject line if you wish, and select â€śSpecific Peopleâ€ť under the â€śToâ€ť header. Enter the email address(es) you wish the notification to be sent to. In addition, you can also include emails for CC.
- When complete, press finish and click on â€śsaveâ€ť and â€śactivateâ€ť on the top right corner of the main rule menu to start your email notification application.
Test your Email Alerts
- Hover your cursor over the left pop-out bar and select â€śBoardsâ€ť. Then click on the â€śRule-Centric Analyticsâ€ť board.
- You will now see several â€ścardsâ€ť that display rule-related information. Try asking Alexa to â€śstart publishingâ€ť and shine a light on the light sensor to trigger the email to see how these cards react.
- Check your email to see the notification.
Extend this Application!
- Once you have successfully built this application, feel free to experiment with different IF conditions and THEN actions. There are many other actions that can be implemented with rules, such as triggering a Node-RED flow, IFTTT, etc.