Giter VIP home page Giter VIP logo

Comments (4)

malle-pietje avatar malle-pietje commented on May 18, 2024 1

It takes a while after the end of each day for its daily stats to populate so that explains why you don't yet see the 5th in the chart. Switch to hourly stats and you will see stats up the last full hour.

Regarding the use of the stat_sessions() method, you do need to provide the correct number of parameters, otherwise, PHP will assume the only provided value must be assigned to the first parameter.

If you do it like so:

//stat_sessions($start = null, $end = null, $mac = null, $type = 'all');
$unifi_connection->stat_sessions(null, null, $mac)

will return the session collection for the device with MAC address $mac for the past week (7*24 hours).

If you wish to see them for a different timeframe, simply pass the required start and end Unix timestamps in seconds.

See the code comments here:
https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#L859-L871

See this site for some explanation and tools regarding Unix (or epoch) time(stamps):
https://www.epochconverter.com/

from unifi-api-client.

malle-pietje avatar malle-pietje commented on May 18, 2024

At first glance, your code is fine although I personally would use a foreach() loop which is more straightforward when cycling through all elements in an array.

The difference you see is caused by the fact you're looking at data in the controller which is coming from a different source. The source of the data you were looking at is the sessions collection which is available through the stat_sessions() method/function.

The collection you are going through is used to populate the "Show historical data" for the client, while the view you were looking is available from the "History" tab for the client.

I cannot say why there is a difference between the two in your case. Maybe it has to do with the data retention settings?

These are the data retention settings which we always use (where possible):
data retention

from unifi-api-client.

rtgoodwin avatar rtgoodwin commented on May 18, 2024

My settings are slightly different, but I think should be fine for this example:

image-07-54-44

Another look:

image-07-29-14

You appear to be right in that the Show Historical Data graph, while darn near impossible to actually tabulate since you have to do hovers, seems to have a different amount of data. Here's a GIF that shows Daily Historical for the device. (Left most Y axis is the "3rd", right is the "4th", and then it's blank through the "5th":
daily_data

Could be a time zone issue, but even so, none of the data shows anything close to the amount of data xferred from the API client test. I tried the stat_sessions call, but it seems to be ignoring the $mac and is returning all sessions for all MACs. (Again could be a newb thing...)

$mac = "my_secret_mac";
$result           = $unifi_connection->stat_sessions($mac);

At any rate (har har), the data that came back making no sense either.

Hostname		rx_bytes/1024
Matched			1219
Matched			69
Matched			0
Matched			65
Matched			73
Matched			85
Matched			1052
Matched			52
Matched			1433
Matched			5530
Matched			141
Matched			2517
Matched			5
Matched			0
Matched			95
Matched			116
Matched			170

Total kbytes rcvd: 12622
Total sessions: 17

At this point I don't know what's what, and may be outside the scope of your responsibilities, but I do appreciate any and all help. :)

from unifi-api-client.

malle-pietje avatar malle-pietje commented on May 18, 2024

Issue appears to be resolved, now closing. Feel free to re-open if needed.

from unifi-api-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.