Go Back   HomeSeer Message Board > Internet or Network Related Plug-ins > Internet or Network Discussion

Thread Tools Display Modes
Old May 30th, 2017, 08:45 AM
jventerprises jventerprises is offline
Join Date: May 2017
Location: MA
Posts: 4
Sending HTTPS commands to Particle Photon

hi all,

converting from a vera to HS3 finally, and wanted to get peoples advice on the best way to send commands to my particle photon. Basically I need to send SSL commands to send and get data.

Lets start with the easy one, the code below would send a message to my photon. in vera i would do this via Luup:
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/{device}/led","arg=9,255,255,0&access_token={token})

return true
very simple, it would basically POST via SSL to my photon.

What would be the best way to do something like this via scripting in HS3?
Reply With Quote
Old May 30th, 2017, 12:17 PM
mrhappy mrhappy is offline
Join Date: Nov 2007
Location: W.Mids, UK
Posts: 7,344
Take a look at my example here which should get you going; https://forums.homeseer.com/showthread.php?t=175638
Reply With Quote
Old May 30th, 2017, 12:42 PM
jventerprises jventerprises is offline
Join Date: May 2017
Location: MA
Posts: 4
Perfect. I ended up with this code:

Const LT As String = "Particle"
Const DeviceID As String = "deviceID"
Const AccessToken As String = "AccessToken"

Sub Main(Parm As Object)

Dim URL As String = "https://api.particle.io/v1/devices/" & DeviceID & "/led" 'led is the name of our access point
Dim responsebytes() As Byte
Dim commandToSend As String = "9,255,255,0"

Using Wclient As New Net.WebClient
Dim headerlist As New Specialized.NameValueCollection
headerlist.Add("access_token", AccessToken) 'Send the access token
headerlist.Add("params", commandToSend) 'to match the entry command in the spark code
responsebytes = Wclient.UploadValues(URL, "POST", headerlist)
hs.writelog(LT, "Reply: " & System.Text.Encoding.ASCII.GetString(responsebytes))
End Using

Catch ex As Exception : hs.writelog(LT, "Exception: " & ex.Message.ToString)
End Try
End Sub

and I get this in the log:
May-30 12:26:42 PM Particle Reply: {"id":"devideID","last_app":"","connected":true,"return_valu e":1}

Reply With Quote
Old July 13th, 2018, 10:37 AM
jventerprises jventerprises is offline
Join Date: May 2017
Location: MA
Posts: 4
No longer working

This worked for quite sometime, but during the last update on Homeseer for me it stopped.

when i run the script i now get

Exception: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure

and i really dont know enough to know why.

If i run my command via curl on my pc everything works so i know my token/device_id/events etc are all ok.

any ideas on what to check?

also, does anyone have an example calling curl from a vb script? i could do that just as easy as webclient

Last edited by jventerprises; July 13th, 2018 at 01:34 PM.
Reply With Quote
Old July 13th, 2018, 03:20 PM
jventerprises jventerprises is offline
Join Date: May 2017
Location: MA
Posts: 4
using curl and particle functions

well, i figured out how to replace the webclient which no longer works with curl, and have posted what i did to help others.

first, i have a particle device that accepts a function called led. it has 4 arguments: led, red, green, blue. these get passed to the particle function as a string like this: led,red,green, blue

i used
  • putty to get into homeseer
  • winSCP to transfer files back and forth
  • dos2unix to remove all the hidden windows formatting since i wrote on my PC

i created script called jons_curl.sh and placed in into /usr/local/HomeSeer/scripts.


echo $PARAM

curl https://api.particle.io/v1/devices/[id]/led -d arg=$PARAM --data-urlencode access_token=[token]

i added that directory to the path
export PATH=$PATH:/usr/local/HomeSeer/scripts)
i made sure the script was executable:
chmod +x jons_script.sh
i checked that it works by typing on the command line
./jons_curl.sh 10 255 128 64
now create an event in Homeseer and select RUN ANOTHER PROGRAM OR PROCESS not (RUN A SCRIPT), select your script and add you params under the advanced tab. params here should be seperated by spaces, not commas.

and you are done!
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adventures with Spark/Particle Core and HS3 mrhappy HomeSeer General Discussion Area 13 September 27th, 2017 05:01 PM
Commands not sending wcwolff UPB plugin by Spud (3P) 3 October 19th, 2015 07:32 AM
Problems sending commands doublejj0305 UltraGCIR HSPI 1 March 30th, 2011 05:25 PM
Sending TCP commands english_1969 HSTouch™ 2 April 6th, 2010 09:37 PM
Problem sending commands picta HAI/OnQ Panel (HS2) 7 March 24th, 2010 12:14 AM

All times are GMT -4. The time now is 02:33 AM.

Copyright HomeSeer Technologies, LLC