mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
parent
f600b0522c
commit
601bbfd88e
@ -13,15 +13,16 @@ import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
|||||||
import { LovelaceCard } from "../types";
|
import { LovelaceCard } from "../types";
|
||||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||||
import { longPress } from "../common/directives/long-press-directive";
|
import { longPress } from "../common/directives/long-press-directive";
|
||||||
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
|
import { loadRoundslider } from "../../../resources/jquery.roundslider.ondemand";
|
||||||
|
import { toggleEntity } from "../common/entity/toggle-entity";
|
||||||
|
|
||||||
import stateIcon from "../../../common/entity/state_icon";
|
import stateIcon from "../../../common/entity/state_icon";
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|
||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import { loadRoundslider } from "../../../resources/jquery.roundslider.ondemand";
|
|
||||||
|
|
||||||
const lightConfig = {
|
const lightConfig = {
|
||||||
radius: 80,
|
radius: 80,
|
||||||
@ -102,14 +103,14 @@ export class HuiLightCard extends hassLocalizeLitMixin(LitElement)
|
|||||||
color: this._computeColor(stateObj),
|
color: this._computeColor(stateObj),
|
||||||
})
|
})
|
||||||
}"
|
}"
|
||||||
@ha-click="${() => this._handleClick(false)}"
|
@ha-click="${this._handleTap}"
|
||||||
@ha-hold="${() => this._handleClick(true)}"
|
@ha-hold="${this._handleHold}"
|
||||||
.longPress="${longPress()}"
|
.longPress="${longPress()}"
|
||||||
></ha-icon>
|
></ha-icon>
|
||||||
<div
|
<div
|
||||||
class="brightness"
|
class="brightness"
|
||||||
@ha-click="${() => this._handleClick(false)}"
|
@ha-click="${this._handleTap}"
|
||||||
@ha-hold="${() => this._handleClick(true)}"
|
@ha-hold="${this._handleHold}"
|
||||||
.longPress="${longPress()}"
|
.longPress="${longPress()}"
|
||||||
></div>
|
></div>
|
||||||
<div class="name">
|
<div class="name">
|
||||||
@ -319,18 +320,13 @@ export class HuiLightCard extends hassLocalizeLitMixin(LitElement)
|
|||||||
return `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
|
return `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleClick(hold: boolean): void {
|
private _handleTap() {
|
||||||
const entityId = this._config!.entity;
|
toggleEntity(this.hass!, this._config!.entity!);
|
||||||
|
}
|
||||||
|
|
||||||
if (hold) {
|
private _handleHold() {
|
||||||
fireEvent(this, "hass-more-info", {
|
fireEvent(this, "hass-more-info", {
|
||||||
entityId,
|
entityId: this._config!.entity,
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hass!.callService("light", "toggle", {
|
|
||||||
entity_id: entityId,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user