Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Bitte lege dieses Script im IOBroker unter scripte an -> als Javascript -> dieses script muss in den Ordner Global
- unten musst du deine fibaro benutzerdaten noch eintragen
- Das Script wurde von Nico Bode von https://www.intelligentes-haus.de entwickelt.
- Die Anleitung inkl. Video findest du hier:
- */
- var fibaro_username = ''; // Fibaro Admin Loginname
- var fibaro_password = ''; // Fibaro Password
- var fibaro_ip = ''; // Fibaro IP adresse
- function fibaro_create_global_var(fibaro_global_name,fibaro_global_value,fibaro_create_when_not_exist=true) {
- request.post({
- url: 'http://'+fibaro_username+':'+fibaro_password+'@'+fibaro_ip+'/api/globalVariables/',
- form: '{"name":"'+fibaro_global_name+'","value":"'+fibaro_global_value+'"}'
- }, function(error, response, body) {
- if (error) {
- //log(error, 'error');
- } else {
- if (response.statusCode == 201) {
- log('Variable '+ fibaro_global_name+' bei Fibaro mit dem Wert '+fibaro_global_value+' angelegt ','info');
- } else {
- log('HTTP Fehler2','info');
- log(JSON.stringify(response), 'error');
- }
- }
- });
- }
- function fibaro_update_global_var(fibaro_global_name,fibaro_global_value,fibaro_create_when_not_exist=true) {
- toString(fibaro_global_name);
- toString(fibaro_global_value);
- request.put({
- url: 'http://'+fibaro_username+':'+fibaro_password+'@'+fibaro_ip+'/api/globalVariables/'+fibaro_global_name,
- form: '{"name":"'+fibaro_global_name+'","value":"'+fibaro_global_value+'"}'
- }, function(error, response, body) {
- if (error) {
- log(error, 'error');
- } else {
- if (response.statusCode == 200) {
- log('Variable '+ fibaro_global_name+' bei Fibaro mit dem Wert '+fibaro_global_value+' gespeichert ','info');
- } else {
- if(response.statusCode == 404 && fibaro_create_when_not_exist === true) {
- log('Variable wird angelegt','info');
- fibaro_create_global_var(fibaro_global_name,fibaro_global_value);
- } else {
- log('HTTP Fehler','info');
- log(JSON.stringify(response), 'error');
- }
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement