Fixes for Chromecast volume

It was line 119 from cast.py that was driving me crazy
This commit is contained in:
Paulus Schoutsen 2015-05-31 11:37:10 -07:00
parent c445563ab1
commit ed46a93848
5 changed files with 88 additions and 119 deletions

View File

@ -1,2 +1,2 @@
""" DO NOT MODIFY. Auto-generated by build_frontend script """
VERSION = "7317977bfe0a61d1b1c79ed332defb7e"
VERSION = "3c6a5149feced6c49cb97b76fdf14fee"

File diff suppressed because one or more lines are too long

View File

@ -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;
@ -29,7 +24,7 @@
}
.has-brightness .brightness {
max-height: 500px;
max-height: 40px;
}
.has-xy_color color-picker {

View File

@ -8,7 +8,7 @@
text-transform: capitalize;
}
paper-button, paper-icon-button {
paper-icon-button {
color: var(--accent-color);
}
@ -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'
@ -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>
@ -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',
@ -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) {
@ -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);
},
});

View File

@ -116,7 +116,7 @@ class CastDevice(MediaPlayerDevice):
}
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