Introduced RPC interface to change some settings and get config files
This commit is contained in:
parent
3f369f3d6b
commit
94910cc5e8
|
@ -1,7 +1,10 @@
|
||||||
[
|
[
|
||||||
{"name": "off", "red": 0, "green": 0, "blue": 0},
|
{"name": "off", "red": 0, "green": 0, "blue": 0},
|
||||||
{"name": "candle", "red": 50, "green": 45, "blue": 10},
|
{"name": "candle", "red": 50, "green": 40, "blue": 10},
|
||||||
{"name": "warmWhite", "red": 100, "green": 100, "blue": 80},
|
{"name": "red", "red": 50, "green": 5, "blue": 5},
|
||||||
{"name": "coldWhite", "red": 100, "green": 100, "blue": 100},
|
{"name": "green", "red": 5, "green": 50, "blue": 5},
|
||||||
|
{"name": "blue", "red": 5, "green": 5, "blue": 50},
|
||||||
|
{"name": "warmWhite", "red": 80, "green": 80, "blue": 40},
|
||||||
|
{"name": "coldWhite", "red": 80, "green": 80, "blue": 100},
|
||||||
{"name": "brightWhite", "red": 255, "green": 255, "blue": 255}
|
{"name": "brightWhite", "red": 255, "green": 255, "blue": 255}
|
||||||
]
|
]
|
48
fs/init.js
48
fs/init.js
|
@ -232,3 +232,51 @@ Timer.set(30000, true, function () {
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
RPC.addHandler('led.setBrightness', function(args) {
|
||||||
|
// print(args);
|
||||||
|
if (args !== undefined && args.level !== undefined) {
|
||||||
|
if (args.level > 0 && args.level <= 100) {
|
||||||
|
brightnessAdjustment = args.level;
|
||||||
|
return { result: 'ok' };
|
||||||
|
} else {
|
||||||
|
return { error: 'Brightness level must be in the range 1..100' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { error: 'level is required having a value in the range 1..100' };
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
|
||||||
|
RPC.addHandler('led.pause', function(args) {
|
||||||
|
LEDStateEngine_pause();
|
||||||
|
return { result: 'ok' };
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
RPC.addHandler('led.run', function(args) {
|
||||||
|
LEDStateEngine_start();
|
||||||
|
return { result: 'ok' };
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
RPC.addHandler('led.getColors', function(args) {
|
||||||
|
let colors = JSON.parse(File.read(colorFile));
|
||||||
|
return { result: 'ok', colors: colors };
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
RPC.addHandler('led.getLamps', function(args) {
|
||||||
|
let lamps = JSON.parse(File.read(lampsFile));
|
||||||
|
return { result: 'ok', lamps: lamps };
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
RPC.addHandler('led.getAnimations', function(args) {
|
||||||
|
let anims = JSON.parse(File.read(animationFile));
|
||||||
|
return { result: 'ok', animations: anims };
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
function saveFile(filename, content) {
|
||||||
|
let backupFilename = 'bak-' + filename;
|
||||||
|
File.remove(backupFilename);
|
||||||
|
File.rename(filename, backupFilename);
|
||||||
|
File.write(JSON.stringify(content), filename);
|
||||||
|
let backupFilename = null;
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[
|
[
|
||||||
{"level": "EG", "room": "Wohnzimmer", "id": "eg-wozi", "onColor": "candle"},
|
{"level": "EG", "room": "Wohnzimmer", "id": "eg-wozi", "onColor": "candle"},
|
||||||
{"level": "EG", "room": "Buero", "id": "eg-office", "onColor": "coldWhite"},
|
{"level": "EG", "room": "Buero", "id": "eg-office", "onColor": "warmWhite"},
|
||||||
{"level": "EG", "room": "Bad", "id": "eg-bad", "onColor": "warmWhite"},
|
{"level": "EG", "room": "Bad", "id": "eg-bad", "onColor": "red"},
|
||||||
{"level": "EG", "room": "Kueche", "id": "eg-kueche", "onColor": "warmWhite"},
|
{"level": "EG", "room": "Kueche", "id": "eg-kueche", "onColor": "green"},
|
||||||
{"level": "EG", "room": "Flur", "id": "eg-flur", "onColor": "candle"},
|
{"level": "EG", "room": "Flur", "id": "eg-flur", "onColor": "blue"},
|
||||||
{"level": "OG", "room": "Wohnzimmer", "id": "og-wozi", "onColor": "candle"},
|
{"level": "OG", "room": "Wohnzimmer", "id": "og-wozi", "onColor": "candle"},
|
||||||
{"level": "OG", "room": "Buero", "id": "og-office", "onColor": "coldWhite"}
|
{"level": "OG", "room": "Buero", "id": "og-office", "onColor": "coldWhite"}
|
||||||
]
|
]
|
||||||
|
|
2
mos.yml
2
mos.yml
|
@ -35,7 +35,7 @@ config_schema:
|
||||||
- ["led.useDefaults", "b", false, {title: "Use default values for colors, led-definitions, animations"}]
|
- ["led.useDefaults", "b", false, {title: "Use default values for colors, led-definitions, animations"}]
|
||||||
- ["led.count", "i", 32, {title: "Number of LEDs connected in the chain"}]
|
- ["led.count", "i", 32, {title: "Number of LEDs connected in the chain"}]
|
||||||
- ["led.updateCycle", "i", 500, {title: "Frequency of LED update in ms"}]
|
- ["led.updateCycle", "i", 500, {title: "Frequency of LED update in ms"}]
|
||||||
- ["led.brightness", "i", 30, {title: "Default brightness in % (1-100)"}]
|
- ["led.brightness", "i", 20, {title: "Default brightness in % (1-100)"}]
|
||||||
- ["led.colorFile", "s", "colors.cfg", {title: "File name containing color definitions"}]
|
- ["led.colorFile", "s", "colors.cfg", {title: "File name containing color definitions"}]
|
||||||
- ["led.lampsFile", "s", "lamps.cfg", {title: "File name containing lamp definitions"}]
|
- ["led.lampsFile", "s", "lamps.cfg", {title: "File name containing lamp definitions"}]
|
||||||
- ["led.animationFile", "s", "animations.cfg", {title: "File name containing animation definitions"}]
|
- ["led.animationFile", "s", "animations.cfg", {title: "File name containing animation definitions"}]
|
||||||
|
|
Loading…
Reference in New Issue