Add option to hide all entities of a device.

#48
This commit is contained in:
Aalian Khan
2023-09-14 15:40:37 -04:00
parent 633e548531
commit 01c6205c02
3 changed files with 9 additions and 5 deletions

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.devices?.[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.devices?.[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.devices?.[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.devices?.[entity.device_id] ?? {};
if (cardOptions.hidden) { if (cardOptions.hidden || deviceOptions.hidden) {
continue; continue;
} }