Skip to content

Commit

Permalink
Add humidifier and thermostat card
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Jul 1, 2024
1 parent f8e187b commit 1cee052
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
24 changes: 23 additions & 1 deletion src/panels/lovelace/cards/hui-humidifier-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { HomeAssistant } from "../../../types";
import "../card-features/hui-card-features";
import { findEntities } from "../common/find-entities";
import { createEntityNotFoundWarning } from "../components/hui-warning";
import { LovelaceCard, LovelaceCardEditor } from "../types";
import {
LovelaceCard,
LovelaceCardEditor,
LovelaceLayoutOptions,
} from "../types";
import { HumidifierCardConfig } from "./types";

@customElement("hui-humidifier-card")
Expand Down Expand Up @@ -173,6 +177,24 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
`;
}

public getLayoutOptions(): LovelaceLayoutOptions {
const grid_columns = 4;
let grid_rows = 5;
let grid_min_rows = 2;
const grid_min_columns = 2;
if (this._config?.features?.length) {
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
grid_rows += featureHeight;
grid_min_rows += featureHeight;
}
return {
grid_columns,
grid_rows,
grid_min_rows,
grid_min_columns,
};
}

static get styles(): CSSResultGroup {
return css`
:host {
Expand Down
24 changes: 23 additions & 1 deletion src/panels/lovelace/cards/hui-thermostat-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { HomeAssistant } from "../../../types";
import "../card-features/hui-card-features";
import { findEntities } from "../common/find-entities";
import { createEntityNotFoundWarning } from "../components/hui-warning";
import { LovelaceCard, LovelaceCardEditor } from "../types";
import {
LovelaceCard,
LovelaceCardEditor,
LovelaceLayoutOptions,
} from "../types";
import { ThermostatCardConfig } from "./types";

@customElement("hui-thermostat-card")
Expand Down Expand Up @@ -165,6 +169,24 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
`;
}

public getLayoutOptions(): LovelaceLayoutOptions {
const grid_columns = 4;
let grid_rows = 5;
let grid_min_rows = 2;
const grid_min_columns = 2;
if (this._config?.features?.length) {
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
grid_rows += featureHeight;
grid_min_rows += featureHeight;
}
return {
grid_columns,
grid_rows,
grid_min_rows,
grid_min_columns,
};
}

static get styles(): CSSResultGroup {
return css`
:host {
Expand Down
3 changes: 2 additions & 1 deletion src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
const grid_columns = 2;
let grid_rows = 1;
if (this._config?.features?.length) {
grid_rows += Math.ceil((this._config.features.length * 2) / 3);
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
grid_rows += featureHeight;
}
if (this._config?.vertical) {
grid_rows!++;
Expand Down

0 comments on commit 1cee052

Please sign in to comment.