How to store sensor readings as variables in Switchur
Storing and processing variables based on the sensor readings of your smart devices extends the possibilities of your home automation projects with Conrad Connect even further. The rather easy to understand service provided by Switchur offers switch variables as well as counter elements. The binary switch simply toggles between ON and OFF whereas the counter is counting up or down. We show you how to set everything up.
1.When we tested the service, we decided to register a fresh Conrad Connect account. In order to transfer your hardware sensor readings into Switchur variables, you need to create Conrad Connect projects employing the Conrad Maker actuator for sending HTTP requests (also referred to as webhooks). Separating these projects from the 'regular' ones helped us keeping a clear overview.
All hardware you wish to create variables for needs to be properly connected to your Conrad Connect account. Even though we don't need to touch IFTTT at all, you ought to authenticate a valid IFTTT account as well. This will help us later to let Switchur trigger Conrad Connect projects directly.
Register for free at Switchur.
In our example we would like to transfer the current status of a window contact to Switchur in order to allow processing this information later on. So the three window contacts we have installed shall be represented by three binary switch variables.
- Go to the Switchboard and create a new binary switch and assign a meaningful name (here kontakt01)
- You can now edit the variable. Notice that you have different URLs that are meant to switch the variable between ON and OFF. Since we are dealing with doors sensors, we simply define OPEN = ON, CLOSED = OFF. If you look closely, you'll see that both the name of the variable and the intended state are part of the URL.
- Log on to Conrad Connect and create a new project. Since we want to store the state of our window contact sensors, we connect them to the Conrad Maker actuator. That is needed twice, one for OPEN (ON), one for CLOSED (OFF).
The Conrad Maker elements are to be configured as such:
- Content-type: application/json
- Trigger on states: either OPEN or CLOSED
- URL: use the respective URL as noted earlier
- Method: POST
- Limit to: Always
- If you want to define more variables simply repeat steps 4 to 6. Keep in mind that you can easily define up to four states for two binary variables within one project.
- It's now time to test the setup thoroughly! The actual state of your window in real life should correspond to what you can see on the Conrad Connect Dashboard as well as on the Switchboard. Don't forget to refresh your browser!
If all works as expected, your sensors states are now being reflected in Switchur as variables in real-time which allows further processing.
Alternatively, you can create a counter that's being counted up (n+1) or down (n-1) based on predefined sensor events. Important: A counter needs to be set to zero before you can start counting. A switch can only be toggled if it was set to either ON or OFF before.