npm.io
2.0.1 • Published 3 weeks ago

homebridge-electromagnetic-lock

Licence
MIT
Version
2.0.1
Deps
3
Size
9 kB
Vulns
0
Weekly
0

Homebridge Electromagnetic Lock

Homebridge Electromagnetic Lock plugin to control electromagnetic lock via Raspberry Pi GPIO lines.

Objective

Electromagnetic lock controlled through libgpiod.

Installation

  1. install homebridge npm install -g homebridge
  2. install libgpiod sudo apt install -y gpiod libgpiod-dev
  3. install this plugin npm install -g homebridge-electromagnetic-lock
  4. update your ~/.homebridge/config.json file (use sample-config.json as a reference)

Configuration

Sample accessory:

"accessories": [
  {
    "accessory": "ElectromagneticLock",
    "name": "Lock",
    "lockPin": 18,
    "gpioChip": 0,
    "activeLow": true,
    "unlockingDuration": 2
  }
]

Fields:

  • accessory must always be ElectromagneticLock
  • name accessory name, e.g. Lock
  • lockPin BCM GPIO / libgpiod line number for unlocking lock, not physical board pin
  • gpioChip [optional, default: 0] GPIO chip number used by libgpiod, usually 0 on Raspberry Pi
  • activeLow [optional, default: true] true: relay activated by low state (0), false: relay activated by high state (1), affects lockPin
  • unlockingDuration [optional, default: 2] how long lockPin should be active (seconds)

For example, Raspberry Pi physical pin 12 is BCM GPIO 18, so use "lockPin": 18.

Upgrading from v1.x

Version 2.0.0 changed the GPIO backend from rpi-gpio/sysfs to libgpiod. The lockPin option now uses the BCM GPIO / libgpiod line number, not the physical board pin.

For example, if v1.x used physical pin 12, v2.x should use "lockPin": 18.

Troubleshooting

Attribution

This project is based on Homebridge GPIO Electromagnetic Lock by Panda Unit sp. z o.o. (github.com/pandaunit/homebridge-gpio-electromagnetic-lock).