Skip to content

Commit

Permalink
Remove not needed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
aivus committed Sep 19, 2024
1 parent 719c516 commit 3f11737
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,113 +11,120 @@ class GreeHVAC extends Homey.App {
this.log('Gree HVAC app is up and running...');

// Register conditions for flows
this._conditionHVACModeIs = this.homey.flow.getConditionCard('hvac_mode_is')
this.homey.flow.getConditionCard('hvac_mode_is')
.registerRunListener((args, state) => {
const hvacMode = args.device.getCapabilityValue('thermostat_mode');
args.device.log('[condition]', '[current hvac mode]', hvacMode);
return args.mode === hvacMode;
});

this._conditionFanSpeedIs = this.homey.flow.getConditionCard('fan_speed_is')
this.homey.flow.getConditionCard('thermostat_mode_is')
.registerRunListener((args, state) => {
const hvacMode = args.device.getCapabilityValue('thermostat_mode');
args.device.log('[condition]', '[current thermostat mode]', hvacMode);
return args.thermostat_mode === hvacMode;
});

this.homey.flow.getConditionCard('fan_speed_is')
.registerRunListener((args, state) => {
const fanSpeed = args.device.getCapabilityValue('fan_speed');
args.device.log('[condition]', '[current fan speed]', fanSpeed);
return args.speed === fanSpeed;
});

this._conditionTurboModeIs = this.homey.flow.getConditionCard('turbo_mode_is')
this.homey.flow.getConditionCard('turbo_mode_is')
.registerRunListener((args, state) => {
const turboMode = args.device.getCapabilityValue('turbo_mode');
args.device.log('[condition]', '[current turbo mode]', turboMode);
return onoffToBoolean(args.mode) === turboMode;
});

this._conditionLightsIs = this.homey.flow.getConditionCard('lights_is')
this.homey.flow.getConditionCard('lights_is')
.registerRunListener((args, state) => {
const lightsMode = args.device.getCapabilityValue('lights');
args.device.log('[condition]', '[current lights]', lightsMode);
return onoffToBoolean(args.mode) === lightsMode;
});

this._conditionXFanModeIs = this.homey.flow.getConditionCard('xfan_mode_is')
this.homey.flow.getConditionCard('xfan_mode_is')
.registerRunListener((args, state) => {
const xfanMode = args.device.getCapabilityValue('xfan_mode');
args.device.log('[condition]', '[current xfan mode]', xfanMode);
return onoffToBoolean(args.mode) === xfanMode;
});

this._conditionVerticalSwingIs = this.homey.flow.getConditionCard('vertical_swing_is')
this.homey.flow.getConditionCard('vertical_swing_is')
.registerRunListener((args, state) => {
const verticalSwing = args.device.getCapabilityValue('vertical_swing');
args.device.log('[condition]', '[current swing vertical]', verticalSwing);
return args.vertical_swing === verticalSwing;
});

this._conditionHorizontalSwingIs = this.homey.flow.getConditionCard('horizontal_swing_is')
this.homey.flow.getConditionCard('horizontal_swing_is')
.registerRunListener((args, state) => {
const horizontalSwing = args.device.getCapabilityValue('horizontal_swing');
args.device.log('[condition]', '[current swing horizontal]', horizontalSwing);
return args.horizontal_swing === horizontalSwing;
});

this._conditionQuietModeIs = this.homey.flow.getConditionCard('quiet_mode_is')
this.homey.flow.getConditionCard('quiet_mode_is')
.registerRunListener((args, state) => {
const quietMode = args.device.getCapabilityValue('quiet_mode_is');
args.device.log('[condition]', '[quiet mode]', quietMode);
return args.mode === quietMode;
});

// Register actions for flows
this._actionChangeHVACMode = this.homey.flow.getActionCard('set_hvac_mode')
this.homey.flow.getActionCard('set_hvac_mode')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('thermostat_mode', args.mode).then(() => {
return args.device.triggerCapabilityListener('thermostat_mode', args.mode, {});
});
});

this._actionChangeFanSpeed = this.homey.flow.getActionCard('set_fan_speed')
this.homey.flow.getActionCard('set_fan_speed')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('fan_speed', args.speed).then(() => {
return args.device.triggerCapabilityListener('fan_speed', args.speed, {});
});
});

this._actionChangeTurboMode = this.homey.flow.getActionCard('set_turbo_mode')
this.homey.flow.getActionCard('set_turbo_mode')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('turbo_mode', onoffToBoolean(args.mode)).then(() => {
return args.device.triggerCapabilityListener('turbo_mode', onoffToBoolean(args.mode), {});
});
});

this._actionChangeLights = this.homey.flow.getActionCard('set_lights')
this.homey.flow.getActionCard('set_lights')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('lights', onoffToBoolean(args.mode)).then(() => {
return args.device.triggerCapabilityListener('lights', onoffToBoolean(args.mode), {});
});
});

this._actionChangeXFanMode = this.homey.flow.getActionCard('set_xfan_mode')
this.homey.flow.getActionCard('set_xfan_mode')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('xfan_mode', onoffToBoolean(args.mode)).then(() => {
return args.device.triggerCapabilityListener('xfan_mode', onoffToBoolean(args.mode), {});
});
});

this._actionChangeVerticalSwing = this.homey.flow.getActionCard('set_vertical_swing')
this.homey.flow.getActionCard('set_vertical_swing')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('vertical_swing', args.vertical_swing).then(() => {
return args.device.triggerCapabilityListener('vertical_swing', args.vertical_swing, {});
});
});

this._actionChangeHorizontalSwing = this.homey.flow.getActionCard('set_horizontal_swing')
this.homey.flow.getActionCard('set_horizontal_swing')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('horizontal_swing', args.horizontal_swing).then(() => {
return args.device.triggerCapabilityListener('horizontal_swing', args.horizontal_swing, {});
});
});

this._actionChangeQuietMode = this.homey.flow.getActionCard('set_quiet_mode')
this.homey.flow.getActionCard('set_quiet_mode')
.registerRunListener((args, state) => {
return args.device.setCapabilityValue('quiet_mode', args.mode).then(() => {
return args.device.triggerCapabilityListener('quiet_mode', args.mode, {});
Expand Down

0 comments on commit 3f11737

Please sign in to comment.