Second Imp does not have an Agent Url

Recently I converted one of my imps to the Agent code from the Planner code. Works great I can now open and close my garage from the planner url. Future I need to see the status from the web. I have a second imp which was used as a status monitor inside the house, so that I could see whether the garage door without going to the garage. It also has a button to close the door if I wanted. The problem is when I went to change the code on the second unit the agent code appeared to be the same as the first Imp. That could not be right. The development screen acts strange reporting the status incorrectly and will not give me an agent url. Also there are no logs being written so there must not be a server connection. I tried reblinking the imp but nothing seems to work. Sometime the agent url being displayed is the agent for the first imp. Confused…

What browser are you using? I believe there are issues with IE, though I’m not sure it would give you those results. The Agent URL should be a link at the top of the Agent window in the IDE.

@JoeC - I’m not sure if this will help perhaps clear up some of your confusion, but just realize that agents are paired with your devices (previously a.k.a. ‘impees’) … agents are not matched with specific imps. This was a misunderstanding I had for a while and could perhaps be related to what you’re observing.

edit: just to elaborate a bit further - an agent is associated with a model, which is associated with a device. The agent URL and device ID you note on the IDE are related to your device (i.e. ‘impee’), not to a particular imp you have in it.

(I’ve parsed your comments a couple times, and am a bit confused re: the exact problem you’re encountering, but I’m just offering this explanation up as it seems as if it might be related to your situation).

I am using chrome for a browser. And I have two impees, one is presently hooked up to my garage door and working nicely. The second impee is on my desk. Both were working under the planer. Now just one is working properly.

The IDE reports that the code compiles correctly and that every thing is good however that is not the case as I have no agent url and server log are not being displayed.

The project consists of two impees, one in the garage which monitors the garage door and provides a time out when opened too long. The second impee’s job was to display the garage door status inside at a movable location, IE the bedroom, living room, or kitchen. The status of the garage door was being sent via the out command. The second impee could also close the door via a push button. So both impee communicated via in and out commands. I realize that this has to change to agent code. So I have to two models running two separate codes on two different impees. But the IDE somehow only partly recognizes the impee that is on my desk being powered by usb.

I should note that I converted the garage door impee to agent code and it does have the agent url at the top and server logs are being displayed properly.

The second impee code was also changed but does not show the url. the space is blank as is the server log window. However, when I press ‘Build and run’ I get a success message but no log messages get displayed. Thanks

I think I see the problem but I don’t know how or why. The IDE is reporting two impees running the code for the garage door. The ID numbers are the same but they both have different agent urls. One of these must be the impee running on the desk while the other is the correct impee running in the garage. The impee running the inside code has the correct ID but is not running the code as is being reported. I have verified this by opening the garage door and looking at the logs one correctly displays the door opened while the second does not. Both have the same ID number. how does this happen?

I have made some progress. I clicked on the duplicate ID number that was running the garage code and changed the name to be that of the inside impee then I changed the model to be the inside code. Now there are logs being written and the code errors are also being displayed. Now I have a duplicate of the inside impee under the inside model. Can I delete the ID number of one of them without effecting the other?

I don’t think that there is any harm in deleting. If you accidentally delete one that you want, it should reappear the next time it connects…you shouldn’t even have to re-blinkup. My guess is that maybe you swapped imps and Aprils at some point? It can get a little confusing with the Imp card, since the ID that you see is actually for the board (the ATSHA chip) and not for the Imp itself, as Larry stated.

I knew that the board has the ID chip. They were never swapped as the garage impee is hardwired to the garage door and to it’s power supply and relay. I suspect a subtle bug exists that allowed two IDs to run at the same time running different code and a third impee code to look like it was running as clicking on the Build and Run gave erroneous messages that all was OK. Thanks for looking all is well now. I just need to find out how to pass the garage door status to the inside impee and how to pass a command to close the door from the inside impee.

@JoeCarson6 - I wrote a blog post about a week ago about imp to imp communication with agents. In the example, we’re triggering an LED, but you should be able to modify it to work with what you need!

@beardedinventor - Thanks

agent-2.nut appears to have an error. “expect function”

`// replace the url with the other agent’s URL
const OtherAgentUrl = “

// catch the button message
device.on(“Gdoor”, function(state) {
// build the URL
// server.log(“Gdoor”);
local url = format("%s?Gdoor=%i", OtherAgentUrl, state);
// make the request, and call the inline function
// when we get a response
http.get(url) .sendasync(function(resp) {
server.log(format("%i: %s", resp.statuscode, resp.message));
} `
error expression expected

I wrapped your code in a < code > </ code > block (the “C” button in the format bar).

Looks like it’s missing a “)” at the very end of the file (directly after the last “}”)

I’ve updated the code in the blog post - so you should be able to grab it now :slight_smile:

That fixed that error thanks. Now when I press the button I get a server log that says the index ‘message’ does not exist at unknow:14.

// replace the url with the other agent’s URL
const OtherAgentUrl = “{agentID}

// catch the button message
device.on(“button”, function(state) {
// build the URL
local url = format("%s?led=%i", OtherAgentUrl, state);
// make the request, and call the inline function
// when we get a response
http.get(url).sendasync(function(resp) {
// log the response, should be 200: OK is things worked
server.log(format("%i: %s", resp.statuscode, resp.message));

resp.message should be resp.body, i.e.:

server.log(format("%i: %s", resp.statuscode, resp.body));