Http Request does not arrive back

I have been basing my script on some examples that parse JSON from an external service back to the IMP.

However, the request is made, but the set(1) function seemingly is never called back, as the log() or show() does not kick in.

Here is the code, anyone see any problems on this?


// Receive JSON Data from External

local astronomy = OutputPort(“Astronomy”,“number”);

// this class receives the json data
class Astronomy extends InputPort {

function set(payload) {
    server.log("data received");"data received");
    //to figure out json structure uncomment the following and check the log output
    //all the data is considered a string, so convert to integer or whatever as necessary 
    local variable = payload.moon_phase.sunset.hour.tointeger(); 
    //schedule another update in 1 minute
    imp.wakeup(10, getAstronomyData);


function getAstronomyData() {
server.log(“data requested”);“data requested”);
astronomy.set(1); //initiates outbound connection to retrieve astronomy data

//imp.wakeup(10, getAstronomyData);


function dumptable(p, t) {
    foreach(key, value in t) {
        if (typeof value == "table") {
            dumptable(p+"."+key, value);
        else server.log(p+"."+key + " = " + value);

server.log(“IMP started”);“IMP started”);
imp.configure(“Outdoor Activation”, [Astronomy(“astronomy”,“string”) ], [astronomy]);



Could we see how your planner is setup?

Sure, here you go.
Just a Http request with a GET and JSON set URL to the wunderground API making a call for the astronomy call (i checked the URL in browser if it returns anything, it does indeed return the right data).

I don’t see a connection from your imp to the http request, to initiate the GET request using set(1).

You mean in the code or in the planner?

I tried to find a way to add another arrow from the IMP to the HTTP in the planner, but I couldn’t find a way to do so.

You can’t add an arrow to the HTTP Request (that’s for incoming requests only). You would need to add a HTTP Out node to the planner, and connect an arrow from your imp node to that.

I can’t really tell what the purpose of your ‘astronomy’ output port is… could you explain the flow of what you’re trying to do in a bit more depth?

I got all my ‘inspiration’ from this forum entry:

All I want to do is retrieve a JSON object I create via PHP.

I thought an HTTP request us what I need for this.

@beardedinventor you are mixing up the HTTP IN node and the HTTP REQUEST node. The HTTP REQUEST node is what is needed to send a request out to a external website (a HTTP OUT node does not exist), and retrieve the result back into the planner, and to your imp through an input port.
You need however an output port on your imp to initiate the request, and make a connection from your imp to the HTTP REQUEST node in the planner. So there is one arrow from imp to HTTP REQUEST, and another arrow the other way around.

so giving my code and planner setup, how do i create that second arrow or what exactly is missing

@marcboon - good catch, sorry for any confusion… I haven’t worked with the nodes in a while :slight_smile:

@uncleunvoid - how about we set you up on beta and you do this the right way with agents… that way you won’t need to rewrite everything when we flip over :slight_smile:

@bearded That would be very appreciated, maybe it also helps me understand the whole setup having one piece of code that works for me.