Count Unique Entries in Database to Graph

Hi folks,

I've resurrected an old project and I need a little help please.

Long story short, I've installed Node Red on a phone. I've managed to get it to use a motion detection app to take photos and put them in a folder. Node Red then uses an API to upload the photos to an object recognition site which returns a JSON detailing what it "sees". I am going to point this as my bird feeder to identify the visitors. I have got the system to email me photos and even "text to speech" announce what is on the feeder.

Phase 2 is to write each visitor into a database with fields being as follows:

Time_Taken (The time the alert was detected)
Visitor_Name (The name returned from the API)
Photo (Base64 copy of the photo taken)

I would then like to count each of entry for a unique Visitor_Name and pass this to the dashboard so I can have a bar graph showing the number of visits for each type of bird.

For example, a robin gets captured so it is logged in the database. It might come back again so it is logged again. The graph would then have a bar for "Robin" with a value of 2. A Starling then arrives and is logged in the database and the graph automatically has a bar for "Starling" with a value of 1.

I don't know anything about Databases in Node Red, so my questions are as follows:

  1. How do I set up a persistent database file which would survive reboots?
  2. How do I count the unique values entered into the database and pass the unique names and the number of times they exist over to the dashboard?

Hope this all makes sense - please ask if I'm talking gibberish!

Cheers, K.

TL;DR : How do I count unique entries in a database and dynamically update a graph on the dashboard with the name and count value, even when new unique values are added?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.