pjjameso Posted November 17, 2021 Posted November 17, 2021 Im sure its my not understanding how the network resources works so seeking some advice. My test curl command works and sends back the correct information as seen below . However when i try and set this up in the network resources all I get is an Request Fail, N/A, what am i doing wrong? Of course my next question will be how do I parse the information returned and populate state variables with the data....? C:\Users\Virtual Reality>curl -v https://api.kaiterra.com:443/v1/devices/25afddd1-51d4-4ed5-ac76-39c3c7a5b8eb/top?key=NzIzZDMzNWNiZTNjNDRkOTk? * Trying 3.124.137.111... * TCP_NODELAY set * Connected to api.kaiterra.com (3.124.137.111) port 443 (#0) * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 1/3) * schannel: checking server certificate revocation * schannel: sending initial handshake data: sending 187 bytes... * schannel: sent initial handshake data: sent 187 bytes * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 2/3) * schannel: failed to receive handshake, need more data * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 2/3) * schannel: encrypted data got 2760 * schannel: encrypted data buffer: offset 2760 length 4096 * schannel: encrypted data length: 2658 * schannel: encrypted data buffer: offset 2658 length 4096 * schannel: received incomplete message, need more data * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 2/3) * schannel: encrypted data got 387 * schannel: encrypted data buffer: offset 3045 length 4096 * schannel: sending next handshake data: sending 93 bytes... * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 2/3) * schannel: encrypted data got 51 * schannel: encrypted data buffer: offset 51 length 4096 * schannel: SSL/TLS handshake complete * schannel: SSL/TLS connection with api.kaiterra.com port 443 (step 3/3) * schannel: stored credential handle in session cache > GET /v1/devices/25afddd1-51d4-4ed5-ac76-39c3c7a5b8eb/top?key=NzIzZDMzNWNiZTNjNDRkOTk? HTTP/1.1> Host: api.kaiterra.com > User-Agent: curl/7.55.1 > Accept: */* > * schannel: client wants to read 102400 bytes * schannel: encdata_buffer resized 103424 * schannel: encrypted data buffer: offset 0 length 103424 * schannel: encrypted data got 773 * schannel: encrypted data buffer: offset 773 length 103424 * schannel: decrypted data length: 744 * schannel: decrypted data added: 744 * schannel: decrypted data cached: offset 744 length 102400 * schannel: encrypted data buffer: offset 0 length 103424 * schannel: decrypted data buffer: offset 744 length 102400 * schannel: schannel_recv cleanup * schannel: decrypted data returned 744 * schannel: decrypted data buffer: offset 0 length 102400 < HTTP/1.1 200 OK < content-type: application/json; charset=utf-8 < date: Wed, 17 Nov 2021 15:39:06 GMT < content-length: 551 < access-control-allow-origin: https://api.kaiterra.com < vary: Origin < {"id":"25afddd1-51d4-4ed5-ac76-39c3c7a5b8eb","data":[{"param":"rhumid","units":"%","span":60,"points":[{"ts":"2021-11-17T15:38:25Z","value":43.99}]},{"param":"rpm10c","units":"µg/m³","span":60,"points":[{"ts":"2021-11-17T15:38:25Z","value":0}]},{"param":"rpm25c","units":"µg/m³","span":60,"points":[{"ts":"2021-11-17T15:38:25Z","value":0}]},{"param":"rtemp","units":"C","span":60,"points":[{"ts":"2021-11-17T15:38:25Z","value":21.56}]},{"param":"rtvoc","source":"st03","units":"ppb","span":60,"points":[{"ts":"2021-11-17T15:38:25Z","value":78}]}]}* Connection #0 to host api.kaiterra.com left intact
randyth Posted November 17, 2021 Posted November 17, 2021 8 minutes ago, pjjameso said: However when i try and set this up in the network resources all I get is an Request Fail, N/A, what am i doing wrong? Did you check the Use SNI box? If not, try that. 8 minutes ago, pjjameso said: Of course my next question will be how do I parse the information returned and populate state variables with the data....? Unfortunately, you cannot do this. Network Resources on ISY are for triggering events. You cannot extract data from the calls you make. 1
pjjameso Posted November 17, 2021 Author Posted November 17, 2021 Just tried your SNI suggestion, no luck so far.
pjjameso Posted November 17, 2021 Author Posted November 17, 2021 Dang, just read your second paragraph.... so how would one make an api call to a website to retrieve data and then populate state variables? Currently using IFTTT, but the polling is only once per hour, was looking for something a bit more robust.
MrBill Posted November 17, 2021 Posted November 17, 2021 (edited) 30 minutes ago, pjjameso said: so how would one make an api call to a website to retrieve data and then populate state variables? Depending on your skill set, one could create an cloud space someplace to do the processing. a middleman of sorts. State variables can be set via the Portal API or through the ISY API with open port. You'd have to do all the programs there, probably via something like php. ...or actually the same on a local machine such as an RPI.... Edited November 17, 2021 by MrBill
randyth Posted November 17, 2021 Posted November 17, 2021 Similar to Mr. Bill's suggestion, if you are a developer you could also look into creating a Node Server for Kaiterra. 2
pjjameso Posted November 26, 2021 Author Posted November 26, 2021 Oh boy! Been reading the documentation…..think I will need to pay someone to create the node server at some point. Probably too old at this point to learn how to write the code. ?
sjenkins Posted November 27, 2021 Posted November 27, 2021 You are advanced enough to use curl, that says you know enough. Start small and inch your way there. The cleanest way is a node server for sure but there are other ways to skin the cat (I am old too btw: ). Write a script with curl and then use the ISY REST to write your variable. Then have your script run as a service on a desktop or a raspberry pi triggered regularly. I did this before the nodes were a thing then finally took a look at a few node server examples and made first some changes to others then my own node. SeJ 1
MrBill Posted November 27, 2021 Posted November 27, 2021 @pjjameso and @sjenkins There are also "blank" nodeserver templates in the store... see PythonTemplate and NodejsTemplate. 1
pjjameso Posted November 29, 2021 Author Posted November 29, 2021 Thank you for pointing to the templates and instructions, will give it a go! Will most likely be back with more questions.
Recommended Posts