Skip to content

Commit

Permalink
Add humidifier support. Fix #140
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Oct 30, 2021
1 parent c714b1e commit 491460e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/controllers/get-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { InputNumberController } from "./input-number-controller";
import { InputSelectController } from "./input-select-controller";
import { NumberController } from "./number-controller";
import { WaterHeaterController } from "./water-heater-controller";
import { HumidifierController } from "./humidifier-controller";

export function getController(domain: string) {
return {
Expand All @@ -19,5 +20,6 @@ export function getController(domain: string) {
input_number: InputNumberController,
input_select: InputSelectController,
number: NumberController,
humidifier: HumidifierController,
}[domain];
}
32 changes: 32 additions & 0 deletions src/controllers/humidifier-controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Controller } from "./controller";

export class HumidifierController extends Controller {
get _value() {
return this.stateObj.attributes.humidity;
}

set _value(value) {
this._hass.callService("humidifier", "set_humidity", {
entity_id: this.stateObj.entity_id,
humidity: value,
});
}

get string() {
return `${this.value} %`;
}

get isOff() {
return this.stateObj.state === "off";
}

get _min() {
return this.stateObj.attributes.min_humidity;
}
get _max() {
return this.stateObj.attributes.max_humidity;
}
get _step() {
return 1;
}
}
3 changes: 3 additions & 0 deletions test/views/1_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ cards:
- type: custom:slider-entity-row
entity: water_heater.demo_water_heater
name: water_heater
- type: custom:slider-entity-row
entity: humidifier.hygrostat
name: humidifier

0 comments on commit 491460e

Please sign in to comment.