Learn a pattern, then do something on change

I had this idea to make a box that would beep when an LED changes state, for example when a thing is done charging.

Ideally a photocell (or perhaps an IR sticky? or an LED as a light detector) placed over the LED of the charger would do it.

The problem is different chargers have different methods to indicate "done"

For example:
Camera = LED on while charging, off when done
Drone = LED blinks when charging, solid when done
Cordless tools = LED fast blink when charging, slow blink when done

So to make a "one fits all" device I anticipate the way to handle this might be...

Take a few samples over a minute and "learn" the state (charging)
then, when the samples deviate from the original (it's done charging) turn on a beeper.

I'm stronger on the hardware side than coding, how would you accomplish this?

Don't forget that a number of chargers also have another state (red for example) if it detects a faulty battery or some other charge error. You might want to consider that also.

technicalguy:
Take a few samples over a minute and "learn" the state (charging)
then, when the samples deviate from the original (it's done charging) turn on a beeper.

That sounds sufficiently sensible to be worth trying.

I presume your Arduino would initially assume that the device in in charge mode? And that you will be present when it starts the detection process?

You need to think about how you can detect different blink rates and not accidentally always sample on the ON stage and think there is a continuous ON (or vice versa).

I think I would have it show a message when it detects the charge pattern which tells you {a} that it has made a decision and {b} what it believes the charge sequence to be. That will allow you to do something if it gets it wrong.

...R