Using light levels for presence detection, help needed

Hey,

I have a “light meter” in the living room that I use for night time detection. Ive noticed that when people are moving around, watching tv, triggering other motion controlled lights, that the light level is quite varied. For some background;

Daytime < 100,
Nightime flag gets set when value is over 200
Lights on and Movement/Tv on 500 to 600
Lights on no movement or tv 560 to 575
Lights off 1000

You can see when everyone goes to sleep and we forget to turn off some lights the value is quite stable.

Looking at a graph as a human it is easy to spot these differences now I’m trying to work out exactly how I could use this for presence detection, but I cant seem to figure out how I would code it into openhab. Using MySQL for persistence.

I feel like this could be an interesting path to go down for presence detection in general, my light meter is just an LDR wired into an esp8266 that was already doing other stuff, and then sends the value via mqtt.

Thanks!
Jackson