Getting Amazon Alexa to talk to PINK

Community forum for discussion and support of the PINK product and development kit
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

Hi guys,
Have been working on a HVAC Project that utilizes PINK for the user interface w/web capabilities. http://forum.embeddedethernet.com/viewt ... f=8&t=2344

Recently got an Amazon Dot aka Alexa, (really cool), and started linking my other home automation devices with it; including the Harmony Hub- to turn on the TV and stereo, the Insteon hub (ISY), Alexa, turn on the Living Room Lights...
along with the music and other amusing things Alexa has, it is a great addition to any home automation system.

If you are not familiar with ISY: https://www.universal-devices.com/resid ... 4i-series/ ,izzy as Alexa calls it, this process of getting Alexa to change a NB_Var requires you have one and the account to have ISY portal access.
http://forum.universal-devices.com/topi ... isyportal/
This service is a 2 year subscription for about $1.75 a month.

The process is Alexa, set office thermostat to 70°; Alexa looks up "office thermostat" in her list of Smart Home Skills (Through the ISY portal), this changes a State Variable: "Office Thermostat" in the ISY 's Programs>Variables Tab to 70.
The ISY initiates a program to POST "70" to Nb_var02 on the PINK/index.html page. This is done with its Configuration>Networking>Network Recourse tab

You can only pass numbers not strings at this time.
Flow:
Alexa> ISY> PINK



Set up the Configuration>Networking>Network Recourse tab like this:
Click Add to set up Authorization to the PINK

Image

The Body of the resource editor is:
Nb_var02=${var.2.1}
${var.2.1}
2 = State var (1 for integer) we want State var to trigger the Program and POST the data
1 is the 1st State var ID Left column in Programs>Variables>State tab


This POST's ISY State variable in ID slot 1 to NB_var02

Make a program to trigger the event when $Office_thermostat changes

Image


Once you add the Spoken mapping through the Universal Devices Portal, My state variable = office_thermostat (1) and
clicking on the Discover Devices in the Amazon Alexa > Smart Home tab then you can get Alexa to change a Nb_var in PINK.






I am told that the PINK throws an error of 300 or 301 when Posting in this manor, maybe something on your end that could be fixed?

So far this has been a one way street of information flow I cannot get the PINK to send data to ISY.
I am not a HTML/.JS guru and in fact had plenty of help on the files in my PINK. I need help completing that step if PINK is to talk to ISY

This is the info I have:
if you put this in your web browser
http://ISY_IP/rest/vars/set/2/2/75

You get this
<RestResponse succeeded="true">
<status>200</status>
</RestResponse>

Which changes the 2nd state variable in the isy to 75

let me know if there is any other info I can provide.

Mike2545
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Getting Amazon Alexa to talk to PINK

Post by TomNB »

With regard to the post error codes of 300 or 301, it may be that your header is not correct. A description of error codes is here:
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

One way to determine what header you need is to use wireshark and capture a post to the PINK web page. Look at how the header if formed and use that in your ISY post.
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

Tom,
I took a look with wireshark, it does not seem to be that big of an issue. The vars are getting to PINK.

What I really need help with is-- code to send NB_Vars to ISY and keep them automatically updated.

Mike
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Getting Amazon Alexa to talk to PINK

Post by TomNB »

Hi Mike,

I'm probably missing something from your original post, so let me summarize to try and determine exactly what you are asking. You have 2 methods with the PINK to share variables

1. Use a serial command to send a UDP packet to an IP address
2. An outside device can scrape the web page and parse the data

Are you using the UDP method?
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

Tom, Currently I am using method 2.
This is probably as crude as it gets, The ISY POSTS through the IP address, sending a variable from the ISY to PINK, The way I outlined above.

This is a one way street like only the Tx not the Rx.
*only sending one byte of data at a data transfer event.

Now I would like the PINK to send data (the content of an Nb_var) to the ISY.
*would like to send 20 bytes of data (from pink to ISY) at a data transfer event.
**need to update the data every 30 seconds

Thanks for taking the time to read this :)

Mike


Edit:
After reading your post, I remembered seeing this
Image

is this what I need to set up?

Mike
Last edited by Mike2545 on Fri Jan 13, 2017 11:53 am, edited 2 times in total.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Getting Amazon Alexa to talk to PINK

Post by TomNB »

Hi Mike,

The PINK can send a UDP packet. Can the ISY receive one and parse it?

To clarify the "scrape" method, what I was trying to describe is a client device doing a HTTP GET, then parsing the received data. Similar to what you do when you go to the PINK web page and read it yourself.
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

Tom, thanks fo the clarification of scrape, I have not been able to get ISY to successfully scrape PINK.

I did find the UDP page in ISY
Image

would you be willing to see if we can set this up?

Mike
EDIT: The ISY cant receive UDP packets :(
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Getting Amazon Alexa to talk to PINK

Post by TomNB »

Hi Mike,

I'm not quite sure what you mean by can we set this up? I do not have a working knowledge of the ISY. I'm just trying to provide information on what the PINK can do. The NetBurner devices can pretty much do anything given time and programming. I'm just trying to stay within what the PINK application can do. In your screen shot it looks to me like that is the ISY sending a UDP packet, not receiving one.
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

Hi Tom, yeah "we" got excited on this end thinking there was a way to use udp to have 2 way communications between PINK and ISY.

This is the packet "we" will need to send.

Code: Select all

POST /rest/vars/set/2/2/75 HTTP/1.1\r\n
Host: ISY IP:ISY Port\r\n
Authorization: Basic YWRtaW46YWRtaW4=\r\n (Base64 of usrename=password ... so if username = admin and password is admin, use Base64(admin=admin) which will give you what you see there)
Content-Type: text/xml; charset="utf-8"\r\n
\r\n
I'll let you know if we succeed :D


Mike
Mike2545
Posts: 44
Joined: Wed Aug 20, 2014 6:07 pm

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 »

To use Netburner PINK with Alexa is not straightforward. I have been working with Tom from Net burner to make sure the PINK firmware was up to par. This is how I have it all working:

Image

There is isy info here on getting alexa to respond to what your vars are: http://forum.universal-devices.com/topi ... responses/
Last edited by Mike2545 on Wed Jan 25, 2017 12:26 pm, edited 1 time in total.
Post Reply