Skip to content

Commit 277204b

Browse files
author
ticaki
committed
add controls.system
1 parent fff9094 commit 277204b

File tree

7 files changed

+233
-10
lines changed

7 files changed

+233
-10
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Connect to hyperion.ng server. Hyperion Projekt https://hyperion-project.org/for
1919
Placeholder for the next version (at the beginning of the line):
2020
### **WORK IN PROGRESS**
2121
-->
22+
### **WORK IN PROGRESS**
23+
* (ticaki) added controls.system
24+
2225
### 0.0.3 (2025-01-01)
2326
* (ticaki) add info.connection for adapter and device
2427

build/lib/definition.js

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/definition.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/hyperion.js

Lines changed: 18 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/hyperion.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/definition.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ export type statesObjectsType = {
143143
componentstate: { [key: string]: ioBroker.StateObject } | customChannelType;
144144
clear: { [key: string]: ioBroker.StateObject } | customChannelType;
145145
sourceselect: { [key: string]: ioBroker.StateObject } | customChannelType;
146+
system:
147+
| {
148+
suspend: ioBroker.StateObject;
149+
resume: ioBroker.StateObject;
150+
toggleSuspend: ioBroker.StateObject;
151+
idle: ioBroker.StateObject;
152+
toggleIdle: ioBroker.StateObject;
153+
restart: ioBroker.StateObject;
154+
}
155+
| customChannelType;
146156
} & customChannelType;
147157
};
148158
};
@@ -175,6 +185,14 @@ export const controlDefaults = {
175185
priority: 1,
176186
auto: false,
177187
},
188+
system: {
189+
suspend: false,
190+
resume: false,
191+
toggleSuspend: false,
192+
idle: false,
193+
toggleIdle: false,
194+
restart: false,
195+
},
178196
},
179197
};
180198

@@ -464,6 +482,88 @@ export const statesObjects: statesObjectsType = {
464482
native: {},
465483
},
466484
},
485+
system: {
486+
_channel: {
487+
_id: '',
488+
type: 'channel',
489+
common: {
490+
name: 'controls.system',
491+
},
492+
native: {},
493+
},
494+
suspend: {
495+
_id: '',
496+
type: 'state',
497+
common: {
498+
name: 'controls.system.suspend',
499+
type: 'boolean',
500+
role: 'button',
501+
read: false,
502+
write: true,
503+
},
504+
native: {},
505+
},
506+
resume: {
507+
_id: '',
508+
type: 'state',
509+
common: {
510+
name: 'controls.system.resume',
511+
type: 'boolean',
512+
role: 'button',
513+
read: false,
514+
write: true,
515+
},
516+
native: {},
517+
},
518+
toggleSuspend: {
519+
_id: '',
520+
type: 'state',
521+
common: {
522+
name: 'controls.system.toggleSuspend',
523+
type: 'boolean',
524+
role: 'button',
525+
read: false,
526+
write: true,
527+
},
528+
native: {},
529+
},
530+
idle: {
531+
_id: '',
532+
type: 'state',
533+
common: {
534+
name: 'controls.system.idle',
535+
type: 'boolean',
536+
role: 'button',
537+
read: false,
538+
write: true,
539+
},
540+
native: {},
541+
},
542+
toggleIdle: {
543+
_id: '',
544+
type: 'state',
545+
common: {
546+
name: 'controls.system.toggleIdle',
547+
type: 'boolean',
548+
role: 'button',
549+
read: false,
550+
write: true,
551+
},
552+
native: {},
553+
},
554+
restart: {
555+
_id: '',
556+
type: 'state',
557+
common: {
558+
name: 'controls.system.restart',
559+
type: 'boolean',
560+
role: 'button',
561+
read: false,
562+
write: true,
563+
},
564+
native: {},
565+
},
566+
},
467567
},
468568

469569
description: {

src/lib/hyperion.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,16 @@ export class Hyperion extends BaseClass {
577577
}
578578
this.ws.send(JSON.stringify({ ...command, tan: 100 }));
579579
}
580+
} else if (parts.length == 6 && parts[4] === 'system') {
581+
if (this.ws) {
582+
this.ws.send(
583+
JSON.stringify({
584+
command: parts[4],
585+
subcommand: parts[5],
586+
tan: 100,
587+
}),
588+
);
589+
}
580590
} else if (parts.length == 6 && parts[4] === 'sourceselect') {
581591
if (this.ws) {
582592
try {
@@ -640,17 +650,22 @@ export class Hyperion extends BaseClass {
640650
async updateACKControlsStates(data: any): Promise<void> {
641651
if (data.success) {
642652
if (data.tan == 220) {
653+
this.log.debug(`Command ${data.command} successful - JSON: ${JSON.stringify(data)}`);
643654
const state = this.library.readdb(`${this.UDN}.controls.action`);
644655
if (state !== undefined) {
645656
await this.library.writedp(`${this.UDN}.controls.action`, state.val);
646657
}
647658
} else if (data.tan == 100) {
648-
const values = this.library.getStates(`${this.UDN}.controls.${data.command}.`);
659+
const commands = data.command.split('-');
660+
this.log.debug(`Command ${commands[0]} successful - JSON: ${JSON.stringify(data)}`);
661+
const values = this.library.getStates(`${this.UDN}.controls.${commands[0]}.`);
649662
for (const k in values) {
650663
const v = k as keyof typeof values;
651-
if (k.endsWith('activate')) {
664+
if (commands[0] == 'color' && k.endsWith('activate')) {
665+
await this.library.writedp(k, false);
666+
} else if (commands[0] == 'sourceselect' && k.endsWith('auto')) {
652667
await this.library.writedp(k, false);
653-
} else if (k.endsWith('auto')) {
668+
} else if (commands[0] == 'system') {
654669
await this.library.writedp(k, false);
655670
} else {
656671
await this.library.writedp(k, values[v]!.val);

0 commit comments

Comments
 (0)