stockmopar / connectedbytcp

Connected by TCP Lights API
http://home.stockmopar.com
30 stars 14 forks source link

Is it still supposed to work? #1

Closed sebastienvg closed 9 years ago

sebastienvg commented 9 years ago

Hi Stockmopar,

I just tried to play around with your nodejs implementation of ConnectedByTCP but no luck. I tried on OSX with node 0.10.21 and I try on a raspbian with node 0.10.24 and I get the same error with both setup while trying for example:

node toggle.js

it returns

``RoomGetCarousel12000Hallway100000000img/room/black.png0002167783252632937161001189016386Entrance Ceiling LED0multilevel0100001TCPLED A19 11WLED7821TCP112167783252659351971000189016386Hallway's TableLED0multilevel09900001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel111Office1000bd1f1img/room/green.png00021677832526587224910096189016386Dev Bulb Office LED1multilevel09900001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel115Master Bedroom10845fcf5img/room/purple.png0002167783252626510931001189016386Seb's Night Table LED5multilevel0100001TCPLED A19 11WLED7821TCP11216778325266869307100100189016386Inka's Night Table LED5multilevel09900001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel118Living Room10ff59b78img/room/pink.png00036021446615555528410000061440Ambiance8multilevel09900001Light Fixture15921productinfo,identify,meter_power,switch_binary,switch_multilevel11 { gwrcmd: { gcmd: 'RoomGetCarousel', gdata: { gip: [Object] } } }

ReferenceError: results is not defined at /root/connectedbytcp/index.js:37:14 at module.exports (/root/connectedbytcp/node_modules/libxml-to-js/lib/libxml-to-js.js:187:3) at Request._callback (/root/connectedbytcp/index.js:34:3) at Request.self.callback (/root/connectedbytcp/node_modules/request/request.js:373:22) at Request.EventEmitter.emit (events.js:98:17) at Request. (/root/connectedbytcp/node_modules/request/request.js:1318:14) at Request.EventEmitter.emit (events.js:117:20) at IncomingMessage. (/root/connectedbytcp/node_modules/request/request.js:1266:12) at IncomingMessage.EventEmitter.emit (events.js:117:20) at _stream_readable.js:920:16``

I can't figure what I am doing wrong! Can you help?

kevincoleman commented 9 years ago

From what I’ve gathered, the lighting router is only communicating on port 443 now, instead of on 80. I have not researched it yet at this point, but I’m guessing that TCP did this to increase security of communications with their web app and/or to actively shut down any unofficial access via the use of encryption (since we don’t have access to their keys).

I’m a n00b to this stuff, but it’s what I’ve gathered. Here’s the error I started getting yesterday morning (I’ve yet to dig to see if this is just dev error, but my script stopped working without being touched):

agnes:connectedbytcp agnes$ node toggle.js undefined undefined

TypeError: Cannot read property 'gip' of undefined at /Users/agnes/dev/connectedbytcp/index.js:37:20 at module.exports (/Users/agnes/dev/connectedbytcp/node_modules/libxml-to-js/lib/libxml-to-js.js:189:3) at Request._callback (/Users/agnes/dev/connectedbytcp/index.js:34:3) at self.callback (/Users/agnes/dev/connectedbytcp/node_modules/request/request.js:372:22) at Request.emit (events.js:95:17) at Request.onRequestError (/Users/agnes/dev/connectedbytcp/node_modules/request/request.js:963:8) at ClientRequest.emit (events.js:95:17) at Socket.socketErrorListener (http.js:1551:9) at Socket.emit (events.js:95:17) at net.js:440:14

kevincoleman commented 9 years ago

I found this thread (http://community.smartthings.com/t/tcp-lighting-integration-issue-10-27/6199/136), which—while referring to a different product integration—explained what’s going on at TCP. Looks like they just pushed a firmware upgrade that broke all integrations (auth-related). The integrated product released a fix (I’m assuming that uses the new SSL auth), but we’d need to update this script to use the new auth method if we want it to work, I think. I’m contacting TCP currently about documentation on the auth switch.

sebastienvg commented 9 years ago

You are right, my firmware got updated last night, and now I am unable to use the internal IP in the browser even if I try https. Seems they want you to open a account in the cloud and use it to authenticate. Then the call is made to cloud server which in turns call the gateway probably trough vpn instead of a call to the gateway directly, in case of internet failure you can't use the light. Why would they break something that worked.

kevincoleman commented 9 years ago

I think they’re not really to be held at fault for improving security (which this does), but I’m not really sure if they intended for it to shut down people who use local scripts to access the system. I think it’s more a side effect, and I bet their official response will be “just use our app!”

Unfortunate, as the reason I bought this system is because I could custom script things like a daily-scheduled progressively brighter sunrise.

I’ll update this issue once TCP gets back to me. If they allow independent devs to auth their apps through the cloud system we might still be in luck.

stockmopar commented 9 years ago

I think this will still be possible locally. The iOS app had a new requirement when I connected locally. I had to press (more of a 1 second hold) upon the initial connect. I think there will be a similar step to authenticate the user. When I get a chance I will wireshark the process and post my findings (hopefully tomorrow).

On Jan 23, 2015, at 2:38 PM, Kevin Coleman notifications@github.com wrote:

I think they’re not really to be held at fault for improving security (which this does), but I’m not really sure if they intended for it to shut down people who use local scripts to access the system. I think it’s more a side effect, and I bet their official response will be “just use our app!”

Unfortunate, as the reason I bought this system is because I could custom script things like a daily-scheduled progressively brighter sunrise.

I’ll update this issue once TCP gets back to me. If they allow independent devs to auth their apps through the cloud system we might still be in luck.

— Reply to this email directly or view it on GitHub.

stockmopar commented 9 years ago

I've done it!!!!!

@kevincoleman @sebastienvg

The process involves:

/gwr/gop.php?cmd=GWRLogin&data=<gip><version>1</version><email>[myuuid]</email><password>[myuuid]</password></gip>&fmt=xml

<gip><version>1</version><rc>200</rc><token>[mytoken]</token></gip>

cmd=GWRBatch&data=<gwrcmds><gwrcmd><gcmd>RoomGetCarousel</gcmd><gdata><gip><version>1</version><token>[mytoken]</token><fields>name,image,imageurl,control,power,product,class,realtype,status</fields></gip></gdata></gwrcmd></gwrcmds>&fmt=xml

kevincoleman commented 9 years ago

Oh wonderful! Awesome work.

I can’t say I am familiar with all these steps, but I will try to make it work here too.

  1. How did you connect to the gateway?
  2. How to generate a UUID?
  3. (I can do that!)
  4. I think I can do this. I’d just write a small script and run it with node. Yea?
  5. Wireshark or console output to see this, I assume.
  6. Easy enough.
  7. Great to see the structure of the call with the token.

Thank you!

stockmopar commented 9 years ago

@kevincoleman @sebastienvg

I have updated the package with the new protocol. Give it a try and let me know how it goes.

Looking through the code should answer most of your questions but here are some direct answers to your above questions.

Connecting to the gateway is done with a https request call. It is important to set the option flag rejectUnauthorized to false during the call.

General format of the call is:

var https = require('https');
...
TCPConnected.prototype.GWRequest = function(payload,cb){
    if(!this._hasToken){
        cb(1);
    }else{
        var options = {
            hostname: this._host,
            port: 443,
            path: '/gwr/gop.php',
            method: 'POST',
            headers:{
              'Content-Type':'text/xml; charset="utf-8"',
              'Content-Length':payload.length
            },
            rejectUnauthorized: false,
            agent: false
        };

        tcpSocket = https.request(options, function(res) {
            res.on('data', function(data){
                cb(data);
            });
        });

        tcpSocket.write(payload);
    }
}

Generate a uuid is very simply accomplished by:

var uuid = require('node-uuid');
...
var myuuid = uuid.v4();
kevincoleman commented 9 years ago

Wow! Thank you for helping me understand. I’ve updated the code on my home server and am getting the “press button” message upon testing (I’m at work). I can’t wait to get home and give it a shot.

For some reason I was thinking that the rejectUnauthorized was something I’d need to have direct file access to change, but that makes sense! I’m totally new to http calls and tokens, so this is really helpful and kind of you.

Thanks for the API fix, and the time helping my little brain along!

sebastienvg commented 9 years ago

You Sir saved my investment! I sent you a donation, please have a well deserved beer!

kevincoleman commented 9 years ago

Donating! What a wonderful idea. It is well deserved, so make it a couple beers.

Tested last night, and it worked great. Thank you again!

bdunlay commented 9 years ago

@sebastienvg did you find this to be true, or is this speculation?

"in case of internet failure you can't use the light"

I'm able to my gateway and lights via my python lib with no official UUID, and i've actually blocked access on my router to/from their cloud service (to prevent any further mystery updates). works like a charm.

sebastienvg commented 9 years ago

well today something happened, not sure if they pushed again one of their mystery firmware or if the gw just gave up. I am unable to control anything whether it's from command line of their app and website. I think I'll just go ahead and return the gw to homedepot and grab a fresh one without updated firmware and then I'll block the port.

kevincoleman commented 9 years ago

I am chasing a ghost error today, too. My cron job that always worked before didn’t seem to manage running sunrise.js, but when I ssh in and run it manually things work.

Hoping I don’t get a firmware update while I‘m out. It’s port 43434 that they use for updates, right? Might have to do some port blocking.

kevincoleman commented 9 years ago

Looks like it’s 49494

bdunlay commented 9 years ago

Can you guys use the app to check the gateway firmware version? Maybe they pushed another update. I've blocked them so there are no surprises.

If you do a traceroute or ping to http://tcp.greenwave.com tcp.greenwave.com you'll see their service IP is 184.169.144.140, so you can easily filter on that.

To be extra safe, I may just take my gateway offline and hook it up directly to a headless raspberry pi to prevent these shenanigans.

Looks like it’s 49494

— Reply to this email directly or view it on GitHub https://github.com/stockmopar/connectedbytcp/issues/1#issuecomment-71918972 .

sebastienvg commented 9 years ago

In fact the firmware is unchanged (3.0.74) and tonight both the phone app (android) and the curl call fired from the also unchanged script. Will keep an eye on this.

stockmopar commented 9 years ago

@sebastienvg @bdunlay @kevincoleman

Are you guys having problems? My local access doesn't seem to be having any problems. I have had issues with remote access.

bdunlay commented 9 years ago

No sir, things locally are working just fine.

kevincoleman commented 9 years ago

Agreed. Seems to work great locally. Not sure why my scheduled task isn’t firing off, but that’s unrelated. :)

sebastienvg commented 9 years ago

Surprise, today the only thing that I can achieve is getting a new TOKEN, when using that same token in a call to turn on or off, I get 400

<html><head><title>400 Bad Request</title></head><body><h1>400 Bad Request</h1><p>Unable to parse data in GOP command</p></body></html>

Is it still working for you guys?

stockmopar commented 9 years ago

Yes. Everything is working for me (as of a couple hours ago). What command are you sending it?

On Jan 31, 2015, at 10:26 AM, Sebastien Vayrette-Gavard notifications@github.com wrote:

Surprise, today the only thing that I can achieve is getting a new TOKEN, when using that same token in a call to turn on or off, I get 400

400 Bad Request

400 Bad Request

Unable to parse data in GOP command

Is it still working for you guys?

— Reply to this email directly or view it on GitHub.

sebastienvg commented 9 years ago

Well I had wrote some kind of bash wrapper that you can pass options it goes something like that ./wrapper.sh device office off it would generate the URL according to $device, $office and $off by converting them to proper $cmd $did $action. It's very simple and worked for days. Of course I use the same UUID that I use with the node examples and these work fine. The problem must be somewhere else, I'll dig in.

Ideally I want to integrate this project as a plugin of pimatic but I don't know how to write any coffeescript and I barely write proper nodejs. Right now I am playing around with sunrise.js and toggle.js trying to find out the fastest way to turn on or off a did or a room without testing for the state first because I am using a raspberrypi these calls node toggle.js can take up to 7 secondes to complete.

Any of you heard of pimatic before? I am willing to donate and help as I can to whoever can help bringing connectedbytcp lights to the most promising home-automation open source project.

kevincoleman commented 9 years ago

FWIW, I got my cron issue figured out. Turns out I had to run a cron job and press the button on the gateway to get it to recognize cron-initiated requests. I had even run the exact same command the cron job runs from the cron server manually via ssh, and it worked great, but if cron ran the command it failed auth. Is the token stored in a user-specific location (probably a n00b question)? That would explain what I was seeing.

sebastienvg commented 9 years ago

I believe upon authentication it creates a config.json in the connectedbytcp folder and the token is stored there.

kevincoleman commented 9 years ago

Huh. Ok—makes sense that it would go there. Still not sure why cron didn’t like my ssh-initiated auth, but whatever!

I guess this issue is becoming a regular forum at this point. Since @stockmopar put in the fix, I guess it should be closed.

Thanks again!

stockmopar commented 9 years ago

It appears to be stored in the folder from which the command is run. I originally assumed exactly what you said but found out that wasn't always the case when I helped a few people still using my old Ninja Blocks driver that the config was getting stored in a different directory. There seemed to be a difference between:

$/afolder> node subfolder/sunrise.js

and

$/afolder/subfolder> node sunrise.js

On Feb 2, 2015, at 1:05 PM, Kevin Coleman notifications@github.com wrote:

Huh. Ok—makes sense that it would go there. Still not sure why cron didn’t like my ssh-initiated auth, but whatever!

I guess this issue is becoming a regular forum at this point. Since @stockmopar put in the fix, I guess it should be closed.

Thanks again!

— Reply to this email directly or view it on GitHub.

sebastienvg commented 9 years ago

in my case the script I use is stored in /home/pi and the config.json is located in /usr/local/connectedbytcp I had to symlink the config.json in the same folder that the script, so I guess it depends whether you npm install ornpm install -g

kevincoleman commented 9 years ago

Ah. Yep. I did the non-global install. Probably should’ve installed globally!

sebastienvg commented 9 years ago

@stockmopar how do I go about parsing the output of the call that check devices status? It's all on one line which confuses me to starts, I'd like to be able to retrieve the status of a particular DID.

scottstevens commented 9 years ago

Thanks for taking the time to sniff out this traffic... really irritating that TCP decided to do this. Question... Any chance you sniffed out the location of their images?

sebastienvg commented 9 years ago

@scottstevens http://tcp.greenwavereality.com/ui/img/ are those the ones you were looking for?

scottstevens commented 9 years ago

I was actually wondering where they were located on the gateway. (The pics I snapped of my lights). I thought they used to be stored there at least. Its OK if you don't know off the top of your head, I can try and find time to sniff the phone app traffic.

kevincoleman commented 9 years ago

The script has stopped working for me again, and I have no clue why. I can’t find any errors reported anywhere, and I’ve uninstalled & reinstalled it completely. It runs and gets a token, so I know the script is running alright, but it just doesn’t do anything with the lights.

Here’s my fork.

toggle.js gives me this error:

/Users/agnes/dev/connectedbytcp/toggle.js:12
            if(state == 1){
               ^
ReferenceError: state is not defined
    at /Users/agnes/dev/connectedbytcp/toggle.js:12:7
    at /Users/agnes/dev/connectedbytcp/index.js:138:6
    at module.exports (/Users/agnes/dev/connectedbytcp/node_modules/libxml-to-js/lib/libxml-to-js.js:189:3)
    at /Users/agnes/dev/connectedbytcp/index.js:135:4
    at IncomingMessage.<anonymous> (/Users/agnes/dev/connectedbytcp/index.js:57:5)
    at IncomingMessage.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at IncomingMessage.Readable.push (_stream_readable.js:126:10)
    at HTTPParser.parserOnBody (_http_common.js:132:22)
    at TLSSocket.socketOnData (_http_client.js:310:20)

sunrise.js gives me a blank prompt with no error logged and no light activity.

node v0.12.0 firmware v3.0.76 (and I did block update ports)

stockmopar commented 9 years ago

@kevincoleman

Can you manually try this process from before again to try to isolate the issue?

Note: You might get browser security warnings when doing this.

https://[your gateway ip]:443/gwr/gop.php?cmd=GWRLogin&data=<gip><version>1</version><email>[myuuid]</email><password>[myuuid]</password></gip>&fmt=xml

<gip><version>1</version><rc>200</rc><token>[mytoken]</token></gip>

https://[your gateway ip]:443/gwr/gop.php?cmd=GWRBatch&data=<gwrcmds><gwrcmd><gcmd>RoomGetCarousel</gcmd><gdata><gip><version>1</version><token>[mytoken]</token><fields>name,image,imageurl,control,power,product,class,realtype,status</fields></gip></gdata></gwrcmd></gwrcmds>&fmt=xml

I can confirm that my setup has been working this whole time. I am on 3.0.74 but I don't believe that makes a difference. I am also on node v0.12.0

kevincoleman commented 9 years ago

Yeah, I’ll happily give that a shot. I am out for the weekend, and have remote access, but can’t press the button!

I’ll try it as soon as I get back, but if it matters I’ve already gone through generating the token several times—even including cloning the source (instead of my fork), installing and running in a clean environment. The token gets written, so I know the script is running. The error (undefined parameter) makes me think maybe I’m getting an unexpected response (or no response?) I tried to wireshark it, but got hung up on setup.

Anyway, I’ll try that when I get back Sunday evening. Thanks!

scottstevens commented 9 years ago

How exactly did you sniff the traffic? I tried proxying my mobile traffic through another computer with fiddler (installing the certificate on my phone). Their app appears to not like this. Im guessing they have their own certificate installed with the app in the local app directory to prevent this kind of attack? Did you root your phone and replace the certificate?

kevincoleman commented 9 years ago

Ok, ran through the token process, and I got a token ok, but when I requested the state of the system I got a 404. Maybe 3.0.76 responds differently or expects a different request?

stockmopar commented 9 years ago

@kevincoleman

I fat fingered the url of the get request state of the system in my previous post (forget the "gwr/gop.php?" part). I correct it above now and will repost below. Sorry. Give it a try again and let me know what you get.

https://[your gateway ip]:443/gwr/gop.php?cmd=GWRBatch&data=<gwrcmds><gwrcmd><gcmd>RoomGetCarousel</gcmd><gdata><gip><version>1</version><token>[mytoken]</token><fields>name,image,imageurl,control,power,product,class,realtype,status</fields></gip></gdata></gwrcmd></gwrcmds>&fmt=xml

kevincoleman commented 9 years ago

Oh, no big! Much easier to fix than some things. :)

Here’s what I get:

RoomGetCarousel12000Bedroom100000000images/black.png00021639040811109695010181238016386Min’s SideLED0images/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngmultilevel0990.0091190001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel112163904081118084751000238016386Kev’s SideLED0images/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngmultilevel09900001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel11

stockmopar commented 9 years ago

It seems to have stripped away the xml tags. Can you repost with the tags in place? You will have to do a view source on the page.

On Mar 3, 2015, at 7:15 PM, Kevin Coleman notifications@github.com wrote:

Oh, no big! Much easier to fix than some things. :)

Here’s what I get:

RoomGetCarousel12000Bedroom100000000images/black.png00021639040811109695010181238016386Min’s SideLED0images/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngmultilevel0990.0091190001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel112163904081118084751000238016386Kev’s SideLED0images/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngimages/lighting/TCP/TCP-A19.pngmultilevel09900001TCPLED A19 11WLED7821TCPproductinfo,identify,meter_power,switch_binary,switch_multilevel11

— Reply to this email directly or view it on GitHub.

kevincoleman commented 9 years ago

Oh. Silly me—of course. Here it is, much better-formatted: https://gist.github.com/kevincoleman/5932dc9edaed0a021c98

Unless I’ve gone crazy, that response looks pretty normal, no?

It appears to me as though nothing is making it past this line. It’s not failing the conditional, it’s just not even running the conditional tree.

kevincoleman commented 9 years ago

Any chance to look at this? I’m pretty stuck.

stockmopar commented 9 years ago

@kevincoleman

Issue seems to be related to invalid xml being passed back which is then not able to be parsed. In the formatted page you sent there is some invalid xml: <img>images/black.png<power>0</power>. The img tag is not being terminated. Can you verify that this is indeed the case if you run the command again?

Also is your response wrapped with <body></body> or did you add that for formatting?

kevincoleman commented 9 years ago

Huh. Odd—not sure where the body tag came from. I may have done inspect element > copy as html instead of view source > copy (which might have added tags?).

I’ve updated the gist with a more recent response. I think the invalid formatting might have been from my indenting cleanup.

Here’s the updated, formatted xml. Here’s the updated, unformatted xml.

stockmopar commented 9 years ago

Found the issue in the toggle.js and commited the fixes.

kevincoleman commented 9 years ago

Man, I don’t know what’s going on. I just wiped my whole fork and reforked, then cloned to both my home server and my local machine. I cleaned up my installation of node and reinstalled in both locations, then tested from each machine, acquiring a token before testing each time. Responses seem ok, but the scripts just don’t turn the lights on. I’ve even removed and set up the lights via the TCP app again. I tested node for running other servers, etc. as well, and it seems to be functioning alright.

I’m getting to where I am about to give up and just sell the lights. Can you think of any sort of error reporting I might just be missing here? Maybe TCP didn’t like the unofficial API and decided specifically to nix it in 3.0.76?

Sorry for all the trouble this has been. I know it’s not like I’m a paying customer or anything—this is just very vexing.

stockmopar commented 9 years ago

Nah man don't give up! I actually suspect that there is still an issue with my package.

This is the command to execute from your browser to turn on the lights.

Based on your above files you should be able to execute these commands in your browser:

Turn On Bedroom:

https://[your gateway ip]/gwr/gop.php?cmd=RoomSendCommand&data=<gip><version>1</version><token>[mytoken]</token><rid>0</rid><val>1</val></gip>&fmt=xml

Turn Off Bedroom:

https://[your gateway ip]/gwr/gop.php?cmd=RoomSendCommand&data=<gip><version>1</version><token>[mytoken]</token><rid>0</rid><val>0</val></gip>&fmt=xml

Turn On the Device "Office" in Bedroom

https://[your gateway ip]/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>[mytoken]</token><did>216390408111096950</did><val>1</val></gip>&fmt=xml

Turn Off the Device "Office" in Bedroom

https://[your gateway ip]/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>[mytoken]</token><did>216390408111096950</did><val>0</val></gip>&fmt=xml

Their command structures are pretty simple once you get the hang of it.

If you did reset your gateway, the above rid (room ids) and did (device ids) may have changed either just get the status with the:

https://[your gateway ip]:443/gwr/gop.php?cmd=GWRBatch&data=<gwrcmds><gwrcmd><gcmd>RoomGetCarousel</gcmd><gdata><gip><version>1</version><token>[mytoken]</token><fields>name,image,imageurl,control,power,product,class,realtype,status</fields></gip></gdata></gwrcmd></gwrcmds>&fmt=xml

command and grab which ever room id or device id and stick it in the above commands. This should be just a temporary measure until we can find the issue with the package.

If you do get successes or failures with the above commands let me know what the error message is that they report.

kevincoleman commented 9 years ago

Ok!

Thanks for the help in outlining those requests for me. I can definitely turn the lights on by sending regular ol’ http requests through the browser. Now I just need to figure out why the script is failing.

After messing with resets, etc., the request I am using is:

https://10.0.1.3/gwr/gop.php?cmd=RoomSendCommand&data=<gip><version>1</version><token>pxzrujvm9zjd3du8pakkyudq2eoau1kpnp8oesgd</token><rid>2</rid><val>1</val></gip>&fmt=xml
kevincoleman commented 9 years ago

Ah ha! I believe I have a more helpful error to troubleshoot with. I ran the script with an output location specified, and saw the error: 1 1 1 Which was initially super confusing. Then, I tried injecting console.log to find out how far the script got, and it stopped at GetRoomStateByName on line 9 of toggle.js. That led me to realize that maybe GetRoomStateByName wasn’t getting what it expected, so I looked it up in index.js, and found the error that’s producing the 1’s.

Am I right in assuming it’s probably not defining Rooms properly based on the response?

I’m still not sure just why it’s erroring, but it seems like progress. Admittedly (and, I’m sure, obviously), I’m new to error reporting—is there an addition I should make for a more verbose error that could be helpful?

Thanks again!