instanttim / MonitorMate

A monitoring system for the Outback Power MATE3. It processes the data stream, reformats it for logging, charting, and display on a web server.
GNU General Public License v2.0
8 stars 7 forks source link

Devices not addressed properly when ports used aren't sequential from port 1. #31

Closed kmpanilla closed 9 years ago

kmpanilla commented 9 years ago

Updated to the latest code, and my summary page decided to break. My FNDC_ID is 4. Line 1462 in monitormate.js has: var device = json_status['status']['devices'][port - 1];

Debugging it showed that device variable was undefined until I set it to "port - 2". The json_status['status']['devices'] only had three entries in it on my system so a "FNDC_ID - 1" would never have found anything in the array of size 3.

instanttim commented 9 years ago

Do you have a url so I can see your site?

instanttim commented 9 years ago

If you have 3 devices than the array should have indexes 0, 1, 2. Why would your fndc be 4?

Are you confusing the device ID with the port address? The FNDC has a device id of 4, but it's port address is based on where you plug it in on your hub.

instanttim commented 9 years ago

Oh I see. You skipped a port and have things plugged in to 1, 2, and 4. The code probably assumed sequentially connected items. It looks like you also didn't supply custom device labels in your config and my latest change isn't handling that well either.

I'll check both things out and submit a fix in a couple hours.

instanttim commented 9 years ago

Can you downgrade to this version before I put the device labels in the JSON? https://github.com/instanttim/monitormate/tree/4db5c1bf7afbebe266393aa4e43a39a85050842a

You said that you just updated to the latest revision and this broke, do you know which revision you were running before?

kmpanilla commented 9 years ago

previous version was from early november. I'll try downgrading tonight

instanttim commented 9 years ago

I fixed up the code for the device labeling so it should work if you haven't customized all or any of your device names in config.php: 47198d8332afb5180d14434c0f52388c0fd8bcff

But i don't think this will fix your issues. I'm still looking into it.

instanttim commented 9 years ago

Oh, well it looks like you have devices plugged into ports 1, 2, and 4. But in your config file you have custom names set for ports 2, 3, 4... furthermore the custom names you've defined are in fact the all-caps constant names for the device ids.

I think you're confused about what that deviceLabels array is for in config.php. That's a place to define "friendly" names for your devices. You should leave them blank if you have no desire to name them. You can check out my site to see how i've named mine as an example: http://finleyridge.com/power/

Clearly the system shouldn't be failing to work properly just because you did this. Somewhere the system is interpreting the name as the constant I think. Why don't you remove the custom names and see if the problem goes away... if so at least I know where the problem is.

kmpanilla commented 9 years ago

I pulled the names out.

Looks like the summary drop down for the port4 isn't working, probably due to the issue you mentioned with the 1,2,4 port selection. Not sure if it's worked for a while honestly.

instanttim commented 9 years ago

Ah, i found it. In set_status it really assumes that the array index is the port number minus one. Which works if you don't skip ports on your hub. I should probably change that array to be an associative array with the keys being the actual port numbers rather than normal array indexes.

    device_id = parseInt(value.split(/[:]/)[0]);
    address = parseInt(value.split(/[:]/)[1] - 1);
    // BUG: this assumes that the array index is the port number minus one. IT ISN'T! if you skip ports on your hub.
    device = json_status['status']['devices'][address];
instanttim commented 9 years ago

Fixed for the select popup menus and status. Not sure if this is the only place that this problem manifests itself... but I think so for now.

kmpanilla commented 9 years ago

Just updated, and all the drop-downs works, but all of the graphs disappeared on the main monitormate.html page.

instanttim commented 9 years ago

Indeed, you found another case that assumed array index == port number minus one. I did some searches and couldn't find any other places where that happened. When one chart (in this case the state of charge gauge) fails it usually stops all other charts on the page from rendering. Just so happened it was the very first chart on the page, so none of them rendered.

kmpanilla commented 9 years ago

updated again, still no luck on the graphs.

also it appears the drop down for the devices no longer work on the main page.

instanttim commented 9 years ago

just looks like bad cookie data or something. I force refreshed your site: http://server.cbl.us/monitormate/monitormate.html http://server.cbl.us/monitormate/monitormate.html and stepped through the debugger and it fixed itself…

.tim

On Jan 6, 2015, at 12:15 AM, kmpanilla notifications@github.com wrote:

updated again, still no luck on the graphs.

— Reply to this email directly or view it on GitHub https://github.com/instanttim/monitormate/issues/31#issuecomment-68837611.

instanttim commented 9 years ago

oops. that was meant for issue #33.

lpgn commented 4 years ago

I believe when ports used aren't sequential still causes problems. I wouldn't get data on the gauges or in the Details page until I placed the equipment sequentially in the hub. What I noticed was that the json file was being generated with some extra characters. I don't have the original json as this is solved around 10 days ago but here is a print I sent to a mate. WhatsApp Image 2019-12-29 at 4 11 17 PM My problem is solved by placing equipment sequentially but because this could take a long time debugging maybe it would worth mentioning.

instanttim commented 4 years ago

Oh I see. Is that valid JSON?

Looks like it’s enumerating the elements in the object. I haven’t looked at any of that code in so long, not sure why that’s an issue. I moved, and am no longer off-grid. So I haven’t been working on or improving any of this project — and in fact can’t test my changes as I don’t have the equipment anymore.

.tim

On Jan 16, 2020, at 5:58 pm, Lucio notifications@github.com wrote:

I believe when ports used aren't sequential still causes problems. I wouldn't get data on the gauges or in the Details page until I placed the equipment sequentially in the hub. What I noticed was that the json file was being generated with some extra characters. I don't have the original json as this is solved around 10 days ago but here is a print I sent to a mate. https://user-images.githubusercontent.com/2556951/72575419-3c9eb180-38c4-11ea-8b80-f67d59ad1ee9.jpeg My problem is solved by placing equipment sequentially but because this could take a long time debugging maybe it would worth mentioning.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/instanttim/MonitorMate/issues/31?email_source=notifications&email_token=ABO7DBTWVULNMF2R7ADQMYDQ6D7ERA5CNFSM4AZYWPXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJGCYWI#issuecomment-575417433, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO7DBXRRJUJZNHTBI5EODLQ6D7ERANCNFSM4AZYWPXA.