Code Monkey home page Code Monkey logo

homebridge-gpio-onoff's Introduction

Homebridge GPIO

Supports triggering General Purpose Input Output (GPIO) pins on platforms supporting the onoff package. It is based on homebridge-gpio, but using the onoff package instead of pi-gpio to be able to listen for changes in pin values.

Requirements

  • Homebridge - HomeKit support for the impatient
  • onoff - Reading and writing GPIO pins and listening for changes

Installation

  1. Install Homebridge using npm install -g homebridge
  2. Install this plugin npm install -g homebridge-gpio-onoff
  3. Update your configuration file

Configuration

Example config.json, creating a switch accessory that the user can switch on and off, setting the GPIO pin value to '1' or '0', respectively:

{
  "accessories": [
    {
      "accessory": "GPIO-OnOff",
      "name": "GPIO-7",
      "pin": 7,
      "direction": "out"
    }
  ]
}

accessory should be set to GPIO-OnOff for this plugin. name is the accessory's name, which is shown in HomeKit. pin is the physical GPIO pin number. direction can be set to either in to read from the GPIO pin or out to write to the pin. If set to in, the edge property can be set to rising, falling or both to have a changing GPIO pin value trigger an accessory value change (it is set to none by default).

By default, a simple 'Switch' accessory is created, which will be set to 'On' or 'Off' by a change in the input value. It is possible to change the service type and even the true and false values. For example, to have it act like a light sensor, you can specify:

{
  "accessories": [
    {
      "accessory": "GPIO-OnOff",
      "name": "GPIO-7",
      "pin": 7,
      "direction": "in",
      "edge": "both",
      "activeLow": true,
      "hapService": "LightSensor",
      "hapCharacteristic": "CurrentAmbientLightLevel",
      "trueValue": 100000,
      "falseValue": 0.0001
    }
  ]
}

activeLow will treat '0' as the true value and '1' as the false value. hapService can be set to one of the defined services in HomeKitTypes.js and hapCharacteristic to one of the characteristics defined for the service. If the characteristic values are not boolean, you can specify the values for true and false by setting trueValue and falseValue, respectively.

homebridge-gpio-onoff's People

Watchers

 avatar  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.