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

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 » Wed Jan 25, 2017 11:58 am

This is what it looks like (most of it)

Image


This is a link to the Autelis module http://www.autelis.com/universal-rs232- ... e-isy.html

I have it eavesdroping on the com line with the x-bee wireless and it picks out the bytes I need to send to ISY from the PIC/PINK

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

Re: Getting Amazon Alexa to talk to PINK

Post by Mike2545 » Wed Jan 25, 2017 5:57 pm

Apparently, one could get the PINK to do what the Autelis is doing. I just don't know how.

Hi Mike,

I can give you an example BUT won't be able to help you with debugging, You will need to either understand HTTP protocol specification OR ask NetBurner for an HTTP client library. You have to send the following packet on your TCP connection

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

With kind regards,
Michel
UDI Tech Support
Universal Devices Inc.

And then this:

Hi mike2545,

Thanks for the update.

Whatever Autelis can do you can do from within PINK.

With kind regards,
Michel
UDI Tech Support
Universal Devices Inc.

does anyone have code to <POST> PINK vars in that manner? I am using the PINK with Pic Basic Pro ; Javascript/ jquery/ajax are not my strong suits.

If I put the address of the ISY in the browser I can change isy state var_32 = 75

Image


What we need is something like:
Green text already in PINK

Code: Select all

<script>
   var timeout;
   function bloop(){
 
	   $.ajax({
		   url: "/ajax.html",
		   success:function(result){
			   var array=result.split(','); 
			   for(i=0;i<array.length;i++){
				                                                               
   $("input[name='Nb_var"+array[i].substring(0,array[i].indexOf(':'))+"']").val(array[i].substring(array[i].indexOf(':')+1));
$url; username:password@192.168.1.157:8081/rest/vars/set2/indexOf/'Nbvar'&array
Post ;indexOf 'Nb_var'+array

Code: Select all

                        }
		}});
	
	timeout = window.setTimeout(function(){bloop()}, 4000);  
}
</script>
The above works , the red part I put in to demonstrate where we need the code, The ajax.html file is like this;

Code: Select all

01:<Nb_var01>,02:<Nb_var02>,11:<Nb_var11>,12:<Nb_var12>,21:<Nb_var21>
with only the vars you want updated



Mike2545

Post Reply