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

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

homebridge-gpio-onoff's Issues

Please help

Hi

Running home bridge, I Get the fallowing issue:

[6/10/2017, 12:39:18 AM] Warning: skipping plugin found at '/node_modules/homebridge-gpio-onoff' since we already loaded the same plugin from '/usr/local/lib/node_modules/homebridge-gpio-onoff'.
[6/10/2017, 12:39:19 AM] ====================
[6/10/2017, 12:39:19 AM] ERROR LOADING PLUGIN homebridge-gpio-onoff:
[6/10/2017, 12:39:19 AM] Error: Could not locate the bindings file. Tried:
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/build/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/build/Debug/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/build/Release/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/out/Debug/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/Debug/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/out/Release/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/Release/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/build/default/epoll.node
→ /usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/compiled/7.10.0/linux/arm/epoll.node
at bindings (/usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/bindings/bindings.js:88:9)
at Object. (/usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/epoll/epoll.js:1:99)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/usr/local/lib/node_modules/homebridge-gpio-onoff/node_modules/onoff/onoff.js:4:11)

How Can I add multiple GPIO accessory ?

Hi

I've already added ambient light.
I also have gpio motion sensor, how Can I add multiple accessories ?

I wish to add noise sensor and motion sensor, please help me with this ;)

MotionSensor, configured, but not working

Hello,

I added the Motion sensor in log I can see that value changes from 0 to 1, but in home app I can only see motion detector, not working when there is a motion around.

Here is my Accessory config
{
"accessory": "GPIO-OnOff",
"name": "Motion",
"pin": 24,
"direction": "in",
"edge": "both",
"activeLow": false,
"hapService": "MotionSensor",
"hapCharacteristic": "MotionDetected"
},

No GPIO real actions happening

Install - all went OK.
Set up json file, Hombridge works, and I can switch from Apply Home App the demo GPIO-7 switch on/off, but there is no any real actions happening on the GPIO exit. Also tested the sample light sensor script. The same, all kind of works, but real 3.3/0V status on the GPIO pin is not read.

Why?

Using different HAP service doesn't work

Hi!

I currently tried to setup this homebridge plugin. It works so far as a normal switch, but if I tried to switch to a different HAP service (Doorbell) nothing changes, it shows up as switch in the Home.app on my iOS device.

Here is my config:

{
  "accessory": "GPIO-OnOff",
  "name": "Doorbell",
  "pin": 17,
  "direction": "in",
  "edge": "falling",
  "activeLow": true,
  "hapService": "DoorBell",
  "hapCharacteristic": "ProgrammableSwitchEvent",
  "trueValue": 0,
  "falseValue": 1
}

The terminal output looks like this, if i press the button:

[Doorbell] Received GPIO value 0 as false

Any idea what´s wrong?

Usage with pwm

Hi,

I’ve been trying to use this plugin to expose a switch that works as an ’on/off’ device to control the backlight of a display. I’m currently using wiringpi with the commands ‘gpio -g pwm 19 0’ to turn it off and ‘gpio -g pwm 19 60’ for full brightness.

Is there a way to achieve this using this plugin?

Toggle switch?

Is the following possible?

  1. Turn physical switch to on position (3.3v to GPIO)
  2. Bulb (via HomeKit automation) switches on
  3. Switch bulb off using Siri/Homekit/another switch
  4. Turn physical switch to off position (0v to GPIO)
  5. Bulb switches on

So the switch is then a toggle and the GPIO state doesn't reflect the bulb state?

Light sensor only 0 or 1

Hello, @krisbreuker

Thank you very much for this plug-in. It is the only one that I found that adds a light sensor to HomeKit using GPIO!

Let me ask you something: looks like it is only showing 100.000 ou 0.00001 LUX readings, as if it was a binary sensor only. My sensor is the LM393 module which is digital and, in theory, would show actual LUX readings.

I’m using the suggested json from your repository.

Am I missing something?

Thanks!

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.