diff --git a/fs/colors.cfg b/fs/colors.cfg index 86d17aa..d4567c0 100644 --- a/fs/colors.cfg +++ b/fs/colors.cfg @@ -1,7 +1,10 @@ [ {"name": "off", "red": 0, "green": 0, "blue": 0}, - {"name": "candle", "red": 50, "green": 45, "blue": 10}, - {"name": "warmWhite", "red": 100, "green": 100, "blue": 80}, - {"name": "coldWhite", "red": 100, "green": 100, "blue": 100}, + {"name": "candle", "red": 50, "green": 40, "blue": 10}, + {"name": "red", "red": 50, "green": 5, "blue": 5}, + {"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} ] \ No newline at end of file diff --git a/fs/init.js b/fs/init.js index 916e962..520ae9a 100644 --- a/fs/init.js +++ b/fs/init.js @@ -232,3 +232,51 @@ Timer.set(30000, true, function () { } }, 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; +} diff --git a/fs/lamps.cfg b/fs/lamps.cfg index cb777cb..ff299b4 100644 --- a/fs/lamps.cfg +++ b/fs/lamps.cfg @@ -1,9 +1,9 @@ [ {"level": "EG", "room": "Wohnzimmer", "id": "eg-wozi", "onColor": "candle"}, - {"level": "EG", "room": "Buero", "id": "eg-office", "onColor": "coldWhite"}, - {"level": "EG", "room": "Bad", "id": "eg-bad", "onColor": "warmWhite"}, - {"level": "EG", "room": "Kueche", "id": "eg-kueche", "onColor": "warmWhite"}, - {"level": "EG", "room": "Flur", "id": "eg-flur", "onColor": "candle"}, + {"level": "EG", "room": "Buero", "id": "eg-office", "onColor": "warmWhite"}, + {"level": "EG", "room": "Bad", "id": "eg-bad", "onColor": "red"}, + {"level": "EG", "room": "Kueche", "id": "eg-kueche", "onColor": "green"}, + {"level": "EG", "room": "Flur", "id": "eg-flur", "onColor": "blue"}, {"level": "OG", "room": "Wohnzimmer", "id": "og-wozi", "onColor": "candle"}, {"level": "OG", "room": "Buero", "id": "og-office", "onColor": "coldWhite"} ] diff --git a/mos.yml b/mos.yml index 9e93c7a..cb7a727 100644 --- a/mos.yml +++ b/mos.yml @@ -35,7 +35,7 @@ config_schema: - ["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.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.lampsFile", "s", "lamps.cfg", {title: "File name containing lamp definitions"}] - ["led.animationFile", "s", "animations.cfg", {title: "File name containing animation definitions"}]