Merge pull request #43 from AalianKhan/lock-card

Fix lock icon by adding lock domain and default domain bug
This commit is contained in:
Aalian Khan
2023-09-09 16:55:15 -04:00
committed by GitHub
7 changed files with 70 additions and 1 deletions

View File

@@ -275,6 +275,7 @@ The following domains are supported and enabled by default:
* cover * cover
* switch * switch
* camera * camera
* lock
* climate * climate
* media_player * media_player
* sensor * sensor
@@ -290,6 +291,23 @@ For these domains, the following options are supported:
| `hidden` | boolean | Set to `true` to exclude the view from the dashboard. | | `hidden` | boolean | Set to `true` to exclude the view 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
```YAML
strategy:
type: custom:mushroom-strategy
options:
domains:
lights:
title: "My cool lights"
order: 1
switch:
showControls: false
default:
hidden: true
views: [ ]
```
### Chips ### Chips
![Chips](./docs/chips.png) ![Chips](./docs/chips.png)

File diff suppressed because one or more lines are too long

39
src/cards/LockCard.js Normal file
View File

@@ -0,0 +1,39 @@
import {AbstractCard} from "./AbstractCard";
/**
* Lock Card Class
*
* Used to create a card for controlling an entity of the lock domain.
*
* @class
* @extends AbstractCard
*/
class LockCard extends AbstractCard {
/**
* Default options of the card.
*
* @type {lockCardOptions}
* @private
*/
#defaultOptions = {
type: "custom:mushroom-lock-card",
icon: undefined,
};
/**
* Class constructor.
*
* @param {hassEntity} entity The hass entity to create a card for.
* @param {lockCardOptions} [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 {LockCard};

View File

@@ -17,6 +17,7 @@ class MediaPlayerCard extends AbstractCard {
*/ */
#defaultOptions = { #defaultOptions = {
type: "custom:mushroom-media-player-card", type: "custom:mushroom-media-player-card",
icon: undefined,
use_media_info: true, use_media_info: true,
media_controls: [ media_controls: [
"on_off", "on_off",

View File

@@ -55,6 +55,11 @@
* @memberOf typedefs.cards * @memberOf typedefs.cards
*/ */
/**
* @typedef {abstractOptions & Object} lockCardOptions Lock 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.

View File

@@ -188,6 +188,7 @@ class MushroomStrategy {
} }
} }
// TODO: Check if default is hidden
// Create cards for any other domain. // Create cards for any other domain.
// Collect device entities of the current area. // Collect device entities of the current area.
const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id) const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id)

View File

@@ -86,6 +86,11 @@ export const optionDefaults = {
showControls: false, showControls: false,
hidden: false, hidden: false,
}, },
lock: {
title: "Locks",
showControls: false,
hidden: false,
},
climate: { climate: {
title: "Climates", title: "Climates",
showControls: false, showControls: false,