24 lines
662 B
JavaScript
24 lines
662 B
JavaScript
import Gpios from '../src/gpios'
|
|
import hahooks from './homeassistant.js'
|
|
|
|
const PINS = [80,73,69,230,229,361,75,74,70]
|
|
|
|
let relays = new Gpios(PINS, {pinOpts:{activeLow:true}})
|
|
|
|
const BROKER = 'nas.kebler.net'
|
|
const TCP_PORT = 9075
|
|
|
|
;
|
|
(async () => {
|
|
await relays.addSocket('mqs','s','m', {host:BROKER, topics:['relays/set/+']})
|
|
hahooks.call(relays,'mqs')
|
|
await relays.addSocket('tcp','s','t', {port:TCP_PORT})
|
|
await relays.addSocket('web','s','w')
|
|
await relays.init()
|
|
|
|
// await relays.getSocket('mqs').subscribe(['relays/#'])
|
|
|
|
})().catch(err => {
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
// process.kill(process.pid, 'SIGTERM')
|
|
})
|