Skip to content

Commit

Permalink
Fix Intellibrite theme setting
Browse files Browse the repository at this point in the history
  • Loading branch information
celestinjr committed Jul 2, 2024
1 parent 374330f commit dab8867
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions controller/nixie/circuits/Circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,22 @@ export class NixieCircuit extends NixieEquipment {
}
protected async setIntelliBriteThemeAsync(cstate: CircuitState, theme: any): Promise<InterfaceServerResponse> {
let arr = [];
if (cstate.isOn) arr.push({ isOn: false, timeout: 1000 });
let count = typeof theme !== 'undefined' && theme.sequence ? theme.sequence : 0;
if (cstate.isOn) arr.push({ isOn: false, timeout: 1000 });

// Removing this. No need to turn the light off first. We actually need it on to start the sequence for theme setting to work correctly when the light is starting from the off state.
// if (cstate.isOn) arr.push({ isOn: false, timeout: 1000 });

// Start the sequence of off/on after the light is on.
arr.push({ isOn: true, timeout: 100 });
for (let i = 0; i < count; i++) {
if (i < count - 1) {
arr.push({ isOn: true, timeout: 100 });
arr.push({ isOn: false, timeout: 100 });
}
else arr.push({ isOn: true, timeout: 1000 });
arr.push({ isOn: false, timeout: 100 });
arr.push({ isOn: true, timeout: 100 });
}
logger.debug(arr);
// Ensure light stays on long enough for the theme to stick (required for light group theme setting to function correctly).
// 2s was too short.
arr.push({ isOn: true, timeout: 3000 });

logger.debug(arr);
let res = await NixieEquipment.putDeviceService(this.circuit.connectionId, `/state/device/${this.circuit.deviceBinding}`, arr, 60000);
// Even though we ended with on we need to make sure that the relay stays on now that we are done.
if (!res.error) {
Expand Down

0 comments on commit dab8867

Please sign in to comment.