power
The sos.management.power
API groups together methods related to the power state of the device. Such as rebooting, shutting down,
setting timers.
Power Management Capabilities
Capability | Description |
---|---|
SYSTEM_REBOOT | If device supports system reboot power action |
APP_RESTART | If device supports app restart power action |
TIMERS_PROPRIETARY | If device supports proprietary timers |
TIMERS_NATIVE | If device supports native timers |
SCHEDULE_POWER_ACTION | If device supports scheduled power actions |
If you want to check if the device supports those capabilities, use sos.management.supports()
.
Methods
appRestart()
The appRestart()
method initializes a restart of the signageOS app.
appRestart(): Promise<void>;
Return value
Resolves when the app restart is initiated.
Example
await sos.management.power.appRestart();
clearScheduledReboots()
Removes all scheduled reboot rules from the device.
clearScheduledReboots(): Promise<void>;
Return value
Resolves when all scheduled reboots are cleared.
Example
await sos.management.power.clearScheduledReboots();
getProprietaryTimers()
The getProprietaryTimers()
method returns a list of currently set
proprietary timers.
getProprietaryTimers(): Promise<IProprietaryTimer[]>;
Return value
Resolves with an array of proprietary timers.
Possible errors
If the timers cannot be retrieved.
Example
const timers = await sos.management.power.getProprietaryTimers();
getScheduledReboots()
Returns all scheduled reboot rules on the device set by the setScheduledReboot()
method.
getScheduledReboots(): Promise<IScheduledRebootActions[]>;
Return value
Resolves with an array of scheduled reboot actions.
Example
await sos.management.power.getScheduledReboots();
getTimers()
The getTimers()
method returns a list of currently set native timers.
getTimers(): Promise<ITimer[]>;
Return value
Resolves with an array of timers.
Example
await sos.management.power.getTimers();
removeScheduledReboot()
Removes scheduled reboot rule from the device (if it exists).
removeScheduledReboot(id: string): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | ID of the rule to be removed. |
Return value
Resolves when the scheduled reboot is removed.
Possible errors
If the id
is not a string or is empty.
Example
// Get scheduled reboots
const scheduledReboots = await sos.management.power.getScheduledReboots();
// Remove scheduled reboot on the first position
await sos.management.power.removeScheduledReboot(scheduledReboots[0].id);
setProprietaryTimer()
The setProprietaryTimer()
method creates or updates a
proprietary timer.
setProprietaryTimer(type: ProprietaryTimerType, timeOn: string | null, timeOff: string | null, weekdays: string[], keepAppletRunning?: boolean): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
type | TIMER_${number} | Yes | The type of the timer (TIMER_1 , ..., TIMER_7 ). |
timeOn | string | null | Yes | The time when the device should turn on. |
timeOff | string | null | Yes | The time when the device should turn off. |
weekdays | string[] | Yes | The days of the week when the timer should be active (mon , ..., sun ). |
keepAppletRunning | boolean | No | If true , the applet will be kept running when the timer is active on certain devices. |
Return value
Resolves when the proprietary timer is set.
Possible errors
- If the timer type is invalid or if the time format is incorrect.
- If the weekdays array contains an invalid weekday.
- If the
keepAppletRunning
parameter is not a boolean. - If the
timeOn
ortimeOff
parameters do not match the expected time format (HH:mm:ss
). - If the
weekdays
parameter is not an array of strings. - If the
weekdays
array contains an invalid weekday. - If the
timeOn
ortimeOff
parameters do not match the expected time format (HH:mm:ss
). - If the
type
parameter is not a valid timer type (e.g.,TIMER_1
,TIMER_2
, ...,TIMER_7
).
Example
await sos.management.power.setProprietaryTimer("TIMER_2", "08:00:00", "22:00:00", ["mon", "tue", "wed", "thu", "fri", "sat", "sun"], false);
setScheduledReboot()
Schedule an automatic reboot on the device. Calling this function will create one rule.
It is possible to set multiple rules, which can be later obtained by the getScheduledReboots
function.
- Setting a new scheduled reboot on the device might take up to 10 minutes to show in the Box.
- Every new scheduled reboot rule gets a unique identifier generated by the device, which might be later returned by
getScheduledReboots()
.
setScheduledReboot(weekdays: WeekdayType[], time: string): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
weekdays | WeekdayType[] | Yes | |
time | string | Yes | Time when the reboot should be executed. Format is HH:mm:ss . |
Return value
Resolves when the scheduled reboot is set.
Possible errors
- If the
weekdays
parameter is not an array of strings. - If the
time
parameter does not match the expected time format (HH:mm:ss
). - If the
weekdays
array contains an invalid weekday. - If the
time
parameter is not a string or does not match the expected format (HH:mm:ss
). - If the
weekdays
array is empty or contains invalid values.
Example
// Schedule reboot every Monday at 3:00 AM
await sos.management.power.setScheduledReboot(["MONDAY"], "03:00:00");
// Schedule reboot every Monday and Friday at 7:30 PM / 19:30
await sos.management.power.setScheduledReboot(["MONDAY", "FRIDAY"], "19:30:00");
setTimer()
The setTimer()
method creates or updates a native timer.
setTimer(type: keyof typeof TimerType, timeOn: string | null, timeOff: string | null, weekdays: string[], volume: number): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
type | "TIMER_1" | "TIMER_2" | "TIMER_3" | "TIMER_4" | "TIMER_5" | "TIMER_6" | "TIMER_7" | Yes | The type of the timer (TIMER_1 , ..., TIMER_7 ). |
timeOn | string | null | Yes | The time when the device should turn on. |
timeOff | string | null | Yes | The time when the device should turn off. |
weekdays | string[] | Yes | The days of the week when the timer should be active (mon , ..., sun ). |
volume | number | Yes | The volume level set when the device is turned on. |
Return value
Resolves when the timer is set.
Possible errors
- If the timer type is invalid.
- If the time format is incorrect.
- If the weekdays array contains an invalid weekday.
- If the
volume
parameter is not a number between 0 and 100. - If the
timeOn
ortimeOff
parameters do not match the expected time format (HH:mm:ss
). - If the
weekdays
parameter is not an array of strings. - If the
type
parameter is not a valid timer type (e.g.,TIMER_1
,TIMER_2
, ...,TIMER_7
).
Example
await sos.management.power.setTimer("TIMER_1", "08:00:00", "22:00:00", ["mon", "tue", "wed", "thu", "fri", "sat", "sun"], 30);
systemReboot()
The systemReboot()
method initializes a system reboot.
systemReboot(): Promise<void>;
Return value
Resolves when the system reboot is initiated.
Example
await sos.management.power.systemReboot();
unsetProprietaryTimer()
The unsetProprietaryTimer()
method removes the specified
proprietary timer.
unsetProprietaryTimer(type: ProprietaryTimerType): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
type | TIMER_${number} | Yes | The type of the timer (TIMER_1 , ..., TIMER_7 ). |
Return value
Resolves when the proprietary timer is removed.
Possible errors
If the timer type is invalid.
Example
await sos.management.power.unsetProprietaryTimer("TIMER_2");
unsetTimer()
The unsetTimer()
method removes the specified native timer.
unsetTimer(type: keyof typeof TimerType): Promise<void>;
Params
Name | Type | Required | Description |
---|---|---|---|
type | "TIMER_1" | "TIMER_2" | "TIMER_3" | "TIMER_4" | "TIMER_5" | "TIMER_6" | "TIMER_7" | Yes | The type of the timer (TIMER_1 , ..., TIMER_7 ). |
Return value
Resolves when the timer is removed.
Possible errors
If the timer type is invalid.
Example
await sos.management.power.unsetTimer("TIMER_2");