Skip to main content
  1. Posts/

Manage NextDNS Parental Control rules from OpenHAB home automation

·399 words·2 mins· loading ·
OpenHAB Home Automation
Harmonise controls for your NextDNS Parental Controls into your OpenHAB home automation configuration and block those cheeky monkeys out of Youtube :)

Overview
#

If (like me) you have a few cheeky little children using your internet, you might from time to time want to limit the services they can access. There are all sorts of ways to do this, but I’ve settled on using NextDNS to do DNS blocking on all the devices they use on a specific VLAN and WIFI SSID in my home. The details of that are beyond this script, but assuming you’re also using NextDNS & OpenHAB this might be helpful!

NextDNS gives you some handy tools to be able to block or allow all sorts of nasties, but I like to have a few rules for specific sites like YouTube or Snapchat to stop the kids wasting time. These scripts and items will give you the ability to manage these from OpenHAB sitemaps and rules so you can integrate and automate.

What’s in this project
#

Included here are two simple rules for OpenHAB:

  1. A cron running every minutes to query NextDNS and synchronise any changes to the Parental Controls section down to your OpenHAB Items (including creating them if needed!)
  2. A rule to respond to any changes you make to these items in OpenHAB and synnchronise them back to NextDNS so they take effect

Prerequisites
#

How to
#

Visit the Github repo for full instructions and details.

alackmann/openhab-nextdns

Javascript rules for OpenHAB home automation to allow control of Parental Control rules

JavaScript
0
0

What else
#

You might also like these extra rules I use for home. You can add them to the nextdns.js file you’ve added to OpenHAB

/**
* Always turn on "recreation time" whenever Youtube blocking is enabled. Ensures your time-based rules in NextDNS are observed 
*/
rules.JSRule({
  name: "Synchronise Recreation time for Youtube",
  description: "",
  triggers: [triggers.ItemStateChangeTrigger('NextDNS_youtube_active', undefined, 'ON')], 
  tags: [],
  id: "NextDNS_EnableRecreationTimeWhenBlockingEnabled",
  execute: (event) => {
    items.getItem('NextDNS_youtube_recreation').sendCommand('ON');
  }
});

/**
* So that we dont accidentally allow YouTube tomorrow when we allowed it today, reset the blocking back to ON each morning at 3am local time
*/
rules.JSRule({
  name: "Reset YouTube blocking each day to be enabled",
  description: "",
  triggers: [triggers.GenericCronTrigger("0 0 3 * * ?")],
  tags: [],
  id: "NextDNS_ResetYouTubeEachDay",
  execute: (event) => {
    items.getItem('NextDNS_youtube_active').sendCommand('ON');
  }
});