0

I know this is an obscure use case, but I am looking to understand what is happening...

So I have a home automation server (Vera by MiCasaVerde) that I can make s simple http request, and it will return a (kind-of large) JSON, which if you are interested looks like a (very familiar) call like this:

http://10.0.1.25:3480/data_request?id=status&output_format=json&DeviceNum=3

or using its "magic" port resolution I can make the call to port 80 like this:

http://10.0.1.25/port_3480/data_request?id=status&output_format=json&DeviceNum=3

that returns a JSON object like this:

{  
   "Device_Num_3":{  
      "states":[  
         {  
            "id":377,
            "service":"urn:upnp-org:serviceId:HVAC_FanOperatingMode1",
            "variable":"Mode",
            "value":"Auto"
         },
         {  
            "id":378,
            "service":"urn:micasaverde-com:serviceId:HVAC_OperatingState1",
            "variable":"ModeState",
            "value":"Cooling"
         },
         {  
            "id":379,
            "service":"urn:micasaverde-com:serviceId:HVAC_OperatingState1",
            "variable":"ModeStateForEnergy",
            "value":"1"
         },
         {  
            "id":380,
            "service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1",
            "variable":"ModeStatus",
            "value":"CoolOn"
         },
         {  
            "id":381,
            "service":"urn:upnp-org:serviceId:HVAC_UserOperatingMode1",
            "variable":"ModeTarget",
            "value":"CoolOn"
         },
         {  
            "id":382,
            "service":"urn:upnp-org:serviceId:TemperatureSensor1",
            "variable":"CurrentTemperature",
            "value":"76"
         },
         {  
            "id":383,
            "service":"urn:upnp-org:serviceId:TemperatureSetpoint1",
            "variable":"AllSetpoints",
            "value":"40.000000,75.000000,0.000000"
         },
         {  
            "id":384,
            "service":"urn:upnp-org:serviceId:TemperatureSetpoint1",
            "variable":"CurrentSetpoint",
            "value":"75"
         },
         {  
            "id":385,
            "service":"urn:upnp-org:serviceId:TemperatureSetpoint1",
            "variable":"SetpointTarget",
            "value":"75.0"
         },
         {  
            "id":386,
            "service":"urn:upnp-org:serviceId:TemperatureSetpoint1_Cool",
            "variable":"CurrentSetpoint",
            "value":"75"
         },
         {  
            "id":387,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"Configured",
            "value":"1"
         },
         {  
            "id":388,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"ModeSetting",
            "value":"1:;2:;3:;4:"
         },
         {  
            "id":389,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"LastUpdate",
            "value":"1438438497"
         },
         {  
            "id":390,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"FirstConfigured",
            "value":"1438438497"
         },
         {  
            "id":391,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"LastTimeCheck",
            "value":"1469292556"
         },
         {  
            "id":392,
            "service":"urn:micasaverde-com:serviceId:HaDevice1",
            "variable":"LastTimeOffset",
            "value":"-4"
         },
         {  
            "id":393,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"ManufacturerInfo",
            "value":"16,1,2"
         },
         {  
            "id":394,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"Capabilities",
            "value":"210,156,0,4,8,6,L,R,B,RS,|49:1,64:1,66,67,68,69,112,114,118,129,133,134,"
         },
         {  
            "id":395,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"NodeInfo",
            "value":"31,40,42,43,44,45,70,72,76,81,85,86,"
         },
         {  
            "id":396,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"SetPointInfo",
            "value":"H1,C1,"
         },
         {  
            "id":397,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"ConfiguredAssoc",
            "value":""
         },
         {  
            "id":398,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"PollSettings",
            "value":"60"
         },
         {  
            "id":399,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"VersionInfo",
            "value":"6,2,64,20,9"
         },
         {  
            "id":400,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"Neighbors",
            "value":"1,3,4,5,6,7,8,9,12,13,14,15,16,17,26,27,31,32,33,34,35,"
         },
         {  
            "id":401,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"LastReset",
            "value":"1438438497"
         },
         {  
            "id":402,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"AssociationNum",
            "value":"1"
         },
         {  
            "id":403,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"TemperatureScale",
            "value":"0,1,1"
         },
         {  
            "id":404,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"PollOk",
            "value":"43881"
         },
         {  
            "id":405,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"LastRouteUpdate",
            "value":"1469322032"
         },
         {  
            "id":406,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"PollNoReply",
            "value":"880"
         },
         {  
            "id":407,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"LastNnu",
            "value":"1469340000,714"
         },
         {  
            "id":408,
            "service":"urn:micasaverde-com:serviceId:ZWaveDevice1",
            "variable":"LastArr",
            "value":"1469340000,714"
         },
         {  
            "id":409,
            "service":"urn:micasaverde-com:serviceId:ZWaveNetwork1",
            "variable":"ConsecutivePollFails",
            "value":"0"
         },
         {  
            "id":410,
            "service":"urn:micasaverde-com:serviceId:GenericSensor1",
            "variable":"CurrentLevel",
            "value":"79"
         }
      ],
      "Jobs":[  

      ],
      "PendingJobs":0,
      "tooltip":{  
         "display":0
      },
      "status":-1
   },
   "Using_2G":0,
   "LoadTime":1469220487,
   "DataVersion":220509446,
   "UserData_DataVersion":220487076,
   "TimeStamp":1469361166,
   "lights_on":2,
   "lights_off":9,
   "doors_locked":5,
   "doors_unlocked":2,
   "sensors_tripped":0,
   "sensors_not_tripped":8,
   "failed_devices":8,
   "visible_devices":93,
   "partitions_active":0,
   "partitions_notactive":2,
   "alerts":[  
      {  
         "PK_Device":154,
         "Room":10,
         "DeviceName":"Laundry Door Lock",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorLock:1",
         "PK_Alert":"4802550961",
         "LocalDate":"2016-07-22 17:26:22",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":2,
         "LocalTimestamp":1469222782,
         "Code":"DL_LOW_BATTERY",
         "NewValue":"1",
         "Description":"Laundry Door Lock",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":154,
         "Room":10,
         "DeviceName":"Laundry Door Lock",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorLock:1",
         "PK_Alert":"4802551121",
         "LocalDate":"2016-07-22 17:26:22",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":2,
         "LocalTimestamp":1469222782,
         "Code":"DL_VERY_LOW_BATTERY",
         "NewValue":"1",
         "Description":"Laundry Door Lock",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":154,
         "Room":10,
         "DeviceName":"Laundry Door Lock",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorLock:1",
         "PK_Alert":"4802551251",
         "LocalDate":"2016-07-22 17:26:22",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":2,
         "LocalTimestamp":1469222782,
         "Code":"SL_BATTERYALARM",
         "NewValue":"0",
         "Description":"Laundry Door Lock",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":150,
         "Room":23,
         "DeviceName":"Kids Bath Motion",
         "DeviceType":"urn:schemas-micasaverde-com:device:MotionSensor:1",
         "PK_Alert":"4802551401",
         "LocalDate":"2016-07-22 17:26:22",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":2,
         "LocalTimestamp":1469222782,
         "Code":"SL_BATTERYALARM",
         "NewValue":"10",
         "Description":"Kids Bath Motion",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":59,
         "Room":17,
         "DeviceName":"GH Garage Door",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorSensor:1",
         "PK_Alert":"4802562881",
         "LocalDate":"2016-07-22 17:27:46",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":1,
         "LocalTimestamp":1469222866,
         "Code":"DL_ARMEDTRIPPED",
         "NewValue":"0",
         "Description":"GH Garage Door",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":59,
         "Room":17,
         "DeviceName":"GH Garage Door",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorSensor:1",
         "PK_Alert":"4803130171",
         "LocalDate":"2016-07-22 18:27:24",
         "EventType":12,
         "SourceType":3,
         "Argument":0,
         "Filesize":0,
         "Severity":0,
         "LocalTimestamp":1469226444,
         "Code":"",
         "NewValue":"1",
         "Description":"",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"burglar.png",
         "PK_Store":"0"
      },
      {  
         "PK_Device":59,
         "Room":17,
         "DeviceName":"GH Garage Door",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorSensor:1",
         "PK_Alert":"4803130271",
         "LocalDate":"2016-07-22 18:27:24",
         "EventType":3,
         "SourceType":3,
         "Argument":0,
         "Filesize":0,
         "Severity":1,
         "LocalTimestamp":1469226444,
         "Code":"DL_ARMEDTRIPPED",
         "NewValue":"1",
         "Description":"",
         "Users":"1061485",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":79,
         "Room":19,
         "DeviceName":"Main_Garage",
         "DeviceType":"urn:schemas-upnp-org:device:DigitalSecurityCamera:1",
         "PK_Alert":"4803134431",
         "LocalDate":"2016-07-22 18:27:54",
         "EventType":2,
         "SourceType":1,
         "Argument":0,
         "Filesize":5055210,
         "Severity":0,
         "LocalTimestamp":1469226474,
         "Code":"",
         "NewValue":"",
         "Description":"Main_Garage",
         "Users":"",
         "Server_Storage":"vera-us-oem-storage11.mios.com",
         "Key":"1085348817",
         "Icon":"camera.png",
         "PK_Store":"1017965291",
         "Format":"mp4"
      },
      {  
         "PK_Device":59,
         "Room":17,
         "DeviceName":"GH Garage Door",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorSensor:1",
         "PK_Alert":"4803142721",
         "LocalDate":"2016-07-22 18:28:48",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":1,
         "LocalTimestamp":1469226528,
         "Code":"DL_ARMEDTRIPPED",
         "NewValue":"0",
         "Description":"GH Garage Door",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      },
      {  
         "PK_Device":78,
         "Room":3,
         "DeviceName":"Front Door L\/R",
         "DeviceType":"urn:schemas-micasaverde-com:device:DoorLock:1",
         "PK_Alert":"4817901641",
         "LocalDate":"2016-07-23 22:59:56",
         "EventType":4,
         "SourceType":4,
         "Argument":0,
         "Filesize":0,
         "Severity":3,
         "LocalTimestamp":1469329196,
         "Code":"DL_USERCODE",
         "NewValue":"UserID=\"1\" UserName=\"Main\"",
         "Description":"Front Door L\/R",
         "Users":"",
         "Server_Storage":"",
         "Key":"",
         "Icon":"",
         "PK_Store":"0"
      }
   ],
   "ZWaveStatus":1,
   "Mode":1,
   "LocalTime":"2016-07-24 07:52:46 D"
}

Which is telling me everything about my Air Conditioner which is controlled by a Z-Wave thermostat.

Now, this server won't allow a JQuery (i.e. $.getJSON()) request as it seems to need authentication for a JavaScript function to work. Further, CORS is not an option, as it is not supported by the server.

I was advised to either 1) create a proxy for the server or 2) install the JavaScript libraries on the server (Vera). Neither of these things I can do with out a bunch of research, and probably adding software to my web server. etc.

This seems odd to me because I can make any un-authenticated http request (type the above link in my browser) to this server and get the data back on my browser.

Does anyone have a suggestion to offer-up? My thought was to have a Raspberry Pi or even a script on my Mac server query the Vera server... but I'm afraid I'll run into the same issue.

Can anyone explain to me how it could be that any browser on my LAN can make a http request and get answered, but I cannot get that same functionality from my website using JavaScript?

Jim from Princeton
  • 481
  • 1
  • 5
  • 16
  • 1
    So what is your goal exactly? Easy solution disable security on your browser for your end point, better solution set up a simple NodeJS or another proxy which can get around the issue. – epascarello Jul 25 '16 at 21:20
  • Oh yeah, well my goal was an AJAX call to server to get updates (like the temperature in the above example) and include it on my website, but that won't work (as caveated above) so I thought I would try to just parse the http request, some other way? The website will only be used on my LAN. – Jim from Princeton Jul 25 '16 at 21:25
  • 1
    Well a bad solution is this: http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome A good solution would be to a proxy https://github.com/nodejitsu/node-http-proxy – epascarello Jul 25 '16 at 21:28
  • @epascerell, I read your updated comments, and I'm keen on a Node.JS proxy... I'm going to have to research that a bit; coming from not knowing anything about such a tool. Is there a resource you could point me to which you are already familiar? – Jim from Princeton Jul 25 '16 at 21:30
  • @epascerell, I was able to get it work with a Node.js library called "reverse-proxy" and it is working well. Thanks for the hints! – Jim from Princeton Jul 29 '16 at 10:36

0 Answers0