Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add select domain support #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ entities:
- `cover` - set position
- `fan` - set speed (assumes first setting is `off`)
- `input_number` - set value (only if `mode: slider`)
- `input_select` - select option
- `select`, `input_select` - select option
- `number` - set value
- `timer` - set number of seconds remaining

Expand Down
4 changes: 3 additions & 1 deletion src/controllers/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export abstract class Controller {
_config: ControllerConfig;
_hass: any;
stateObj: any;
_domain: string;

abstract _value?: number;
abstract _min?: number;
Expand All @@ -28,8 +29,9 @@ export abstract class Controller {

static allowed_attributes = [];

constructor(config: ControllerConfig, parent) {
constructor(config: ControllerConfig, parent: any, domain: string) {
this._config = config;
this._domain = domain;
}

set hass(hass: any) {
Expand Down
1 change: 1 addition & 0 deletions src/controllers/get-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const controllers = {
cover: CoverController,
fan: FanController,
input_number: InputNumberController,
select: InputSelectController,
input_select: InputSelectController,
number: NumberController,
humidifier: HumidifierController,
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/input-select-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class InputSelectController extends Controller {

set _value(value) {
if (value in this.stateObj.attributes.options)
this._hass.callService("input_select", "select_option", {
this._hass.callService(this._domain, "select_option", {
entity_id: this.stateObj.entity_id,
option: this.stateObj.attributes.options[value],
});
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SliderEntityRow extends LitElement {
const domain = config.entity.split(".")[0];
const ctrlClass = getController(domain);
if (!ctrlClass) throw new Error(`Unsupported entity type: ${domain}`);
this.ctrl = new ctrlClass(config, this);
this.ctrl = new ctrlClass(config, this, domain);
}

static getConfigElement() {
Expand Down