Create a Function to Automate the Process

Functions provide the capability to execute the custom business rules.

In this example, you will use Functions to check the starting motion date and time, and give it a statement to send a mobile notification as an alert.

  1. To create a Function, click User Functions > Functions.
    Figure 1.


  2. Click New Function.
  3. Add the Function name as notification.
    Figure 2.


  4. In the Code field, enter the code provided in notification_Functions.py. Complete with the information required at the beginning. Complete the PATH with your own values.
  5. Add an Event Trigger as follows:
    spaces/YourSpaceID/categories/YourCategory/things/YourThingUID/properties/start

    When using this method, the function will be invoked whenever there is a change on the Property start on the Thing you have created.

    Figure 3.


  6. Deploy your Function by clicking Save.
    The Function is created. This could take a few minutes. The status of your Function will be updated to a Building status and, eventually, it will become Running. At this point, your Function is ready to be called.