Add Mushroom Number Card (#79)

A Mushroom Number Card for number and input_number entities.
This commit is contained in:
Johan Frick
2023-10-31 14:41:37 +01:00
committed by GitHub
parent ccf10f716c
commit f76a596572
4 changed files with 55 additions and 7 deletions

View File

@ -316,16 +316,17 @@ The following domains are supported and enabled by default:
* media_player
* sensor
* binary_sensor
* number
* default (Miscellaneous)
For these domains, the following options are supported:
| Option | type | Description |
|:---------------|:--------|:---------------------------------------------------------------------------|
| `title` | string | Title of the domain in a view. |
| `showControls` | boolean | Weather to show controls int a view, to switch all entities of the domain. |
| `hidden` | boolean | Set to `true` to exclude the view from the dashboard. |
| `order` | number | Ordering position of the domain entities in a view. |
| Option | type | Description |
|:---------------|:--------|:--------------------------------------------------------------------------|
| `title` | string | Title of the domain in a view. |
| `showControls` | boolean | Weather to show controls in a view, to switch all entities of the domain. |
| `hidden` | boolean | Set to `true` to exclude the domain from the dashboard. |
| `order` | number | Ordering position of the domain entities in a view. |
#### Example

37
src/cards/NumberCard.js Normal file
View File

@ -0,0 +1,37 @@
import {AbstractCard} from "./AbstractCard";
/**
* Number Card Class
*
* Used to create a card for controlling an entity of the number domain.
*
* @class
* @extends AbstractCard
*/
class NumberCard extends AbstractCard {
/**
* Default options of the card.
*
* @type {numberCardOptions}
* @private
*/
#defaultOptions = {
type: "custom:mushroom-number-card",
icon: undefined,
};
/**
* Class constructor.
*
* @param {hassEntity} entity The hass entity to create a card for.
* @param {numberCardOptions} [options={}] Options for the card.
* @throws {Error} If the Helper module isn't initialized.
*/
constructor(entity, options = {}) {
super(entity);
this.mergeOptions(this.#defaultOptions, options);
}
}
export {NumberCard};

View File

@ -60,6 +60,11 @@
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} numberCardOptions Number Card options.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} switchCardOptions Switch Card options.
* @property {{tap_action: switchTapAction}} [action] Home assistant action to perform on tap.

View File

@ -111,5 +111,10 @@ export const optionDefaults = {
showControls: false,
hidden: false,
},
number: {
title: "Numbers",
showControls: false,
hidden: false,
},
}
}
};