Skip to content

Commit

Permalink
allow fan/fanv2 rotation speed to be a different unit than percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Dec 27, 2023
1 parent 89e94e1 commit f35071d
Show file tree
Hide file tree
Showing 53 changed files with 91 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All notable changes to homebridge-config-ui-x will be documented in this file.
- added credits link in status footer and modal for credits
- added more `aria-label` attributes to buttons to improve accessibility
- add link to homebridge wiki in logs on plugin action error
- allow fan/fanv2 rotation speed to be a different unit than percentage

### Translation Changes

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/accessories/accessories.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { ValveComponent } from '@/app/core/accessories/types/valve/valve.compone
import { ValveManageComponent } from '@/app/core/accessories/types/valve/valve.manage.component';
import { WindowComponent } from '@/app/core/accessories/types/window/window.component';
import { WindowManageComponent } from '@/app/core/accessories/types/window/window.manage.component';
import { WindowcoveringComponent } from '@/app/core/accessories/types/windowcovering/windowcovering.component';
import { WindowCoveringComponent } from '@/app/core/accessories/types/windowcovering/windowcovering.component';
import { WindowcoveringManageComponent } from '@/app/core/accessories/types/windowcovering/windowcovering.manage.component';
import { CoreModule } from '@/app/core/core.module';

Expand Down Expand Up @@ -79,7 +79,7 @@ import { CoreModule } from '@/app/core/core.module';
OccupancysensorComponent,
HumiditysensorComponent,
AirqualitysensorComponent,
WindowcoveringComponent,
WindowCoveringComponent,
WindowcoveringManageComponent,
WindowComponent,
WindowManageComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { AirpurifierManageComponent } from '@/app/core/accessories/types/airpurifier/airpurifier.manage.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-airpurifier-manage',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-airqualitysensor',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-batteryservice',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-contactsensor',
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/accessories/types/door/door.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { DoorManageComponent } from '@/app/core/accessories/types/door/door.manage.component';

@Component({
Expand All @@ -27,7 +27,7 @@ export class DoorComponent implements OnInit {

onLongClick() {
const ref = this.modalService.open(DoorManageComponent, {
size: 'sm',
size: 'md',
});
ref.componentInstance.service = this.service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h5 class="modal-title" [innerText]="service.customName || service.serviceName">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-center">
<div class="modal-body text-center px-5">

<h5>
<strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-door-manage',
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/accessories/types/fan/fan.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
[innerText]="(service.values.On ? 'accessories.control.label_on' : 'accessories.control.label_off') | translate">
</div>
<div class="accessory-label grey-text" *ngIf="service.values.RotationSpeed && service.values.On">
{{ service.values.RotationSpeed }}%</div>
{{ service.values.RotationSpeed }}{{ rotationSpeedUnit }}</div>
</div>
</div>
</div>
18 changes: 13 additions & 5 deletions ui/src/app/core/accessories/types/fan/fan.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { FanManageComponent } from '@/app/core/accessories/types/fan/fan.manage.component';

@Component({
Expand All @@ -10,25 +10,33 @@ import { FanManageComponent } from '@/app/core/accessories/types/fan/fan.manage.
})
export class FanComponent implements OnInit {
@Input() public service: ServiceTypeX;
public rotationSpeedUnit = '';

constructor(
private modalService: NgbModal,
) {}

ngOnInit() {}
ngOnInit() {
// Find the unit for the rotation speed
const RotationSpeed = this.service.serviceCharacteristics.find((c) => c.type === 'RotationSpeed');
if (RotationSpeed && RotationSpeed.unit === 'percentage') {
this.rotationSpeedUnit = '%';
}
}

onClick() {
this.service.getCharacteristic('On').setValue(!this.service.values.On);

// set the brightness to 100% if on 0% when turned on
// set the rotation speed to max if on 0% when turned on
if (!this.service.values.On && 'RotationSpeed' in this.service.values && !this.service.values.RotationSpeed) {
this.service.getCharacteristic('RotationSpeed').setValue(100);
const RotationSpeed = this.service.getCharacteristic('RotationSpeed');
RotationSpeed.setValue(RotationSpeed.maxValue);
}
}

onLongClick() {
const ref = this.modalService.open(FanManageComponent, {
size: 'sm',
size: 'md',
});
ref.componentInstance.service = this.service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h5 class="modal-title" [innerText]="service.customName || service.serviceName">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-center">
<div class="modal-body text-center px-5">

<h5>
<strong>
Expand All @@ -27,7 +27,7 @@ <h5>

<div *ngIf="targetRotationSpeed">
<h5 class="mb-0">{{ 'accessories.control.label_rotation_speed' | translate }}</h5>
<p>{{ targetRotationSpeed.value }}%</p>
<p>{{ targetRotationSpeed.value }}<span *ngIf="targetRotationSpeed.unit === 'percentage'">%</span></p>
<nouislider [min]="targetRotationSpeed.min" [max]="targetRotationSpeed.max" [step]="targetRotationSpeed.step"
[(ngModel)]="targetRotationSpeed.value" (ngModelChange)="onTargetRotationSpeedChange()">
</nouislider>
Expand Down
7 changes: 4 additions & 3 deletions ui/src/app/core/accessories/types/fan/fan.manage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-fan-manage',
Expand Down Expand Up @@ -53,16 +53,17 @@ export class FanManageComponent implements OnInit {
min: RotationSpeed.minValue,
max: RotationSpeed.maxValue,
step: RotationSpeed.minStep,
unit: RotationSpeed.unit,
};
}
}

onTargetStateChange() {
this.service.getCharacteristic('On').setValue(this.targetMode);

// set the brightness to 100% if on 0% when turned on
// set the rotation speed to max if on 0% when turned on
if (this.targetMode && this.targetRotationSpeed && !this.targetRotationSpeed.value) {
this.targetRotationSpeed.value = 100;
this.targetRotationSpeed.value = this.service.getCharacteristic('RotationSpeed').maxValue;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/accessories/types/fanv2/fanv2.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
[innerText]="(service.values.Active ? 'accessories.control.label_on' : 'accessories.control.label_off') | translate">
</div>
<div class="accessory-label grey-text" *ngIf="service.values.RotationSpeed && service.values.Active">
{{ service.values.RotationSpeed }}%</div>
{{ service.values.RotationSpeed }}{{ rotationSpeedUnit }}</div>
</div>
</div>
</div>
18 changes: 13 additions & 5 deletions ui/src/app/core/accessories/types/fanv2/fanv2.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { Fanv2ManageComponent } from '@/app/core/accessories/types/fanv2/fanv2.manage.component';

@Component({
Expand All @@ -10,25 +10,33 @@ import { Fanv2ManageComponent } from '@/app/core/accessories/types/fanv2/fanv2.m
})
export class Fanv2Component implements OnInit {
@Input() public service: ServiceTypeX;
public rotationSpeedUnit = '';

constructor(
private modalService: NgbModal,
) {}

ngOnInit() {}
ngOnInit() {
// Find the unit for the rotation speed
const RotationSpeed = this.service.serviceCharacteristics.find((c) => c.type === 'RotationSpeed');
if (RotationSpeed && RotationSpeed.unit === 'percentage') {
this.rotationSpeedUnit = '%';
}
}

onClick() {
this.service.getCharacteristic('Active').setValue(this.service.values.Active ? 0 : 1);

// set the brightness to 100% if on 0% when turned on
// set the rotation speed to max if on 0% when turned on
if (!this.service.values.On && 'RotationSpeed' in this.service.values && !this.service.values.RotationSpeed) {
this.service.getCharacteristic('RotationSpeed').setValue(100);
const RotationSpeed = this.service.getCharacteristic('RotationSpeed');
RotationSpeed.setValue(RotationSpeed.maxValue);
}
}

onLongClick() {
const ref = this.modalService.open(Fanv2ManageComponent, {
size: 'sm',
size: 'md',
});
ref.componentInstance.service = this.service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h5 class="modal-title" [innerText]="service.customName || service.serviceName">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-center">
<div class="modal-body text-center px-5">

<h5>
<strong>
Expand All @@ -27,7 +27,7 @@ <h5>

<div *ngIf="targetRotationSpeed">
<h5 class="mb-0">{{ 'accessories.control.label_rotation_speed' | translate }}</h5>
<p>{{ targetRotationSpeed.value }}%</p>
<p>{{ targetRotationSpeed.value }}<span *ngIf="targetRotationSpeed.unit === 'percentage'">%</span></p>
<nouislider [min]="targetRotationSpeed.min" [max]="targetRotationSpeed.max" [step]="targetRotationSpeed.step"
[(ngModel)]="targetRotationSpeed.value" (ngModelChange)="onTargetRotationSpeedChange()">
</nouislider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-fanv2-manage',
Expand Down Expand Up @@ -53,16 +53,17 @@ export class Fanv2ManageComponent implements OnInit {
min: RotationSpeed.minValue,
max: RotationSpeed.maxValue,
step: RotationSpeed.minStep,
unit: RotationSpeed.unit,
};
}
}

onTargetStateChange() {
this.service.getCharacteristic('Active').setValue(this.targetMode);

// set the brightness to 100% if on 0% when turned on
// set the rotation speed to max if on 0% when turned on
if (this.targetMode && this.targetRotationSpeed && !this.targetRotationSpeed.value) {
this.targetRotationSpeed.value = 100;
this.targetRotationSpeed.value = this.service.getCharacteristic('RotationSpeed').maxValue;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-garagedooropener',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { HeaterCoolerManageComponent } from '@/app/core/accessories/types/heatercooler/heatercooler.manage.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-heatercooler-manage',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { HumidifierDehumidifierManageComponent } from '@/app/core/accessories/types/humidifierdehumidifier/humidifierdehumidifier.manage.component'; // eslint-disable-line max-len

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-humidifierdehumidifier-manage',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-humiditysensor',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-irrigationsystem',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-leaksensor',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';
import { LightbulbManageComponent } from '@/app/core/accessories/types//lightbulb/lightbulb.manage.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-lightbulb-manage',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-lightsensor',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { ServiceTypeX } from '../../accessories.interfaces';
import { ServiceTypeX } from '@/app/core/accessories/accessories.interfaces';

@Component({
selector: 'app-lockmechanism',
Expand Down
Loading

0 comments on commit f35071d

Please sign in to comment.