Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Tile cards #2415

Merged
merged 2 commits into from
Dec 30, 2022
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
1 change: 1 addition & 0 deletions src/language-service/src/schemas/lovelace/cards/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export * as Sensor from "./sensor";
export * as ShoppingList from "./shopping_list";
export * as StatisticsGraph from "./statistics_graph";
export * as Thermostat from "./thermostat";
export * as Tile from "./tile";
export * as VerticalStack from "./vertical_stack";
export * as WeatherForecast from "./weather_forecast";
115 changes: 115 additions & 0 deletions src/language-service/src/schemas/lovelace/cards/tile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Tile Card
* Sources:
* - https://github.com/home-assistant/frontend/blob/dev/src/panels/lovelace/cards/hui-tile-card.ts
* - https://github.com/home-assistant/frontend/blob/dev/src/panels/lovelace/cards/types.ts
* - https://github.com/home-assistant/frontend/blob/dev/src/data/lovelace.ts
*/

import { Action } from "../actions";
import { Entity as EntityString } from "../../types";

export interface Schema {
/**
* The tile card gives you a quick overview of your entity. The card allows you to toggle the entity and show the more info dialog.
* https://www.home-assistant.io/dashboards/tile/
*/
type: "tile";

/**
* Set the color when the entity is active. By default, the color is based on state, domain, and device_class of your entity. It accepts color token or hex color code.
* https://www.home-assistant.io/dashboards/tile/#color
*/
color?: string;

/**
* Entity to show in the tile card
* https://www.home-assistant.io/dashboards/tile/#entity
*/
entity: EntityString;

/**
*
*/
features?: TileFeatures[];

/**
* Overwrites icon.
* https://www.home-assistant.io/dashboards/tile/#icon
*/
icon?: string;

/**
* Action taken on icon card tap. By default, it will toggle the entity (if possible), otherwise, show the “more-info” dialog.
* https://www.home-assistant.io/dashboards/tile/#icon_tap_action
*/
icon_tap_action?: Action;

/**
* Overwrites friendly name.
* https://www.home-assistant.io/dashboards/tile/#name
*/
name?: string;

/**
* If your entity has a picture, it will replace the icon.
* ttps://www.home-assistant.io/dashboards/tile/#show_entity_picture
*/
show_entity_picture?: boolean;

/**
* Action taken on card tap. By default, it will show the “more-info” dialog.
* https://www.home-assistant.io/dashboards/tile/#tap_action
*/
tap_action?: Action;
}

type TileFeatures =
| CoverOpenCloseFeature
| CoverTiltFeature
| LightBrightnessFeature
| VacuumCommandsFeature;

interface CoverOpenCloseFeature {
/**
* Widget that display buttons to open, close or stop a cover.
* https://www.home-assistant.io/dashboards/tile/#cover-openclose
*/
type: "cover-open-close";
}

interface CoverTiltFeature {
/**
* Widget that display buttons to open, close or stop a cover.
* https://www.home-assistant.io/dashboards/tile/#cover-tilt
*/
type: "cover-tilt";
}

interface LightBrightnessFeature {
/**
* Widget that display a slider to select the brightness for a light.
* https://www.home-assistant.io/dashboards/tile/#light-brightness
*/
type: "light-brightness";
}

type VacuumCommands =
| "start_pause"
| "stop"
| "clean_spot"
| "locate"
| "return_home";
interface VacuumCommandsFeature {
/**
* Widget that display buttons to control a vacuum.
* https://www.home-assistant.io/dashboards/tile/#vacuum-commands
*/
type: "vacuum-commands";

/**
* List of commands to show on the card.
* https://www.home-assistant.io/dashboards/tile/#commands
*/
commands: VacuumCommands[];
}
1 change: 1 addition & 0 deletions src/language-service/src/schemas/lovelace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type Card =
| cards.ShoppingList.Schema
| cards.StatisticsGraph.Schema
| cards.Thermostat.Schema
| cards.Tile.Schema
| cards.VerticalStack.Schema
| cards.WeatherForecast.Schema;

Expand Down