You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
824 B

const Tinkerforge = require('tinkerforge')
/**
*
*
*
*
*/
class TinkerforgePower {
constructor(power) {
this.host = 'localhost'
this.port = 4223
this.UID = 'xxx'
this.power = power
this.ipcon = new Tinkerforge.IPConnection()
this.idr = new Tinkerforge.BrickletIndustrialDualRelay(this.UID, this.ipcon);
this.ipcon.connect(this.host, this.port, (error) => {
this._handleError(error)
})
this.ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED, (connectReason) => {
this._handlePower(this.power)
})
}
_handleError(error) {
console.log('Error: ' + error)
}
_handlePower(connectReason) {
this.idr.setValue(this.power, this.power)
}
}
module.exports = TinkerforgePower