Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/components/ha-labeled-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class HaLabeledSlider extends PolymerElement {
}

.title {
margin-bottom: 16px;
color: var(--secondary-text-color);
margin-bottom: 8px;
color: var(--primary-text-color);
}

.slider-container {
Expand Down Expand Up @@ -43,7 +43,6 @@ class HaLabeledSlider extends PolymerElement {
step="[[step]]"
pin="[[pin]]"
disabled="[[disabled]]"
disabled="[[disabled]]"
value="{{value}}"
></ha-slider>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/components/ha-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HaSlider extends PaperSliderClass {
.pin > .slider-knob > .slider-knob-inner {
font-size: var(--ha-slider-pin-font-size, 10px);
line-height: normal;
cursor: pointer;
}

.disabled.ring > .slider-knob > .slider-knob-inner {
Expand Down Expand Up @@ -69,9 +70,9 @@ class HaSlider extends PaperSliderClass {
transform: scale(1) translate(0, -10px);
}

.slider-input {
width: 54px;
}
.slider-input {
width: 54px;
}
`)
);
}
Expand Down
38 changes: 21 additions & 17 deletions src/dialogs/more-info/controls/more-info-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ class MoreInfoLight extends LitElement {
caption=${this.hass.localize("ui.card.light.brightness")}
icon="hass:brightness-5"
min="1"
max="255"
max="100"
value=${this._brightnessSliderValue}
@change=${this._brightnessSliderChanged}
pin
></ha-labeled-slider>
`
: ""}
Expand All @@ -87,6 +88,7 @@ class MoreInfoLight extends LitElement {
.max=${this.stateObj.attributes.max_mireds}
.value=${this._ctSliderValue}
@change=${this._ctSliderChanged}
pin
></ha-labeled-slider>
`
: ""}
Expand All @@ -98,6 +100,7 @@ class MoreInfoLight extends LitElement {
max="255"
.value=${this._wvSliderValue}
@change=${this._wvSliderChanged}
pin
></ha-labeled-slider>
`
: ""}
Expand Down Expand Up @@ -155,16 +158,22 @@ class MoreInfoLight extends LitElement {

protected updated(changedProps: PropertyValues): void {
const stateObj = this.stateObj! as LightEntity;
if (changedProps.has("stateObj") && stateObj.state === "on") {
this._brightnessSliderValue = stateObj.attributes.brightness;
this._ctSliderValue = stateObj.attributes.color_temp;
this._wvSliderValue = stateObj.attributes.white_value;

if (stateObj.attributes.hs_color) {
this._colorPickerColor = {
h: stateObj.attributes.hs_color[0],
s: stateObj.attributes.hs_color[1] / 100,
};
if (changedProps.has("stateObj")) {
if (stateObj.state === "on") {
this._brightnessSliderValue = Math.round(
(stateObj.attributes.brightness * 100) / 255
);
this._ctSliderValue = stateObj.attributes.color_temp;
this._wvSliderValue = stateObj.attributes.white_value;

if (stateObj.attributes.hs_color) {
this._colorPickerColor = {
h: stateObj.attributes.hs_color[0],
s: stateObj.attributes.hs_color[1] / 100,
};
}
} else {
this._brightnessSliderValue = 0;
}
}
}
Expand All @@ -191,7 +200,7 @@ class MoreInfoLight extends LitElement {

this.hass.callService("light", "turn_on", {
entity_id: this.stateObj!.entity_id,
brightness: bri,
brightness_pct: bri,
});
}

Expand Down Expand Up @@ -250,15 +259,10 @@ class MoreInfoLight extends LitElement {
align-items: center;
}

.content.is-on {
margin-top: -16px;
}

.content > * {
width: 100%;
max-height: 84px;
overflow: hidden;
padding-top: 16px;
}

.color_temp {
Expand Down
5 changes: 3 additions & 2 deletions src/panels/lovelace/cards/hui-light-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
}

const brightness =
Math.round((stateObj.attributes.brightness / 254) * 100) || 0;
Math.round((stateObj.attributes.brightness / 255) * 100) || 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 1 now?

Suggested change
Math.round((stateObj.attributes.brightness / 255) * 100) || 0;
Math.round((stateObj.attributes.brightness / 255) * 100) || 1;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but I think no. If for some reason we get invalid brightness value so that the first part results in an NaN, then we should not switch on the light slightly dimmed at 1%, but it should stay at 0. Or am I missing something here?


return html`
<ha-card>
Expand All @@ -116,7 +116,8 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
<div id="controls">
<div id="slider">
<round-slider
min="0"
min="1"
max="100"
.value=${brightness}
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state)}
@value-changing=${this._dragEvent}
Expand Down
1 change: 1 addition & 0 deletions src/resources/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const derivedStyles = {
"paper-slider-knob-color": "var(--slider-color)",
"paper-slider-knob-start-color": "var(--slider-color)",
"paper-slider-pin-color": "var(--slider-color)",
"paper-slider-pin-start-color": "var(--slider-color)",
"paper-slider-active-color": "var(--slider-color)",
"paper-slider-secondary-color": "var(--slider-secondary-color)",
"paper-slider-container-color": "var(--slider-bar-color)",
Expand Down
2 changes: 1 addition & 1 deletion src/state-summary/state-card-input_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StateCardInputNumber extends mixinBehaviors(
value="{{value}}"
step="[[step]]"
hidden="[[hiddenslider]]"
pin=""
pin
on-change="selectedValueChanged"
on-click="stopPropagation"
id="slider"
Expand Down