forked from DigiLive/mushroom-strategy
Add Mushroom Number Card (#79)
A Mushroom Number Card for number and input_number entities.
This commit is contained in:
13
README.md
13
README.md
@ -316,16 +316,17 @@ The following domains are supported and enabled by default:
|
|||||||
* media_player
|
* media_player
|
||||||
* sensor
|
* sensor
|
||||||
* binary_sensor
|
* binary_sensor
|
||||||
|
* number
|
||||||
* default (Miscellaneous)
|
* default (Miscellaneous)
|
||||||
|
|
||||||
For these domains, the following options are supported:
|
For these domains, the following options are supported:
|
||||||
|
|
||||||
| Option | type | Description |
|
| Option | type | Description |
|
||||||
|:---------------|:--------|:---------------------------------------------------------------------------|
|
|:---------------|:--------|:--------------------------------------------------------------------------|
|
||||||
| `title` | string | Title of the domain in a view. |
|
| `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. |
|
| `showControls` | boolean | Weather to show controls in a view, to switch all entities of the domain. |
|
||||||
| `hidden` | boolean | Set to `true` to exclude the view from the dashboard. |
|
| `hidden` | boolean | Set to `true` to exclude the domain from the dashboard. |
|
||||||
| `order` | number | Ordering position of the domain entities in a view. |
|
| `order` | number | Ordering position of the domain entities in a view. |
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
|
37
src/cards/NumberCard.js
Normal file
37
src/cards/NumberCard.js
Normal 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};
|
@ -60,6 +60,11 @@
|
|||||||
* @memberOf typedefs.cards
|
* @memberOf typedefs.cards
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {abstractOptions & Object} numberCardOptions Number Card options.
|
||||||
|
* @memberOf typedefs.cards
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {abstractOptions & Object} switchCardOptions Switch Card options.
|
* @typedef {abstractOptions & Object} switchCardOptions Switch Card options.
|
||||||
* @property {{tap_action: switchTapAction}} [action] Home assistant action to perform on tap.
|
* @property {{tap_action: switchTapAction}} [action] Home assistant action to perform on tap.
|
||||||
|
@ -111,5 +111,10 @@ export const optionDefaults = {
|
|||||||
showControls: false,
|
showControls: false,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
},
|
},
|
||||||
|
number: {
|
||||||
|
title: "Numbers",
|
||||||
|
showControls: false,
|
||||||
|
hidden: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
Reference in New Issue
Block a user