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