Got it Working with VeraPlus

I was able to integrate my Garadget with my VeraPlus by writing some lua code into a scene. The scene does not run manually, but does run when I have it triggered by a virtual switch named “Garage”. The code is:

local socket = require(‘socket’)
local https = require(‘ssl.https’)
local ltn12 = require(‘ltn12’)

https.TIMEOUT = 5

local body, code, headers, status = https.request(“https://api.particle.io/v1/devices/yourGaradgetID/setState","arg=open&access_token=youraccesstokenhere”)

This scene runs when the virtual switch is turned on. Write another scene changing open to close, and have it run when the switch is turned off. Now to buy a tilt sensor so that the virtual switch will stay in sync when the door is opened via the Garadget app! This is so cool!

Awesome!
If you have a moment, can you put together a step-by-step tutorial for the process?
Any interest in creating a vera plugin?

I have next to zero programming knowledge, so a plugin is beyond me at the moment. I searched the Vera forum and found a post regarding controlling Particle devices via LUUP here. This is what I did:

  1. Create a virtual switch named “Garage Door”
  2. Create a scene "Open Garage"
    Select the trigger to be a Device
    Choose Garage Door
    Garage Door is turned On
    Go to the next step
    Do not enter any devices in Step 2, click next at the bottom of the screen.
    In Step 3, scroll down to "Also, execute the following Luup code:"
    Click the arrow next to "No LUUP code defined"
    In the box that says “Enter your Luup code here” type the code in my first message, using your device ID and access token.
    Click Save Lua.
    Name the scene and click Finish.
  3. Repeat the Scene creation, triggered when the “Garage Door” switch is turned off, using “Close Garage” and “arg=close” in the code.

This will allow opening and closing the garage door in scenes in Vera. Note that for some reason the scene will not work when manually triggered- it seems to have to be triggered by a device. Also, the virtual switch can be out of sync when the Garadget app is used to open and close the door. I may install a tilt sensor on the door to keep it in sync, unless I can figure out how to poll another way. Again, no programming experience, so I may stick with the tilt sensor.

Hope this helps another Vera user that owns a Garadget.

Forgot to mention, this requires the latest firmware for the VeraPlus, 1.7.2414! Earlier versions corrupt the luup code.

1 Like

Note to all who might try this- it turns out the access token changes every 90 days or so. If this implementation stops working, you may need to find the new access token and update your lua code in the scene. I was pulling my hair out to find out why my switch stopped working, now I know!

I believe it is possible to generate an access token that doesn’t expire. See instructions on using curl for generating a token at https://docs.particle.io/reference/api/#generate-an-access-token . Just include “-d expires_in=0” in the curl command.