Author Topic: UI6 and HTTPS access (remote) Problems  (Read 6460 times)

Offline jventerprises

  • Sr. Newbie
  • *
  • Posts: 34
  • Karma: +1/-0
UI6 and HTTPS access (remote) Problems
« on: June 04, 2014, 10:27:16 am »
Hi,

I have UI6 running with very little problems. However, I used to access my veralite via the following links when outside my LAN

https://us-relay12.mios.com/<username>/<password>/<vera_ID>/data_request?id=user_data


I would use various lu_variableget commands to get various states of my devices.  I can no longer do that.  I get the following error:

ERROR:Module not found:<username>

Is this just a UI6 (MMS) thing or am i missing something...


Offline garrettwp

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6376
  • Karma: +226/-128
  • Vera 3, Lite, ISY994
Re: UI6 and HTTPS access (remote) Problems
« Reply #1 on: June 04, 2014, 10:54:29 am »
UI6 uses MMS authentication which is drastically different from UI5 and the URL that you are using. The URL you provided is for UI5 remote access. MMS authentication is more complex and requires many steps. Think openauth. To summarize there is no easy way to do what you want in UI6 with out the complexity of the MMS authentication.

Have a look here for some details:

http://forum.micasaverde.com/index.php?topic=24942.0

- Garrett
« Last Edit: June 04, 2014, 10:59:48 am by garrettwp »

Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #2 on: June 16, 2014, 06:47:27 am »
Hi All,

I have created the functionality to request remotely using MMS authentication. I am able to read the user data from unit.

but when I am trying to create the scene using http request, it just responding with ERROR.

I am sending the JSON object as a json post parameter to create scene http request.

can any buddy help me please.

Thanks


Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9432
  • Karma: +716/-133
    • RTS Services Plugins
Re: UI6 and HTTPS access (remote) Problems
« Reply #3 on: June 16, 2014, 08:42:26 am »
Other than authentication ... and the url prefix .... there is no difference between running locally and remotely.

Have you verified your code works properly with LOCAL access, or UI5 access ?
With LOCAL access it will probably work with a GET method ... but you need to verify your logic with the POST method.



Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #4 on: June 17, 2014, 02:30:40 am »
Yes, I have two accounts one is running ui5 and other is ui6.

Create scene works perfect with ui5. I am using same data format to request for a UI6 unit.

I am sending the json string as a POST parameter because the string is very long.

Every thing is work fine with UI5. But dont know what is the issue with UI6.

Following are the details for your reference

URL :

https://XXXX/relay/relay/relay/device/XXXX/port_3480/data_request?id=scene&action=create

POST data

{"scene_name":"turn of living therm","name":"turn of living therm","groups":[{"delay":0,"actions":[{"device":"10","service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1","action":"SetModeTarget","arguments":[{"name":"NewModeTarget","value":"Off"}]}]}],"triggers":[{"name":"sensor tripped","enabled":1,"device":"7","template":"2","arguments":[{"id":1,"value":"1"}]}],"timers":[],"lua":""}



Please advice



Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9432
  • Karma: +716/-133
    • RTS Services Plugins
Re: UI6 and HTTPS access (remote) Problems
« Reply #5 on: June 17, 2014, 10:40:37 am »
The post data should be:

json={"scene_name":"turn of living therm","name":"turn of living therm","groups":[{"delay":0,"actions":[{"device":"10","service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1","action":"SetModeTarget","arguments":[{"name":"NewModeTarget","value":"Off"}]}]}],"triggers":[{"name":"sensor tripped","enabled":1,"device":"7","template":"2","arguments":[{"id":1,"value":"1"}]}],"timers":[],"lua":""}

And the value of the json parameter must be URL encoded (might be handled by the software you are using).

Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #6 on: July 17, 2014, 05:05:35 am »
Hi,

thanks for your advice.

I was implemented the MMS authentication successfully for the vera UI6. It was working fine.
But after some days its start creating the problems. And there is no response from the locator & account services.

We have implemented the MMS authentication as below.
 
1. By using username and password of vera 6 unite we request
   "authenticate account"  using below url
   "https://us-autha11.mios.com/autha/auth/username/UserName?SHA1Password=passwordSha&PK_Oem=1";
   
   By using above request we get the following result
   a. Identity
   b. IdentitySignature
   c. Server_Account
   
2. By using the Identity & IdentitySignature we are generating the SESSION token by using the following URL
   "us-authd11.mios.com"

3. Once we get the session token from "us-authd11.mios.com", we are trying to locate the server device IP(i.e. Server_Device) by using the following URL.
"http://Server_Account/account/account/account/PK_Account/devices";

where
 Server_Account = server account received from "https://us-autha11.mios.com/autha/auth/username/sUserName?SHA1Password=passwordSha&PK_Oem=1";
 PK_Account = base64 decode of Identity parameter received in step 1
 
 Note: We are also sending the Session token as header in above request.
 
4. But when we try to get the server device details using

"http://Server_Account/account/account/account/PK_Account/devices" it responding with the following error
 "WWW-Authenticate: MMSAuth error="invalid session".

 5. We are sure that the session is recently generated, so there is no possibility of using the expired session token. Also it was previously working fine for us. but from last few days it is not working properly.   
   

Please advice how can we send the HTTP request for the Vera UI6 version units.

Thanks

Offline garrettwp

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6376
  • Karma: +226/-128
  • Vera 3, Lite, ISY994
Re: UI6 and HTTPS access (remote) Problems
« Reply #7 on: July 17, 2014, 07:57:25 am »
Please see this thread as the url's have changed:

http://forum.micasaverde.com/index.php?topic=25859.0

- Garrett


Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #8 on: July 28, 2014, 05:59:37 am »
Hi,

I have modified the server URl and it works for me.

Thanks !!!


There is one more query,

We can get the external IP address of UI6  unit by parsing the response from Server_Device/device/device/device.


Is there any way to get the 'External IP' address of UI5 unit unig HTTP request or by using any API call?

I want this external IP address of UI5 devices to stream the camera videos.


Thanks



Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #9 on: August 05, 2014, 07:32:45 am »
I have two accounts one is running ui5 and other is ui6.

Create scene works perfect with ui5. I am using same data format to request for a UI6 unit.

I am sending the json string as a POST parameter because the string is very long.

Every thing is work fine with UI5. But dont know what is the issue with UI6.

Following are the details for your reference

URL :

https://vera-us-oem-relay12.mios.com/relay/relay/relay/device/35020991/port_3480/data_request?id=scene&action=create

POST data

{"scene_name":"if master bed is off then 2 thrmostat is heat on","name":"if master bed is off then 2 thrmostat is heat on","groups":[{"delay":0,"actions":[{"device":"11","service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1","action":"SetModeTarget","arguments":[{"name":"NewModeTarget","value":"HeatOn"}]}]}],"triggers":[{"name":"testing tiggers","enabled":1,"device":"9","template":"1","arguments":[{"id":1,"value":"Off"}]}],"timers":[],"lua":""}


we post data using curl with MMSSession token


$ch = curl_init ($url);               
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("MMSSession:$sessionToken"));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 60); //timeout in seconds
      if($aPostData != null)
      {
         $fields_string = '';
         foreach($aPostData as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
         $fields_string = rtrim($fields_string, '&');
         curl_setopt($ch,CURLOPT_POST, count($aPostData));
         curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
         //print_r(count($aPostData));
         //print_r($aPostData);
         
         
      }
      
      $result = curl_exec($ch);
      

if i am print this  $result varible then it's show 'ERROR'      



Please advice

Thanks

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9432
  • Karma: +716/-133
    • RTS Services Plugins
Re: UI6 and HTTPS access (remote) Problems
« Reply #10 on: August 07, 2014, 11:01:33 am »
Did you get an AuthToken and then create and attach a SessionToken to the Headers for UI6 ?

Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #11 on: September 18, 2014, 07:59:36 am »
Hello ,
   
   i am attached Authtoken to header but not working

   like below code

   function make_curl_request_with_session($url,$aPostData,$sessionToken,$AuthToken)
   {
      
      $ch = curl_init ($url);               
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("MMSAuth:$AuthToken","MMSSession:$sessionToken"));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 60); //timeout in seconds
      if($aPostData != null)
      {
         $fields_string = '';
         foreach($aPostData as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
         $fields_string = rtrim($fields_string, '&');
         curl_setopt($ch,CURLOPT_POST, count($aPostData));
         curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
      }
      
      $result = curl_exec($ch);
      //print_r($result);die('curl with session');
      if(curl_errno($ch))
      {
         $error = curl_error($ch);
         curl_close ($ch);         
         return $error;
         
      }else
      {
         curl_close ($ch);
         return $result;
      }
   }
   
   FYI
   delete scene command  is working fine for UI6.
   
   

   Please advice

 Thanks
 
 Abhijit S

Offline shrik

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: UI6 and HTTPS access (remote) Problems
« Reply #12 on: November 04, 2014, 03:26:29 am »
Hello,

 I have upgrade UI5 to UI7 but we unable to create scene automation

 Before I have UI5 account then I upgrade to UI7 

Create scene worked perfect with ui5. I am using same data format to request for a UI7 unit.

I am sending the json string as a POST parameter because the string is very long.

Every thing is worked fine with UI5. But dont know what is the issue with UI7.

Following are the details for your reference

URL :

https://vera-us-oem-relay41.mios.com/relay/relay/relay/device/35011801/session/0DD42F5FCF72EA43B0BE822C45A3A28E3B2608/port_3480/data_request?id=scene&action=create


POST data

{"scene_name":"if master bed is off then 2 thrmostat is heat on","name":"if master bed is off then 2 thrmostat is heat on","groups":[{"delay":0,"actions":[{"device":"11","service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1","action":"SetModeTarget","arguments":[{"name":"NewModeTarget","value":"HeatOn"}]}]}],"triggers":[{"name":"testing tiggers","enabled":1,"device":"9","template":"1","arguments":[{"id":1,"value":"Off"}]}],"timers":[],"lua":""}


we post data using curl with MMSSession token


$ch = curl_init ($url);               
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("MMSSession:$sessionToken"));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 60); //timeout in seconds
      if($aPostData != null)
      {
         $fields_string = '';
         foreach($aPostData as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
         $fields_string = rtrim($fields_string, '&');
         curl_setopt($ch,CURLOPT_POST, count($aPostData));
         curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
         //print_r(count($aPostData));
         //print_r($aPostData);
         
         
      }
     
      $result = curl_exec($ch);
     

if i am print this  $result varible then it's show 'ERROR'     



Please advice

Thanks

Offline garrettwp

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6376
  • Karma: +226/-128
  • Vera 3, Lite, ISY994
Re: UI6 and HTTPS access (remote) Problems
« Reply #13 on: November 04, 2014, 09:42:30 am »
This will not work. The new authentication mechanism is  very different from UI5. It is much more complicated and requires multiple steps to authenticate before you can send request to the relay server.

Please see here for details:

http://forum.micasaverde.com/index.php?topic=24942.0

- Garrett
« Last Edit: November 04, 2014, 09:49:15 am by garrettwp »