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

fix config.supports to match listentities object #18

Open
wants to merge 1 commit into
base: main
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
16 changes: 8 additions & 8 deletions lib/entities/Climate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Base = require('./Base')

// bool supports_current_temperature = 5;
// bool supports_two_point_target_temperature = 6;
// bool supportsCurrentTemperature = 5;
// bool supportsTwoPointTargetTemperature = 6;
// repeated ClimateMode supported_modes = 7;
// float visual_min_temperature = 8;
// float visual_max_temperature = 9;
// float visual_temperature_step = 10;
// bool supports_away = 11;
// bool supports_action = 12;
// bool supportsAway = 11;
// bool supportsAction = 12;
// repeated ClimateFanMode supported_fan_modes = 13;
// repeated ClimateSwingMode supported_swing_modes = 14;
class Climate extends Base {
Expand Down Expand Up @@ -37,11 +37,11 @@ class Climate extends Base {
this.command({ targetTemperature });
}
setTargetTemperatureLow(targetTemperatureLow) {
if (!this.config.supports_two_point_target_temperature) throw new Error('two_point_target_temperature are not supported');
if (!this.config.supportsTwoPointTargetTemperature) throw new Error('two_point_target_temperature are not supported');
this.command({ targetTemperatureLow });
}
setTargetTemperatureHign(targetTemperatureHign) {
if (!this.config.supports_two_point_target_temperature) throw new Error('two_point_target_temperature are not supported');
if (!this.config.supportsTwoPointTargetTemperature) throw new Error('two_point_target_temperature are not supported');
this.command({ targetTemperatureHign });
}
setMode(mode) {
Expand All @@ -50,11 +50,11 @@ class Climate extends Base {
this.command({ mode });
}
setAway(away) {
if (!this.config.supports_away) throw new Error('away is not supported');
if (!this.config.supportsAway) throw new Error('away is not supported');
this.command({ away });
}
setAction(action) {
if (!this.config.supports_action) throw new Error('action is not supported');
if (!this.config.supportsAction) throw new Error('action is not supported');
this.command({ action });
}
setMode(mode) {
Expand Down
8 changes: 4 additions & 4 deletions lib/entities/Cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const Base = require('./Base')


// bool assumed_state = 5;
// bool supports_position = 6;
// bool supports_tilt = 7;
// bool supportsPosition = 6;
// bool supportsTilt = 7;
// string device_class = 8;
class Cover extends Base {
constructor(data) {
Expand All @@ -27,11 +27,11 @@ class Cover extends Base {
this.command({ legacyCommand });
}
setPosition(position) {
if (!this.config.supports_position) throw new Error('brightness is not supported');
if (!this.config.supportsPosition) throw new Error('brightness is not supported');
this.command({ position });
}
setTilt(tilt) {
if (!this.config.supports_tilt) throw new Error('tilt is not supported');
if (!this.config.supportsTilt) throw new Error('tilt is not supported');
this.command({ tilt });
}
setStop(stop) {
Expand Down
8 changes: 4 additions & 4 deletions lib/entities/Fan.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Base = require('./Base')

// bool supports_oscillation = 5;
// bool supports_speed = 6;
// bool supportsOscillation = 5;
// bool supportsSpeed = 6;
class Fan extends Base {
constructor(data) {
super(data);
Expand All @@ -21,11 +21,11 @@ class Fan extends Base {
this.command({ state });
}
setOscillation(oscillation) {
if (!this.config.supports_oscillation) throw new Error('brightness is not supported');
if (!this.config.supportsOscillation) throw new Error('brightness is not supported');
this.command({ oscillation });
}
setSpeed(speed) {
if (!this.config.supports_speed) throw new Error('brightness is not supported');
if (!this.config.supportsSpeed) throw new Error('brightness is not supported');
this.command({ speed });
}
}
Expand Down
24 changes: 12 additions & 12 deletions lib/entities/Light.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { LightCommandRequest } = require('../protoc/api_pb');
const Base = require('./Base');

// bool supports_brightness = 5;
// bool supports_rgb = 6;
// bool supports_white_value = 7;
// bool supports_color_temperature = 8;
// bool supportsBrightness = 5;
// bool supportsRgb = 6;
// bool supportsWhiteValue = 7;
// bool supportsColorTemperature = 8;
// float min_mireds = 9;
// float max_mireds = 10;
// repeated string effects = 11;
Expand All @@ -25,10 +25,10 @@ class Light extends Base {
// handleState(state) {
// super.handleState(state);
// this.emit('state.state', this.state.state);
// if (this.config.supports_brightness) this.emit('state.brightness', this.state.brightness);
// if (this.config.supports_rgb) this.emit('state.rgb', this.state.red, this.state.green, this.state.blue);
// if (this.config.supports_white_value) this.emit('state.white', this.state.white);
// if (this.config.supports_color_temperature) this.emit('state.colorTemperature', this.state.white);
// if (this.config.supportsBrightness) this.emit('state.brightness', this.state.brightness);
// if (this.config.supportsRgb) this.emit('state.rgb', this.state.red, this.state.green, this.state.blue);
// if (this.config.supportsWhiteValue) this.emit('state.white', this.state.white);
// if (this.config.supportsColorTemperature) this.emit('state.colorTemperature', this.state.white);
// }
// fixed32 key = 1;
// bool has_state = 2;
Expand Down Expand Up @@ -57,19 +57,19 @@ class Light extends Base {
this.command({ state });
}
setBrightness(brightness) {
if (!this.config.supports_brightness) throw new Error('brightness is not supported');
if (!this.config.supportsBrightness) throw new Error('brightness is not supported');
this.command({ brightness });
}
setRgb(red, green, blue) {
if (!this.config.supports_rgb) throw new Error('rgb is not supported');
if (!this.config.supportsRgb) throw new Error('rgb is not supported');
this.command({ red, green, blue });
}
setWhite(white) {
if (!this.config.supports_white_value) throw new Error('white_value is not supported');
if (!this.config.supportsWhiteValue) throw new Error('white_value is not supported');
this.command({ white });
}
setColorTemperature(colorTemperature) {
if (!this.config.supports_color_temperature) throw new Error('white_value is not supported');
if (!this.config.supportsColorTemperature) throw new Error('white_value is not supported');
this.command({ colorTemperature });
}
setTransitionLength(transitionLength) {
Expand Down