Skip to content

Commit

Permalink
Support base stations without power state reporting. Add support for …
Browse files Browse the repository at this point in the history
…forcing power states for basestations.
  • Loading branch information
Raphiiko committed May 19, 2024
1 parent efd6328 commit 8482dc0
Show file tree
Hide file tree
Showing 26 changed files with 425 additions and 142 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- OVRToolkit as a notification provider
- Integration with Home Assistant via MQTT
- Additional configuration options for the sleep detector (controller presence, sleeping pose)
- Options for forcing the power state of base stations (Right click the power button).
- Support for base stations that don't report their status. (Newer lighthouses sold through Valve, likely manufactured by HTC)

### Changed

Expand Down
4 changes: 4 additions & 0 deletions src-core/src/lighthouse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ pub async fn get_device_power_state(
Ok(characteristic) => characteristic,
Err(err) => return Err(err),
};
// (Raphii): For personal testing purposes, I can pretend one of my basestations doesn't report its status
// if device_id == "BluetoothLE#BluetoothLE48:51:c5:c6:5f:4c-f1:46:cc:56:2e:8c" {
// return Err(LighthouseError::CharacteristicNotFound);
// }
let value = match characteristic.read().await {
Ok(value) => value,
Err(err) => return Err(LighthouseError::FailedToReadCharacteristic(err)),
Expand Down
4 changes: 2 additions & 2 deletions src-overlay-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src-ui/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ import { SleepDetectionDetectionTabComponent } from './views/dashboard-view/view
import { SleepDetectionSleepEnableTabComponent } from './views/dashboard-view/views/sleep-detection-view/tabs/sleep-detection-sleep-enable-tab/sleep-detection-sleep-enable-tab.component';
import { SleepDetectionSleepDisableTabComponent } from './views/dashboard-view/views/sleep-detection-view/tabs/sleep-detection-sleep-disable-tab/sleep-detection-sleep-disable-tab.component';
import { SleepDetectionViewComponent } from './views/dashboard-view/views/sleep-detection-view/sleep-detection-view.component';
import { DeviceListLhStatePopoverComponent } from './components/device-list/device-list-lh-state-popover/device-list-lh-state-popover.component';

[
localeEN,
Expand Down Expand Up @@ -336,6 +337,7 @@ export function createTranslateLoader(http: HttpClient) {
SleepDetectionDetectionTabComponent,
SleepDetectionSleepEnableTabComponent,
SleepDetectionSleepDisableTabComponent,
DeviceListLhStatePopoverComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,67 @@
<ng-container *ngIf="lighthouseDevice || ovrDevice">
<div class="wrapper" [class.device-ignored]="isDeviceIgnored()">
<ng-container *ngIf="mode">
<div class="wrapper" [class.device-ignored]="isDeviceIgnored">
<div class="header-bar">
<div class="header-bar-icon">
<img [src]="'/assets/img/icon_' + icon + '.png'" class="category-icon" />
</div>
<div class="header-bar-info" (click)="editDevice()">
<div class="device-name" translate>{{ deviceName }}</div>
<div class="device-serial" *ngIf="!deviceNickname && deviceRole"
>{{ 'comp.device-list.deviceRole.' + deviceRole | translate }}
>{{ 'comp.device-list.deviceRole.' + deviceRole | translate }}
</div>
<div class="device-serial" *ngIf="!deviceNickname && !deviceRole"
>{{ deviceIdentifier }}
>{{ deviceIdentifier }}
</div>
<div class="device-nickname" *ngIf="deviceNickname">{{ deviceNickname }}</div>
</div>
<div class="header-bar-spacer"></div>
<div class="header-bar-action" *ngIf="!isDeviceIgnored()">
<div class="header-bar-action" *ngIf="!isDeviceIgnored">
<button
[id]="'btn-power-' + cssId"
class="btn-power"
[class.power-off]="
powerButtonState === 'turn_off' || powerButtonState === 'turn_off_busy'
"
[class.power-on]="powerButtonState === 'turn_on' || powerButtonState === 'turn_on_busy'"
[class.power-unknown]="powerButtonState === 'turn_on_off' || powerButtonState === 'turn_on_off_busy'"
*ngIf="powerButtonState !== 'hide'"
[disabled]="powerButtonState === 'turn_off_busy' || powerButtonState === 'turn_on_busy'"
[@fade]
(click)="clickDevicePowerButton()"
(contextmenu)="rightClickDevicePowerButton()"
[ngStyle]="{ 'anchor-name': powerButtonAnchorId }"
>
<i
class="material-icons"
*ngIf="powerButtonState === 'turn_off' || powerButtonState === 'turn_on'"
>power_settings_new</i
>power_settings_new</i
>
<i
class="material-icons"
*ngIf="powerButtonState === 'turn_on_off'"
>settings_power</i
>
<div
class="small-spinner"
[class.power-off]="powerButtonState === 'turn_off_busy'"
[class.power-on]="powerButtonState === 'turn_on_busy'"
*ngIf="powerButtonState === 'turn_off_busy' || powerButtonState === 'turn_on_busy'"
[class.power-unknown]="powerButtonState === 'turn_on_off_busy'"
*ngIf="powerButtonState === 'turn_off_busy' || powerButtonState === 'turn_on_busy' || powerButtonState === 'turn_on_off_busy'"
></div>
</button>
<div @fade (clickOutside)="onClickOutsideLHStatePopover($event)"
*ngIf="showLHStatePopover">
<app-device-list-lh-state-popover
(action)="onForceLHState($event)"
[style.position-anchor]="powerButtonAnchorId">
</app-device-list-lh-state-popover>
</div>
</div>
</div>
<div class="status-info" @vshrink *ngIf="status && !isDeviceIgnored()">
<div class="status-info" @vshrink *ngIf="status && !isDeviceIgnored">
<span *ngFor="let s of status ? [status] : []" [@vshrink]>{{ s | translate }}</span></div
>
<div class="battery-info" @vshrink *ngIf="showBattery && !isDeviceIgnored()">
<div class="battery-info" @vshrink *ngIf="showBattery && !isDeviceIgnored">
<div class="battery-info-bar">
<div
class="battery-info-bar-fill"
Expand All @@ -64,3 +81,4 @@
</div>
</div>
</ng-container>

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
&.power-off {
--spinner-color: var(--color-alert-error);
}

&.power-unknown {
--spinner-color: var(--color-text-1);
}
}

.category-icon {
Expand All @@ -129,3 +133,4 @@
.device-ignored {
opacity: 0.6;
}

Loading

0 comments on commit 8482dc0

Please sign in to comment.