Git Product home page Git Product logo

homebridge-pfsense's Introduction

Initial Commit of creating a homekit switch to toggle rules in pfsense

The script will toggle the disabled flag for any rule with a description beginning with a specified term. Script will also provide a state

Usage:

  • ./toggle_rule enable
  • ./toggle_rule disable
  • ./toggle_rule state

Prerequisites

  1. Pfsense needs to have a working instance of FauxAPI https://github.com/ndejong/pfsense_fauxapi

  2. Need to have a working instance of homebridge running

  3. Install the cmdswitch2 plugin https://www.npmjs.com/package/homebridge-cmdswitch2

Installation Directions

  1. Create a folder to house the scripts

  2. Download the toggle_rule script into the folder

  3. Download the FauxAPI python library https://github.com/ndejong/pfsense_fauxapi_client_python

  4. Place the following files at the root of the folder (very important)

  • __version__.py
  • PfsenseFauxapi.py

Also, modify PfsenseFauxapi.py line 24:

Old: from .version import version

New: from version import version

  1. chmod +x toggle_rule

  2. In your config.json file:

    {
    "platform":"cmdSwitch2",
    "name":"CMD Switch",
    "switches":[{
            "name":"Kids Internet",
            "on_cmd":"/home/folder/toggle_rule enable",
            "off_cmd":"/home/folder/toggle_rule disable",
            "state_cmd":"/home/folder/toggle_rule state 2>&1 /dev/null; script_output=$? ; echo $script_output | grep 1"
            }]
    }
    

The state_cmd needs to be written exactly (with exception to the folder path). Basically, the state_cmd only looks to see if the switch is on. Toggle_rule will report an exit value of 1 if that's the case. I had to perform some extra steps to report back a 1 for the plugin

  1. Modify toggle_rule:

     api_hostname = "pfsense_host"
     api_key = "fauxapi_key"
     api_secret = "fauxpai_secret"
     rule_prefix = "TEST"
    

homebridge-pfsense's People

Contributors

tman785 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.