[SOLVED] Can FPS value be monitored and accessed? HomeSeer & BlueIris via JSON

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Hello! Long time viewer on this forum, don't usually post. As I consider the possibility of acquiring a GPU for my i7-4790K for CodeProject AI I may possibly start posting... in any case, I have learned a lot over the years and greatly benefited from so much collective knowledge, it is much appreciated.

Today, however, it is hopefully something much simpler.

Is it possible to access FPS information and use this? I am thinking MQTT or any other mechanism...

Reason for this: I have some cameras that are connected to the network via PTP links with Ubiquiti Nanostations. It usually works extremely well. On occasion, the Nanostations need a reboot, and there is nothing that can be automated, since no fault is detected, simply the throughput lowers - I am monitoring them with a remote syslog on my Synology too.

When this happens, the cameras that use these links drop their FPS considerably. If I can monitor the FPS, I can be alerted as to when to take action.

I am okay with using my various Home Automation systems, MQTT, writing any piece of code I may need, I just would like to understand if there is a way to access the FPS data. I know it is held in variables in Blueiris, since I can use it for overlays...

Any thoughts?

Cheers
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,451
Reaction score
38,164
Location
Alabama
As you likely already know, the macro %006 contains a specific cam's current FPS on the main stream and will display as an overlay.
Could you write it to text and detect a minimum value that would trigger the restart you're wanting?
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Thank you, TonyR. Yes, I am aware of the that macro, it's one of the replacement variables I use on my overlays. I also write other data from my home automation to BI for macros that I use on overlays. like weather conditions from my weather station.

I like your suggestion, but does it work the other way as well, i.e. can I write a variable / macro from BI to a text file? If yes, I couldn't find any reference to it in the help file (short of accessing the registry to read the value, but that seems a bit too convoluted).

If I can get the value into a file, then yes, I can definitely retrieve and read the file and then use it as needed.
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
I think I found a way... using the JSON interface, and the command "camlist" amongst the returned data is fps and fps2 for each camera (for main and sub stream).

So, it would seem I just need to write some code on my home automation to access BI via the JSON interface and retrieve this.

I have a way forward :)

Cheers
 

biggen

Known around here
Joined
May 6, 2018
Messages
2,539
Reaction score
2,765
I’m kinda wondering why you have to reboot nano stations are a regular basis. I have two NanoBeams that I run that haven’t been rebooted in a year (on a UPS system).
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Well, I have 4 and 3 are rock solid... one of them is a bit wonky... on occasion, it decides to do a "eth0 down"... and UISP/etc do not record that as an outage... so you need to go and fiddle with it... firmware is up to date, power supply is good, ethernet cables too... just one of those ubiquiti things I guess...
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,126
Reaction score
1,237
Location
SF Bay Area
can I write a variable / macro from BI to a text file?
Yes. Even better you can create a log file.

Use ‘write to file’ actions executed every N minutes from the Settings > Schedule tab.
Key Point: Note that these action sets are schedule-specific. These actions must be created for every schedule you use.
1683989965810.png

Action 1. Create a Blue Iris 'Do command' action that stores the current timestamp string to a Blue Iris macro.
Why needed? In Actions 2-N we will create one action for each camera that require an identical timestamp work best with identical timestamps.
1683990307777.png

Actions 2-N. Create multiple Blue Iris 'Write to file' actions - one for each camera - that can append a row of data to a single file. Each 'Write to file' action is like the following:
1683990383172.png
where:
the Action field is always write to file--append;
the Camera field is unique for each action;
the File field is the same for each action, e.g., C:\Blue Iris\My External Logs\fps_log_%Y%m.csv
• using date macros %Y%m causes Blue Iris to automatically rollover the log file.
the Headers field is the same for each action, e.g., Timestamp,Camera,MainstreamFps,SubstreamFps,Tag\n
• this header will be written as the first row to the file when first created, then again each time the file is rolled over;
• \n starts a new row after the header.
the Parameters field uses Blue Iris macros to load current values into the CSV file:
• macro %500 expands to the 'Timestamp' column value created by the action in Action 1, e.g., 2021/09/03_11:33.
• macro &CAM expands to the camera shortname selected in the Camera field.
• macro %006 expands to the 'Mainstream(FPS)' column value (if dual stream).
• macro %f expands to the 'Substream(FPS)' column value (if dual stream).
• the 'Tag' column value varies by action.
• \n starts a new row.

Key point - If the camera is not dual stream:
  • The Parameters field should instead be as follows.
    1683990461884.png
    The reason why is that macro %f expands to the 'Mainstream(FPS)' value when the camera is not dual stream.

Over time we should observe that the 'fps_log.csv' is populated with data from Blue Iris, like this:
1683990549819.png
 
Last edited:

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Jaydeel... maestro...

I just realized how little I know of Blueiris... I will look into your solution right now, thanks so much for taking the time!!!!!!

I will post back once I get it going.
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
I will probably use a scheduled event from HomeSeer to parse the file and get the data I need... it's a shame the camera selection is only available in the do command... if it were also available with http/mqtt I could simply use macros in the payload and send to HomeSeer or interact with the HomeSeer JSON interface...

Unless you know of a way to reference a replacement variable for a specific camera from the http/mqtt action... in which case I would owe a beer ;))))
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,126
Reaction score
1,237
Location
SF Bay Area
If there is ‘noise’ in the your camera’s FPS values, you may want to monitor not just the current FPS value, but rather the N most recent. I’d consider using a running average.

Here’s an example of a ‘noisy’ camera’s FPS values. It is connected to the network via a powerline adapter, hence the variability.
1683992069365.png
 
Last edited:

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
That's a nice idea actually. Once I have the fps attached to a device in HomeSeer I can use mqtt->influxdb->grafana to review historical data... this is getting really good!
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,126
Reaction score
1,237
Location
SF Bay Area
it's a shame the camera selection is only available in the do command... if it were also available with http/mqtt I could simply use macros in the payload and send to HomeSeer or interact with the HomeSeer JSON interface...
Ask Ken to add it… that’s what I did to get it added to the write to file action.
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Ahhh, I could try. I will drop Ken a line. In the meantime, Michael (who wrote the mcsMQTT plugin for Homeseer) over at the HS forum has suggested an approach with the mcsMQTT/Cloud (JSON) functionality I could test to see if I can retrieve the values that way... so I will test both this and your suggestions.

In case anyone comes across this, and uses Homeseer too, the link to the post there is:

 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,126
Reaction score
1,237
Location
SF Bay Area
Yes, the JSON ‘camlist’ cmd is a good solution too.
I use it as well. It requires a bit of parsing to extract.
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Yes, that's why I was thinking of using the mcsMQTT plugin. I believe it will parse the JSON and allow me to create devices based on that... it would simplify a lot. Nonetheless, regardless of how it goes, I may implement your solution as well, so I have a log file to review with camera fps information - I think that would be very valuable too
 

pyspilf

Getting the hang of it
Joined
May 22, 2017
Messages
60
Reaction score
50
Location
Madrid, Spain
Yes, the JSON ‘camlist’ cmd is a good solution too.
I use it as well. It requires a bit of parsing to extract.
OK, I'm starting to see this JSON interface is not that trivial... if you want to have a laugh and see the struggle, head over to the HS forum post and take a look... after a lot of work managed to get a proper response and the camlist data, but still some work to be done on (a) the MD5 hash (internal plugin details, I think related to how replacement variables are being used and (b) the parsing bit you hinted to in this message... the JSON file returned is large
 
Top