Skip to content
Closed
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
65 changes: 65 additions & 0 deletions src/more-infos/more-info-fan.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@

<div class$='[[computeClassNames(stateObj)]]'>

<div class='container-night-mode'
hidden$='[[computeHideAutoMode(stateObj)]]'>
<div class='center horizontal layout single-row'>
<div class='flex'>Auto Mode</div>
<paper-toggle-button
checked='[[autoModeToggleChecked]]'
on-change='autoModeToggleChanged'>
</paper-toggle-button>
</div>
</div>

<div class='container-night-mode'
hidden$='[[computeHideNightMode(stateObj)]]'>
<div class='center horizontal layout single-row'>
<div class='flex'>Night Mode</div>
<paper-toggle-button
checked='[[nightModeToggleChecked]]'
on-change='nightModeToggleChanged'>
</paper-toggle-button>
</div>
</div>

<div class="container-speed_list">
<paper-dropdown-menu label-float label='Speed'>
<paper-menu class='dropdown-content' selected='{{speedIndex}}'>
Expand Down Expand Up @@ -83,10 +105,20 @@
oscillationToggleChecked: {
type: Boolean,
},

nightModeToggleChecked: {
type: Boolean,
},

autoModeToggleChecked: {
type: Boolean,
},
},

stateObjChanged: function (newVal, oldVal) {
this.oscillationToggleChecked = newVal.attributes.oscillating;
this.nightModeToggleChecked = newVal.attributes.night_mode;
this.autoModeToggleChecked = newVal.attributes.auto_mode;

if (newVal.attributes.speed_list) {
this.speedIndex = newVal.attributes.speed_list.indexOf(
Expand Down Expand Up @@ -134,6 +166,30 @@
});
},

nightModeToggleChanged: function (ev) {
var oldVal = this.stateObj.attributes.night_mode;
var newVal = ev.target.checked;

if (oldVal === newVal) return;

this.hass.callService('fan', 'set_night_mode', {
entity_id: this.stateObj.entity_id,
night_mode: newVal,
});
},

autoModeToggleChanged: function (ev) {
var oldVal = this.stateObj.attributes.auto_mode;
var newVal = ev.target.checked;

if (oldVal === newVal) return;

this.hass.callService('fan', 'set_auto_mode', {
entity_id: this.stateObj.entity_id,
auto_mode: newVal,
});
},

onDirectionLeft: function () {
this.hass.callService('fan', 'set_direction', {
entity_id: this.stateObj.entity_id,
Expand All @@ -160,5 +216,14 @@
return stateObj.attributes.direction;
},

computeHideNightMode: function (stateObj) {
return (stateObj.attributes.supported_features & 8) === 0;
},

computeHideAutoMode: function (stateObj) {
return (stateObj.attributes.supported_features & 16) === 0;
},

});
</script>