Commit b4c9b70f authored by Peter Müller's avatar Peter Müller

Added readme, updated package.json

parent d9fd8332
node_modules
doc/*
.js
*.tgz
## v1.0.0 2017-05-28
- First official release
# Pimatic PCF8574 Plugin
[![npm version](https://badge.fury.io/js/pimatic-pcf8574.svg)](https://badge.fury.io/js/pimatic-pcf8574)
[![build status](https://git.cryhost.de/crycode/pimatic-pcf8574/badges/master/build.svg)](https://git.cryhost.de/crycode/pimatic-pcf8574/commits/master)
(c) 2017 Peter Müller <peter@crycode.de>
# pimatic-pcf8574
`pimatic-pcf8574` is a [pimatic](https://github.com/pimatic/pimatic) plugin that enables PCF8574 portexpander ICs to be used as **Switch**, **ContactSensor**, **PresenceSensor** or **ShutterController**.
The PCF8574/PCF8574A is an 8 bit/pin port expander IC, which can be controlled over the I2C-Bus.
Each of the 8 pins can be separately used as an input or output.
It also offers an interrupt signal, which can be used to detect input changes by the I2C master (e.g. a Raspberry Pi).
For more information about the PCF8574/PCF8574A please consult the [datasheet from Texas Instruments](http://www.ti.com/lit/ds/symlink/pcf8574.pdf).
## Installation
You can simply install this plugin via the frontend.
Alternatively you can add it manually to the `config.json` of pimatic:
```json
{
"plugin": "pcf8574",
"i2cBusNr": 1
}
```
This will fetch the most recent version from npm-registry on the next pimatic start and install the plugin.
## Configuration
The whole configuration can be made via the frontend in the *Devices* section.
You have to add one `PCF8574IC` device first, because the other devices will need this.
If you delete a `PCF8574IC` device, all devices associated to this device will also be deleted.
### Device PCF8574IC
This is a basic device which provides the inputs and outputs (8 pins) for the other devices.
You have to set the `address` of the IC.
Optionally you can enable the detection of input changes using an `interrupt` or using active `polling`.
If you need input change detection you should prefer using the interrupt, because polling leeds to a higher load on the I2C bus.
The pin number of the interrupt pin must to be the *BCM* pin number of the Raspberry Pi. (see https://de.pinout.xyz/)
### PCF8574ContactSensor, PCF8574PresenceSensor, PCF8574Switch and PCF8574Shutter
All other devices (`PCF8574ContactSensor`, `PCF8574PresenceSensor`, `PCF8574Switch` and `PCF8574Shutter`) needs an `PCF8574IC` device and a pin number of the IC.
Also you can define each pin as `inverted`, which assumes that the hardware inverts the logical signal.
A `PCF8574Shutter` device needs two `PCF8574IC` devices (which can be the same device) and also two pin numbers for up and down.
## License
Licensed under GPL Version 2
Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de/)
......@@ -10,17 +10,24 @@
"portexpander",
"raspberry pi",
"gpio",
"pimatic"
"pimatic",
"ContactSensor",
"PresenceSensor",
"Switch",
"ShutterController"
],
"main": "pcf8574",
"files": [
"CHANGELOG.md",
"device-config-schema.coffee",
"LICENSE.md",
"pcf8574-config-schema.coffee",
"pcf8574.coffee",
"README.md",
"pcf8574-config-schema.coffee"
"README.md"
],
"version": "0.0.1",
"homepage": "https://crycode.de",
"private": true,
"version": "1.0.0",
"homepage": "https://git.cryhost.de/crycode/pimatic-pcf8574",
"license": "GPL-2.0",
"repository": {
"type": "git",
"url": "https://git.cryhost.de/crycode/pimatic-pcf8574.git"
......
......@@ -112,9 +112,10 @@ module.exports = (env) ->
# remove all devices which belongs to this device
_.forEach @framework.deviceManager.getDevices(), (device) =>
if device.config.PCF8574IC is @id
env.logger.info "removing device #{device.config.id} because it belongs to #{@id}"
@framework.deviceManager.removeDevice device.config.id
_.forEach pcf8574DevicesEnums, (deviceEnum) =>
if device.config[deviceEnum]? and device.config[deviceEnum] is @id
env.logger.info "removing device #{device.config.id} because it belongs to #{@id}"
@framework.deviceManager.removeDevice device.config.id
# remove from the other device classes configs
_.forEach pcf8574Devices, (device) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment