mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 14:56:37 +00:00
Allow energy dashboard to be cast (#15397)
This commit is contained in:
parent
f786539f15
commit
7041d322d6
@ -252,6 +252,22 @@ export class HcMain extends HassElement {
|
||||
msg.urlPath = null;
|
||||
}
|
||||
this._lovelacePath = msg.viewPath;
|
||||
if (msg.urlPath === "energy") {
|
||||
this._lovelaceConfig = {
|
||||
views: [
|
||||
{
|
||||
strategy: {
|
||||
type: "energy",
|
||||
options: { show_date_selection: true },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
this._urlPath = "energy";
|
||||
this._lovelacePath = 0;
|
||||
this._sendStatus();
|
||||
return;
|
||||
}
|
||||
if (!this._unsubLovelace || this._urlPath !== msg.urlPath) {
|
||||
this._urlPath = msg.urlPath;
|
||||
this._lovelaceConfig = undefined;
|
||||
|
@ -18,7 +18,7 @@ import "../lovelace/components/hui-energy-period-selector";
|
||||
import { Lovelace } from "../lovelace/types";
|
||||
import "../lovelace/views/hui-view";
|
||||
|
||||
const LOVELACE_CONFIG: LovelaceConfig = {
|
||||
const ENERGY_LOVELACE_CONFIG: LovelaceConfig = {
|
||||
views: [
|
||||
{
|
||||
strategy: {
|
||||
@ -93,8 +93,8 @@ class PanelEnergy extends LitElement {
|
||||
|
||||
private _setLovelace() {
|
||||
this._lovelace = {
|
||||
config: LOVELACE_CONFIG,
|
||||
rawConfig: LOVELACE_CONFIG,
|
||||
config: ENERGY_LOVELACE_CONFIG,
|
||||
rawConfig: ENERGY_LOVELACE_CONFIG,
|
||||
editMode: false,
|
||||
urlPath: "energy",
|
||||
mode: "generated",
|
||||
|
@ -56,7 +56,7 @@ export class EnergyStrategy {
|
||||
(source) => source.type === "water"
|
||||
);
|
||||
|
||||
if (info.narrow) {
|
||||
if (info.narrow || info.view.strategy?.options?.show_date_selection) {
|
||||
view.cards!.push({
|
||||
type: "energy-date-selection",
|
||||
collection_key: "energy_dashboard",
|
||||
|
@ -884,6 +884,11 @@ class HuiEnergyDistrubutionCard
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 12px;
|
||||
opacity: 1;
|
||||
height: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 80px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
line,
|
||||
path {
|
||||
|
@ -62,7 +62,7 @@ const buttonEntitiesRowConfigStruct = object({
|
||||
|
||||
const castEntitiesRowConfigStruct = object({
|
||||
type: literal("cast"),
|
||||
view: union([string(), number()]),
|
||||
view: optional(union([string(), number()])),
|
||||
dashboard: optional(string()),
|
||||
name: optional(string()),
|
||||
icon: optional(string()),
|
||||
|
@ -55,7 +55,7 @@ export interface CastConfig {
|
||||
type: "cast";
|
||||
icon?: string;
|
||||
name?: string;
|
||||
view: string | number;
|
||||
view?: string | number;
|
||||
dashboard?: string;
|
||||
// Hide the row if either unsupported browser or no API available.
|
||||
hide_if_unavailable?: boolean;
|
||||
|
@ -29,13 +29,10 @@ class HuiCastRow extends LitElement implements LovelaceRow {
|
||||
@state() private _noHTTPS = false;
|
||||
|
||||
public setConfig(config: CastConfig): void {
|
||||
if (!config || config.view === undefined || config.view === null) {
|
||||
throw new Error("View required");
|
||||
}
|
||||
|
||||
this._config = {
|
||||
icon: "hass:television",
|
||||
icon: "mdi:television",
|
||||
name: "Home Assistant Cast",
|
||||
view: 0,
|
||||
...config,
|
||||
};
|
||||
}
|
||||
@ -123,7 +120,7 @@ class HuiCastRow extends LitElement implements LovelaceRow {
|
||||
castSendShowLovelaceView(
|
||||
this._castManager!,
|
||||
this.hass.auth.data.hassUrl,
|
||||
this._config!.view,
|
||||
this._config!.view!,
|
||||
this._config!.dashboard
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user