Gravio is an easy-to-use platform that enables anyone to create mini programs (called “Actions”) that can be built in a logic based manner which can be triggered from sensor data. In this tutorial, we learn how to trigger a camera taking a picture and sending it to an e-mail address.
We use a button sensor that triggers a camera to take a snapshot. The picture is then attached to an E-Mail and sent out to the recipient.
Our camera is mounted on a balcony and pointing towards a harbour. It is connected wirelessly to the same network as the Gravio HubKit is running. In our case the HubKit is running on macOS. Gravio HubKit has the ability to detect local network cameras, which is why the network camera will show up in this menu:
Once you click on it, you can enter your credentials and your camera is ready to be used.
Give it a unique name and remember its physical Device ID.
In our case here, the sensor is a simple Aqara button that can be pressed. First we pair the sensor with the Zigbee Dongle.
Plug the dongle into your computer
Restart your Gravio HubKit
Your Zigbee dongle will now show up under devices
Click the “Start Pairing” button and bring your sensor near the dongle. Press the “Pairing” button on the sensor for 5seconds until it appears in the log window
Next we add the area and data layer, and bind the new sensor device to it
Enable the sensor by checking the checkbox
Your sensor is now ready to receive data. You can check if the data comes in by opening the Data tab, activating the “Live” button at the top right and triggering the sensor
Once confirmed that data comes in, you’re ready to use the sensor data.
The next step is to create the action that will be triggered by the sensor. In our case our action will take a picture from the camera and attach the image to an e-mail that will be sent to a pre-defined e-mail address.
Actions are created in the Action Editor
The action editor will open. Click the + signat the top right to add a new action. Give it a meaningful name and description
The action editor consists of components that are executed in sequence. You can add new components (or steps) by clicking the+ symbol in the square.
Enter the Device ID you remembered from Step 1 in the Device ID
If you add a path to “save to” the picture will be saved there
The filename will consist of the timestamp followed by the Device ID.
You can now trigger camera images to your location using play button on the top right.
In this step we want to show how to use the pictures. For example to send them via an e-mail attachment to a predefined e-mail address.
First you need to add the “split” component in order to turn the array coming from the image capture component into a single item to be processed.
Then you add the E-Mail component and fill all the fields
Note, you can “hard code” the smtp server settings here, or you can create a “base profile” in the HubKit settings andre-use that.
Note, in order to use a gmail smtp, you need to change the security setting to “allow reduced security apps” to access the smtp server.
Then you fill out the pre-mappings by adding the attachment and the HTML code of the e-mail
Try it by pressing the Play button. If you receive the e-mail with the attached picture, you’ve done it!
Now you’re now ready to trigger this action from the sensor data.
The trigger is used to trigger an action. The action will receive the data from the sensor, however in this application here, we do not need any sensor data. The button just acts as trigger.
Open the Trigger tab and click on the lightning on the top right. Give the trigger a meaningful name, ideally describing what should have happened if it gets triggered, and pick the condition under which it should trigger the action
Switch to the Action tab and pick the Action you would like to trigger
That’s it. Press the button and you should see a picture in your saved file path and receive an e-mail with the picture attached.
This concludes the tutorial. If you have any questions, suggestions or ideas, feel free to join our slack under https://link.gravio.com/slack