Skip to content

Commit

Permalink
renderer: fix system settings and add led-active to datamodel
Browse files Browse the repository at this point in the history
Signed-off-by: John Crispin <[email protected]>
  • Loading branch information
blogic committed Jun 24, 2021
1 parent d40781d commit 630a2af
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions command/cmd_leds.uc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{%
function set_led(val, path)
{
let cursor = uci.cursor(path);
cursor.set("system", "@system[-1]", "leds_off", val);
cursor.commit();
}
Expand Down
7 changes: 4 additions & 3 deletions renderer/templates/unit.uc
Original file line number Diff line number Diff line change
@@ -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) }}
5 changes: 5 additions & 0 deletions schema/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions schemareader.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions ucentral.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"EST5",
"CET-1CEST,M3.5.0,M10.5.0/3"
]
},
"led-active": {
"type": "boolean",
"default": true
}
}
},
Expand Down

0 comments on commit 630a2af

Please sign in to comment.