forked from DigiLive/mushroom-strategy
Support Select/InputSelect mushroom cards (#151)
Add cards * Select Card. * Input Select Card Contribution by wallforfry
This commit is contained in:
committed by
GitHub
parent
d7f100df16
commit
dbebfc88d3
41
src/cards/InputSelectCard.ts
Normal file
41
src/cards/InputSelectCard.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {EntityRegistryEntry} from "../types/homeassistant/data/entity_registry";
|
||||
import {SelectCardConfig} from "../types/lovelace-mushroom/cards/select-card-config";
|
||||
import {SelectCard} from './SelectCard';
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported
|
||||
/**
|
||||
* InputSelect Card Class
|
||||
*
|
||||
* Used to create a card for controlling an entity of the input_select domain.
|
||||
*
|
||||
* @class
|
||||
* @extends AbstractCard
|
||||
*/
|
||||
class InputSelectCard extends SelectCard {
|
||||
/**
|
||||
* Default configuration of the card.
|
||||
*
|
||||
* @type {SelectCardConfig}
|
||||
* @private
|
||||
*/
|
||||
#defaultConfig: SelectCardConfig = {
|
||||
type: "custom:mushroom-select-card",
|
||||
icon: undefined,
|
||||
};
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param {EntityRegistryEntry} entity The hass entity to create a card for.
|
||||
* @param {cards.InputSelectCardOptions} [options={}] Options for the card.
|
||||
* @throws {Error} If the Helper module isn't initialized.
|
||||
*/
|
||||
constructor(entity: EntityRegistryEntry, options: cards.InputSelectCardOptions = {}) {
|
||||
super(entity);
|
||||
|
||||
this.config = Object.assign(this.config, this.#defaultConfig, options);
|
||||
}
|
||||
}
|
||||
|
||||
export {InputSelectCard};
|
41
src/cards/SelectCard.ts
Normal file
41
src/cards/SelectCard.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {AbstractCard} from "./AbstractCard";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {EntityRegistryEntry} from "../types/homeassistant/data/entity_registry";
|
||||
import {SelectCardConfig} from "../types/lovelace-mushroom/cards/select-card-config";
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported
|
||||
/**
|
||||
* Select Card Class
|
||||
*
|
||||
* Used to create a card for controlling an entity of the select domain.
|
||||
*
|
||||
* @class
|
||||
* @extends AbstractCard
|
||||
*/
|
||||
class SelectCard extends AbstractCard {
|
||||
/**
|
||||
* Default configuration of the card.
|
||||
*
|
||||
* @type {SelectCardConfig}
|
||||
* @private
|
||||
*/
|
||||
#defaultConfig: SelectCardConfig = {
|
||||
type: "custom:mushroom-select-card",
|
||||
icon: undefined,
|
||||
};
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param {EntityRegistryEntry} entity The hass entity to create a card for.
|
||||
* @param {cards.SelectCardOptions} [options={}] Options for the card.
|
||||
* @throws {Error} If the Helper module isn't initialized.
|
||||
*/
|
||||
constructor(entity: EntityRegistryEntry, options: cards.SelectCardOptions = {}) {
|
||||
super(entity);
|
||||
|
||||
this.config = Object.assign(this.config, this.#defaultConfig, options);
|
||||
}
|
||||
}
|
||||
|
||||
export {SelectCard};
|
@ -100,6 +100,16 @@ export const configurationDefaults: StrategyDefaults = {
|
||||
showControls: true,
|
||||
hidden: false,
|
||||
},
|
||||
select: {
|
||||
title: "Selects",
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
input_select: {
|
||||
title: "Input Selects",
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
},
|
||||
home_view: {
|
||||
hidden: [],
|
||||
|
18
src/types/lovelace-mushroom/cards/select-card-config.ts
Normal file
18
src/types/lovelace-mushroom/cards/select-card-config.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {ActionsSharedConfig} from "../shared/config/actions-config";
|
||||
import {LovelaceCardConfig} from "../../homeassistant/data/lovelace";
|
||||
import {EntitySharedConfig} from "../shared/config/entity-config";
|
||||
import {AppearanceSharedConfig} from "../shared/config/appearance-config";
|
||||
|
||||
/**
|
||||
* Select Card Config.
|
||||
*
|
||||
* @property {string} [icon_color=blue] Custom color for icon when entity state is active.
|
||||
*
|
||||
* @see https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/select.md
|
||||
*/
|
||||
export type SelectCardConfig = LovelaceCardConfig &
|
||||
EntitySharedConfig &
|
||||
AppearanceSharedConfig &
|
||||
ActionsSharedConfig & {
|
||||
icon_color?: string;
|
||||
};
|
@ -16,6 +16,7 @@ import {MediaPlayerCardConfig} from "../lovelace-mushroom/cards/media-player-car
|
||||
import {NumberCardConfig} from "../lovelace-mushroom/cards/number-card-config";
|
||||
import {PersonCardConfig} from "../lovelace-mushroom/cards/person-card-config";
|
||||
import {VacuumCardConfig} from "../lovelace-mushroom/cards/vacuum-card-config";
|
||||
import {SelectCardConfig} from '../lovelace-mushroom/cards/select-card-config';
|
||||
|
||||
export namespace cards {
|
||||
/**
|
||||
@ -58,6 +59,8 @@ export namespace cards {
|
||||
export type PictureEntityCardOptions = Omit<PictureEntityCardConfig, "type">;
|
||||
export type TemplateCardOptions = Omit<TemplateCardConfig, "type">;
|
||||
export type VacuumCardOptions = Omit<VacuumCardConfig, "type">;
|
||||
export type SelectCardOptions = Omit<SelectCardConfig, "type">;
|
||||
export type InputSelectCardOptions = Omit<SelectCardConfig, "type">;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user