Openhab based device timer - kids device screen time

looking for a method of seeing and later cntrolling kids device time.

I have the unifi binding which can report in minutes up time…I’m hoping it resets each time the device disconnects, so working on that assumption.

so from that I guess I set up persistence on that uptime. But if it does reset, and say in the morning is 1 hour = 3600 minutes. The second time it comes online how can i grab the previous uptime of 3600 and add the new session? to make a combined total of 7200 minutes (2 hours).

Now that is a good idea!

I wonder if the unifi products can block internet access for an IP via a script? If so I guess I am buying a UDM pro.
Keen to follow.


if you have unifiy in place, you guess you can use the guest ticket system to provide vouchers with a time limit. I found this screenshot on the official help: UniFi - Guest Network, Guest Portal, and Hotspot System – Ubiquiti Support and Help Center

I have a real firewall in place (opnSense, pfsense) which is way more powerful as some unifi gateways, according to your setup, this would also be an approach.

You may want to enable LAN access, only disable “surfing”. I would not use Openhab to solve the problems, only to control other services (connec to unifi / pfsense) .

OPenhab was only going to be the timer system.

I did look at vouchers, but seemed a pain (for them and me). And his school requires the use of FamilyZone which manages the content filtering and the ability to set schedules (ie allowed to be using the computer for “play” during the hours of 16:00 and 21:00.

But obviously I don’t want him on minecraft for 5 hours…so I’ll see if I can run an accumlation of uptime from the unifi binding (persistence)…and it also looks like the block client command is part of the binding on a switch.

I’ve got an item from unifi that acumulates the session time. Where a session time is number of seconds or minutes for that session.

So storing 3000 seconds, 3600 seconds in influx is not helpful, as it’s the last entry of the session that we care about, not all the in between ones, since it does reset when the device goes offline.

But then it comes back on later in the day, it starts adding a new session which you need to add to.

I’ve used the item.sumSince, but I think the way I’m storing the session duration is not right, as it’s every 15 mins, where I need to just store the last entry…or a derivative since the last entry.