Skip to content

Commit

Permalink
Allows for two speed fans by hiding middle button
Browse files Browse the repository at this point in the history
  • Loading branch information
finity69x2 authored Apr 20, 2021
1 parent a6a30e4 commit 0fa7846
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions dist/fan-percent-button-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class CustomFanPercentRow extends Polymer.Element {
disabled='[[_leftState]]'>[[_leftText]]</button>
<button
class='percentage'
style='[[_midLeftColor]];min-width:[[_width]];max-width:[[_width]];height:[[_height]]'
style='[[_midLeftColor]];min-width:[[_width]];max-width:[[_width]];height:[[_height]];[[_hideMidLeft]]'
toggles name="[[_midLeftName]]"
on-click='setPercentage'
disabled='[[_midLeftState]]'>[[_midLeftText]]</button>
<button
class='percentage'
style='[[_midRightColor]];min-width:[[_width]];max-width:[[_width]];height:[[_height]]'
style='[[_midRightColor]];min-width:[[_width]];max-width:[[_width]];height:[[_height]];[[_hideMidRight]]'
toggles name="[[_midRightName]]"
on-click='setPercentage'
disabled='[[_midRightState]]'>[[_midRightText]]</button>
Expand Down Expand Up @@ -79,6 +79,8 @@ class CustomFanPercentRow extends Polymer.Element {
_midLeftName: String,
_midRightName: String,
_rightName: String,
_hideMidLeft: String,
_hideMidRight: String,
_leftState: Boolean,
_midLeftState: Boolean,
_midRightState: Boolean,
Expand All @@ -94,6 +96,7 @@ class CustomFanPercentRow extends Polymer.Element {
customTheme: false,
customSetpoints: false,
reverseButtons: false,
isTwoSpeedFan: false,
offPercentage: 0,
lowPercentage: 33,
medPercentage: 66,
Expand All @@ -120,6 +123,7 @@ class CustomFanPercentRow extends Polymer.Element {
const custTheme = config.customTheme;
const custSetpoint = config.customSetpoints;
const revButtons = config.reverseButtons;
const twoSpdFan = config.isTwoSpeedFan;
const buttonWidth = config.width;
const buttonHeight = config.height;
const OnLowClr = config.isOnLowColor;
Expand Down Expand Up @@ -148,8 +152,8 @@ class CustomFanPercentRow extends Polymer.Element {
if (custSetpoint) {
offSetpoint = parseInt(OffSetpoint);
medSetpoint = parseInt(MedSetpoint);
if (parseInt(LowSetpoint) < 10) {
lowSetpoint = 10;
if (parseInt(LowSetpoint) < 1) {
lowSetpoint = 1;
} else {
lowSetpoint = parseInt(LowSetpoint);
}
Expand Down Expand Up @@ -250,6 +254,15 @@ class CustomFanPercentRow extends Polymer.Element {
let medname = 'medium'
let hiname = 'high'

let hidemedium = 'display:block';
let nohide = 'display:block';

if (twoSpdFan) {
hidemedium = 'display:none';
} else {
hidemedium = 'display:block';
}

if (revButtons) {
this.setProperties({
_stateObj: stateObj,
Expand All @@ -275,7 +288,8 @@ class CustomFanPercentRow extends Polymer.Element {
_midLeftName: lowname,
_midRightName: medname,
_rightName: hiname,

_hideMidLeft: nohide,
_hideMidRight: hidemedium,
});
} else {
this.setProperties({
Expand All @@ -302,10 +316,10 @@ class CustomFanPercentRow extends Polymer.Element {
_midLeftName: medname,
_midRightName: lowname,
_rightName: offname,
_hideMidRight: nohide,
_hideMidLeft: hidemedium,
});
}


}

stopPropagation(e) {
Expand Down Expand Up @@ -333,3 +347,4 @@ class CustomFanPercentRow extends Polymer.Element {
}

customElements.define('fan-percent-button-row', CustomFanPercentRow);

0 comments on commit 0fa7846

Please sign in to comment.