diff --git a/command/cmd_leds.uc b/command/cmd_leds.uc index 5832590..7ecfeba 100644 --- a/command/cmd_leds.uc +++ b/command/cmd_leds.uc @@ -1,6 +1,7 @@ {% function set_led(val, path) { + let cursor = uci.cursor(path); cursor.set("system", "@system[-1]", "leds_off", val); cursor.commit(); } diff --git a/renderer/templates/unit.uc b/renderer/templates/unit.uc index b777aee..8eca00b 100644 --- a/renderer/templates/unit.uc +++ b/renderer/templates/unit.uc @@ -1,11 +1,12 @@ # Basic unit configuration {% if (unit.name): %} -set system.description={{ s(unit.name) }} +set system.@system[-1].description={{ s(unit.name) }} {% endif %} {% if (unit.location): %} -set system.notes={{ s(unit.location) }} +set system.@system[-1].notes={{ s(unit.location) }} {% endif %} {% if (unit.timezone): %} -set system.timezone={{ s(unit.timezone) }} +set system.@system[-1].timezone={{ s(unit.timezone) }} {% endif %} +set system.@system[-1].leds_off={{ b(!unit.leds_active) }} diff --git a/schema/unit.yml b/schema/unit.yml index 3a14f8e..8d91ed2 100644 --- a/schema/unit.yml +++ b/schema/unit.yml @@ -21,3 +21,8 @@ properties: - UTC - EST5 - CET-1CEST,M3.5.0,M10.5.0/3 + led-active: + description: + This allows forcing all LEDs off. + type: boolean + default: true diff --git a/schemareader.uc b/schemareader.uc index bd46cbe..fc4a1b2 100644 --- a/schemareader.uc +++ b/schemareader.uc @@ -101,6 +101,20 @@ function instantiateUnit(location, value, errors) { obj.timezone = parseTimezone(location + "/timezone", value["timezone"], errors); } + function parseLedActive(location, value, errors) { + if (type(value) != "bool") + push(errors, [ location, "must be of type boolean" ]); + + return value; + } + + if (exists(value, "led-active")) { + obj.led_active = parseLedActive(location + "/led-active", value["led-active"], errors); + } + else { + obj.led_active = true; + } + return obj; } diff --git a/ucentral.schema.json b/ucentral.schema.json index 8e8fecd..2cc9fd7 100644 --- a/ucentral.schema.json +++ b/ucentral.schema.json @@ -54,6 +54,10 @@ "EST5", "CET-1CEST,M3.5.0,M10.5.0/3" ] + }, + "led-active": { + "type": "boolean", + "default": true } } },