Merge pull request #51 from AalianKhan/hide-devices

Add option to hide all entities of a device.
This commit is contained in:
Aalian Khan
2023-09-19 11:04:56 -04:00
committed by GitHub
4 changed files with 22 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ My goal is to propose a way to create powerful dashboards without the need of sp
### Features ### Features
- 🛠 Automatically create dashboard with 3 lines of yaml. - 🛠 Automatically create dashboard with three lines of yaml.
- 😍 Built-in Views for device-specific controls. - 😍 Built-in Views for device-specific controls.
- 🎨 Many options to customize to fit your needs. - 🎨 Many options to customize to fit your needs.
@@ -55,7 +55,7 @@ Mushroom dashboard strategy is available in [HACS][hacsUrl] (Home Assistant Comm
- **Using UI:** _Settings__Dashboards__More Options icon__Resources__Add Resource_ → Set _Url_ - **Using UI:** _Settings__Dashboards__More Options icon__Resources__Add Resource_ → Set _Url_
as `/local/mushroom-strategy.js` → Set _Resource type_ as `JavaScript Module`. as `/local/mushroom-strategy.js` → Set _Resource type_ as `JavaScript Module`.
**Note:** If you do not see the Resources menu, you will need to enable _Advanced Mode_ in your _User Profile_ **Note:** If you do not see the Resources menu, you will need to enable _Advanced Mode_ in your _User Profile_
- **Using YAML:** Add following code to the `lovelace` section. - **Using YAML:** Add the following code to the `lovelace` section.
```yaml ```yaml
resources: resources:
- url: /local/mushroom-strategy.js - url: /local/mushroom-strategy.js
@@ -66,7 +66,7 @@ Mushroom dashboard strategy is available in [HACS][hacsUrl] (Home Assistant Comm
All the rounded cards can be configured using the Dashboard UI editor. All the rounded cards can be configured using the Dashboard UI editor.
1. In the UI of the dashboard, click the 3 dots in the top right corner. 1. In the UI of the dashboard, click the three dots in the top right corner.
2. Click _Edit Dashboard_. 2. Click _Edit Dashboard_.
3. Click 3 dots again 3. Click 3 dots again
4. Click `Raw configuration editor` 4. Click `Raw configuration editor`
@@ -201,7 +201,9 @@ To exclude this area from the dashboard and views, set its property `hidden` to
### Card Options ### Card Options
The `card_options` entry enables you to specify a card type for an entity or to hide the card from the dashboard. The `card_options` entry enables you to specify a card type for an entity or to hide the card from the dashboard.
You can also provide a device ID and hide all entities linked to that device.
See [Instructions on to find a device ID](https://community.home-assistant.io/t/device-id-entity-id-where-to-find/289230/4?u=aaliankhan).
#### Example #### Example
@@ -214,6 +216,9 @@ strategy:
type: custom:mushroom-fan-card type: custom:mushroom-fan-card
remote.harmony_hub_wk: remote.harmony_hub_wk:
hidden: true hidden: true
077ba0492c9bb3b31ffac34f1f3a626a:
hidden: true
views: [ ] views: [ ]
``` ```
@@ -299,11 +304,11 @@ strategy:
options: options:
domains: domains:
lights: lights:
title: "My cool lights" title: "My cool lights"
order: 1 order: 1
switch: switch:
showControls: false showControls: false
default: default:
hidden: true hidden: true
views: [ ] views: [ ]
``` ```

File diff suppressed because one or more lines are too long

View File

@@ -118,8 +118,9 @@ class MushroomStrategy {
// Find the state of the current sensor. // Find the state of the current sensor.
const sensorState = sensorStates.find(state => state.entity_id === sensor.entity_id); const sensorState = sensorStates.find(state => state.entity_id === sensor.entity_id);
let cardOptions = Helper.strategyOptions.card_options?.[sensor.entity_id] ?? {}; let cardOptions = Helper.strategyOptions.card_options?.[sensor.entity_id] ?? {};
let deviceOptions = Helper.strategyOptions.card_options?.[sensor.device_id] ?? {};
if (!cardOptions.hidden) { if (!cardOptions.hidden && !deviceOptions.hidden) {
if (sensorState?.attributes.unit_of_measurement) { if (sensorState?.attributes.unit_of_measurement) {
cardOptions = { cardOptions = {
...{ ...{
@@ -149,8 +150,9 @@ class MushroomStrategy {
// Create a card for each domain-entity of the current area. // Create a card for each domain-entity of the current area.
for (const entity of entities) { for (const entity of entities) {
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {}; let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
let deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id] ?? {};
if (!cardOptions.hidden) { if (!cardOptions.hidden && !deviceOptions.hidden) {
domainCards.push(new cardModule[className](entity, cardOptions).getCard()); domainCards.push(new cardModule[className](entity, cardOptions).getCard());
} }
} }
@@ -219,8 +221,9 @@ class MushroomStrategy {
for (const entity of miscellaneousEntities) { for (const entity of miscellaneousEntities) {
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {}; let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
let deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id] ?? {};
if (!cardOptions.hidden) { if (!cardOptions.hidden && !deviceOptions.hidden) {
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard()); miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
} }
} }

View File

@@ -77,8 +77,9 @@ class AbstractView {
// Create a card for each domain-entity of the current area. // Create a card for each domain-entity of the current area.
for (const entity of entities) { for (const entity of entities) {
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {}; let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
let deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id] ?? {};
if (cardOptions.hidden) { if (cardOptions.hidden || deviceOptions.hidden) {
continue; continue;
} }