const Client = require('ssh2').Client;
on({id: 'javascript.0.steckdosen.steckdose_1'}, function (obj) {
if (getState("javascript.0.steckdosen.steckdose_1").val == 1)
{
execein1();
} else {
execaus1();
}
})
on({id: 'javascript.0.steckdosen.steckdose_2'}, function (obj) {
if (getState("javascript.0.steckdosen.steckdose_2").val == 1)
{
execein2();
} else {
execaus2();
}
})
on({id: 'javascript.0.steckdosen.steckdose_3'}, function (obj) {
if (getState("javascript.0.steckdosen.steckdose_3").val == 1)
{
execein3();
} else {
execaus3();
}
})
on({id: 'javascript.0.steckdosen.steckdose_4'}, function (obj) {
if (getState("javascript.0.steckdosen.steckdose_4").val == 1)
{
execein4();
} else {
execaus4();
}
})
on({id: 'javascript.0.steckdosen.steckdose_5'}, function (obj) {
if (getState("javascript.0.steckdosen.steckdose_5").val == 1)
{
execein5();
} else {
execaus5();
}
})
function execein1() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 1 1', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execaus1() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 1 0', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execein2() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 2 1', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execaus2() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 2 0', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execein3() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 3 1', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execaus3() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 3 0', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execein4() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 4 1', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execaus4() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 4 0', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execein5() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 5 1', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}
function execaus5() {
var conn = new Client();
conn.on('ready', function() {
conn.exec('/bin/send 00001 5 0', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
conn.end();
}).on('data', function(data) {
log('Ausgabe: ' + data);
}).stderr.on('data', function(data) {
log('Fehler: ' + data);
});
});
}).connect({
host: '10.100.10.12', // IP des RPi
port: 22,
username: 'root',
password: 'root'
});
}