Skip to content

Commit

Permalink
Merge pull request #2 from balloob/media-player-volume
Browse files Browse the repository at this point in the history
Fixes for Chromecast volume
  • Loading branch information
hansmbakker committed May 31, 2015
2 parents c445563 + ed46a93 commit 5c48c87
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 119 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" DO NOT MODIFY. Auto-generated by build_frontend script """
VERSION = "7317977bfe0a61d1b1c79ed332defb7e"
VERSION = "3c6a5149feced6c49cb97b76fdf14fee"
143 changes: 64 additions & 79 deletions homeassistant/components/frontend/www_static/frontend.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
transition: max-height .5s ease-in;
}

.brightness paper-slider::shadow #sliderKnobInner,
.brightness paper-slider::shadow #sliderBar::shadow #activeProgress {
background-color: #039be5;
}

color-picker {
display: block;
width: 350px;
Expand All @@ -29,7 +24,7 @@
}

.has-brightness .brightness {
max-height: 500px;
max-height: 40px;
}

.has-xy_color color-picker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
text-transform: capitalize;
}

paper-button, paper-icon-button {
paper-icon-button {
color: var(--accent-color);
}

Expand All @@ -20,24 +20,12 @@
transition: max-height .5s ease-in;
}

.volume paper-slider::shadow #sliderKnobInner,
.volume paper-slider::shadow #sliderBar::shadow #activeProgress {
background-color: var(--accent-color);
}

.has-volume .volume {
max-height: 500px;
.has-media_volume .volume {
max-height: 40px;
}
</style>
<template>
<div class$='[[computeClassNames(stateObj)]]'>
<div class='volume center horizontal layout'>
<div>Volume</div>
<paper-slider
max='100' id='volume' value='{{volumeSliderValue}}'
on-change='volumeSliderChanged' class='flex'>
</paper-slider>
</div>
<div class='layout horizontal'>
<div class='flex'>
<paper-icon-button icon='power-settings-new'
Expand All @@ -54,6 +42,13 @@
</template>
</div>
</div>
<div class='volume center horizontal layout'>
<div>Volume</div>
<paper-slider
min='0' max='100' value='{{volumeSliderValue}}'
on-change='volumeSliderChanged' class='flex'>
</paper-slider>
</div>
</div>
</template>
</dom-module>
Expand All @@ -62,7 +57,7 @@
(function() {
var serviceActions = window.hass.serviceActions;
var uiUtil = window.hass.uiUtil;
var ATTRIBUTE_CLASSES = ['volume'];
var ATTRIBUTE_CLASSES = ['media_volume'];

Polymer({
is: 'more-info-media_player',
Expand All @@ -86,12 +81,12 @@

stateObjChanged: function(newVal, oldVal) {
if (newVal) {
this.volumeSliderValue = newVal.attributes.volume;
this.volumeSliderValue = newVal.attributes.media_volume * 100;
}

//this.debounce('more-info-volume-animation-finish', function() {
// this.fire('iron-resize');
//}.bind(this), 500);
this.debounce('more-info-volume-animation-finish', function() {
this.fire('iron-resize');
}.bind(this), 500);
},

computeClassNames: function(stateObj) {
Expand Down Expand Up @@ -131,21 +126,15 @@
},

volumeSliderChanged: function(ev) {
var volPercentage = parseInt(ev.target.value);

if(isNaN(volPercentage)) return;

var vol = volPercentage / 100;

serviceActions.callService('media_player', 'volume_set', {
entity_id: this.stateObj.entityId,
volume: vol
});
var volPercentage = parseFloat(ev.target.value);
var vol = volPercentage > 0 ? volPercentage / 100 : 0;

this.callService('volume_set', {volume: vol});
},

callService: function(service) {
var data = {entity_id: this.stateObj.entityId};
callService: function(service, data) {
data = data || {};
data.entity_id = this.stateObj.entityId;
serviceActions.callService('media_player', service, data);
},
});
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/media_player/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def state_attributes(self):
}

if cast_status:
state_attr[ATTR_MEDIA_VOLUME] = cast_status.volume_level,
state_attr[ATTR_MEDIA_VOLUME] = cast_status.volume_level

if media_status.content_id:
state_attr[ATTR_MEDIA_CONTENT_ID] = media_status.content_id
Expand Down

0 comments on commit 5c48c87

Please sign in to comment.