diff --git a/CHANGELOG.md b/CHANGELOG.md index a3dfd80b..245f1a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Option for the brightness automations based on sleep mode to run on SteamVR launch. This now happens automatically when a HMD is connected. +### Fixed + +- Duration inputs for shutdown sequence triggers being broken on systems using a 12-hour clock. +- Shutdown sequence being triggered over and over by the sleep mode trigger, when not using it to shut down or reboot the PC. + ## [1.13.3] ### Fixed @@ -36,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Certain types of selection in input fields (e.g. Ctrl+A) being blocked ### Changed + - Window titlebar icons ## [1.13.2] diff --git a/src-ui/app/components/duration-input-setting/duration-input-setting.component.html b/src-ui/app/components/duration-input-setting/duration-input-setting.component.html index 244190bd..d3e84eec 100644 --- a/src-ui/app/components/duration-input-setting/duration-input-setting.component.html +++ b/src-ui/app/components/duration-input-setting/duration-input-setting.component.html @@ -5,6 +5,7 @@ readonly (mouseenter)="mouseEnter('INPUT')" (mouseleave)="mouseLeave('INPUT')" + (click)="mouseClickInput()" [disabled]="disabled" />
!v)) this.inputOpen = false; }, 200); } + + mouseClickInput() { + if (this.inputOpen && this.hourInput?.nativeElement) { + this.hourInput.nativeElement.focus(); + } + } } diff --git a/src-ui/app/services/mqtt/integrations/hmd-data.mqtt-integration.ts b/src-ui/app/services/mqtt/integrations/hmd-data.mqtt-integration.ts index 2a7bf599..456063c1 100644 --- a/src-ui/app/services/mqtt/integrations/hmd-data.mqtt-integration.ts +++ b/src-ui/app/services/mqtt/integrations/hmd-data.mqtt-integration.ts @@ -27,18 +27,9 @@ export class HMDDataMqttIntegrationService { value: 'off', available: false, }); - await this.mqtt.initProperty({ - type: 'SENSOR', - id: 'debugHmdActivity', - topicPath: 'debugHmdActivity', - displayName: 'VR HMD Activity (DEBUG)', - value: 'null', - available: false, - }); this.openvr.status.subscribe((status) => { this.mqtt.setPropertyAvailability('hmdModel', status === 'INITIALIZED'); this.mqtt.setPropertyAvailability('hmdOnHead', status === 'INITIALIZED'); - this.mqtt.setPropertyAvailability('debugHmdActivity', status === 'INITIALIZED'); }); this.openvr.devices .pipe(map((devices) => devices.find((d) => d.class === 'HMD'))) @@ -47,7 +38,6 @@ export class HMDDataMqttIntegrationService { [device?.manufacturerName, device?.modelNumber].filter(Boolean).join(' ') ?? 'null'; this.mqtt.setSensorPropertyValue('hmdModel', name); this.mqtt.setSensorPropertyValue('hmdOnHead', device?.hmdOnHead ? 'on' : 'off'); - this.mqtt.setSensorPropertyValue('debugHmdActivity', device?.debugHmdActivity ?? 'null'); }); } } diff --git a/src-ui/app/services/shutdown-automations.service.ts b/src-ui/app/services/shutdown-automations.service.ts index 14111e9b..eaa5a8c6 100644 --- a/src-ui/app/services/shutdown-automations.service.ts +++ b/src-ui/app/services/shutdown-automations.service.ts @@ -56,6 +56,7 @@ export class ShutdownAutomationsService { ); private sleepMode = false; private sleepModeLastSet = 0; + private triggeredThisSleep = false; private aloneSince = 0; private isAlone = false; private wasNotAlone = false; @@ -105,7 +106,7 @@ export class ShutdownAutomationsService { this.automationConfigService.configs .pipe( map((configs) => configs.SHUTDOWN_AUTOMATIONS), - // Reset the 'last set' in case any of the trigger parameters change, so the user doesn't get any unwanted surprises + // Reset the 'alone since' in case any of the trigger parameters change, so the user doesn't get any unwanted surprises pairwise(), filter(([oldConfig, newConfig]) => { const keys: Array = [ @@ -125,6 +126,7 @@ export class ShutdownAutomationsService { // Track sleep mode being set this.sleepService.mode.pipe(distinctUntilChanged()).subscribe((mode) => { this.sleepMode = mode; + if (!this.sleepMode) this.triggeredThisSleep = false; this.sleepModeLastSet = Date.now(); }); // Track being alone @@ -197,11 +199,18 @@ export class ShutdownAutomationsService { private async handleTriggerOnSleep() { interval(1000) .pipe( - filter(() => this._stage.value === 'IDLE'), + // Only trigger if this trigger is enabled filter(() => this.config.triggersEnabled), filter(() => this.config.triggerOnSleep), + // Only trigger if the shutdown sequence isn't running + filter(() => this._stage.value === 'IDLE'), + // Only trigger if the sleep mode is active filter(() => this.sleepMode), + // Only trigger if we haven't already triggered this sleep (resets once sleep mode disables) + filter(() => !this.triggeredThisSleep), + // Only trigger if the sleep mode has been active for long enough filter(() => Date.now() - this.sleepModeLastSet >= this.config.triggerOnSleepDuration), + // Only trigger if we're in the activation window, if it's configured filter( () => !this.config.triggerOnSleepActivationWindow || @@ -209,11 +218,12 @@ export class ShutdownAutomationsService { this.config.triggerOnSleepActivationWindowStart, this.config.triggerOnSleepActivationWindowEnd ) - ), - // Only trigger once every 5 minutes at most - throttleTime(300000, asyncScheduler, { leading: true, trailing: false }) + ) ) - .subscribe(() => this.runSequence('SLEEP_TRIGGER')); + .subscribe(() => { + this.triggeredThisSleep = true; + this.runSequence('SLEEP_TRIGGER'); + }); } private async handleTriggerWhenAlone() { diff --git a/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.html b/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.html index b4a8f230..cf62ff96 100644 --- a/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.html +++ b/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.html @@ -44,15 +44,10 @@

shutdown-automations.triggers.triggers

shutdown-automations.triggers.whenAsleepDuration.description
-
- -
+
@@ -117,15 +112,10 @@

shutdown-automations.triggers.triggers

shutdown-automations.triggers.whenAloneDuration.description
-
- -
+
diff --git a/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.ts b/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.ts index 79955ae3..3ad649a4 100644 --- a/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.ts +++ b/src-ui/app/views/dashboard-view/views/shutdown-automations-view/tabs/shutdown-automations-triggers-tab/shutdown-automations-triggers-tab.component.ts @@ -22,8 +22,6 @@ export class ShutdownAutomationsTriggersTabComponent implements OnInit { protected onSleepActivationWindowEnd = '00:00'; protected whenAloneActivationWindowStart = '00:00'; protected whenAloneActivationWindowEnd = '00:00'; - protected onSleepDurationString = '00:00:00'; - protected whenAloneDurationString = '00:00:00'; constructor(private automationConfigs: AutomationConfigService, private destroyRef: DestroyRef) {} @@ -32,14 +30,12 @@ export class ShutdownAutomationsTriggersTabComponent implements OnInit { .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((configs) => { this.config = configs.SHUTDOWN_AUTOMATIONS; - this.onSleepDurationString = this.durationToString(this.config.triggerOnSleepDuration); this.onSleepActivationWindowStart = this.config.triggerOnSleepActivationWindowStart .map((v) => v.toString().padStart(2, '0')) .join(':'); this.onSleepActivationWindowEnd = this.config.triggerOnSleepActivationWindowEnd .map((v) => v.toString().padStart(2, '0')) .join(':'); - this.whenAloneDurationString = this.durationToString(this.config.triggerWhenAloneDuration); this.whenAloneActivationWindowStart = this.config.triggerWhenAloneActivationWindowStart .map((v) => v.toString().padStart(2, '0')) .join(':'); @@ -75,12 +71,7 @@ export class ShutdownAutomationsTriggersTabComponent implements OnInit { ); } - async onSleepDurationChange(value: string) { - let [hours, minutes, seconds] = value.split(':').map((v) => parseInt(v)); - if (isNaN(hours)) hours = 0; - if (isNaN(minutes)) minutes = 0; - if (isNaN(seconds)) seconds = 0; - const duration = (hours * 3600 + minutes * 60 + seconds) * 1000; + async onSleepDurationChange(duration: number) { await this.automationConfigs.updateAutomationConfig( 'SHUTDOWN_AUTOMATIONS', { @@ -89,12 +80,7 @@ export class ShutdownAutomationsTriggersTabComponent implements OnInit { ); } - async whenAloneDurationChange(value: string) { - let [hours, minutes, seconds] = value.split(':').map((v) => parseInt(v)); - if (isNaN(hours)) hours = 0; - if (isNaN(minutes)) minutes = 0; - if (isNaN(seconds)) seconds = 0; - const duration = (hours * 3600 + minutes * 60 + seconds) * 1000; + async whenAloneDurationChange(duration: number) { await this.automationConfigs.updateAutomationConfig( 'SHUTDOWN_AUTOMATIONS', {