mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-02 19:14:27 +02:00
Add a showControls option to all domains
Adds the `showControls` option to the all-domains configuration to allow hiding the control buttons at a domain view or for the domains at an area view. Closes #126.
This commit is contained in:
@@ -19,7 +19,6 @@ class HeaderCard {
|
|||||||
static getDefaultConfig(): StrategyHeaderCardConfig {
|
static getDefaultConfig(): StrategyHeaderCardConfig {
|
||||||
return {
|
return {
|
||||||
type: 'custom:mushroom-title-card',
|
type: 'custom:mushroom-title-card',
|
||||||
showControls: true,
|
|
||||||
iconOn: 'mdi:power-on',
|
iconOn: 'mdi:power-on',
|
||||||
iconOff: 'mdi:power-off',
|
iconOff: 'mdi:power-off',
|
||||||
onService: 'none',
|
onService: 'none',
|
||||||
|
@@ -38,6 +38,7 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
|||||||
_: {
|
_: {
|
||||||
hide_config_entities: undefined,
|
hide_config_entities: undefined,
|
||||||
hide_diagnostic_entities: undefined,
|
hide_diagnostic_entities: undefined,
|
||||||
|
showControls: true,
|
||||||
},
|
},
|
||||||
binary_sensor: {
|
binary_sensor: {
|
||||||
title: `${localize('sensor.binary')} ` + localize('sensor.sensors'),
|
title: `${localize('sensor.binary')} ` + localize('sensor.sensors'),
|
||||||
@@ -56,7 +57,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
|||||||
},
|
},
|
||||||
cover: {
|
cover: {
|
||||||
title: localize('cover.covers'),
|
title: localize('cover.covers'),
|
||||||
showControls: true,
|
|
||||||
iconOn: 'mdi:arrow-up',
|
iconOn: 'mdi:arrow-up',
|
||||||
iconOff: 'mdi:arrow-down',
|
iconOff: 'mdi:arrow-down',
|
||||||
onService: 'cover.open_cover',
|
onService: 'cover.open_cover',
|
||||||
@@ -70,7 +70,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
|||||||
},
|
},
|
||||||
fan: {
|
fan: {
|
||||||
title: localize('fan.fans'),
|
title: localize('fan.fans'),
|
||||||
showControls: true,
|
|
||||||
iconOn: 'mdi:fan',
|
iconOn: 'mdi:fan',
|
||||||
iconOff: 'mdi:fan-off',
|
iconOff: 'mdi:fan-off',
|
||||||
onService: 'fan.turn_on',
|
onService: 'fan.turn_on',
|
||||||
@@ -84,7 +83,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
|||||||
},
|
},
|
||||||
light: {
|
light: {
|
||||||
title: localize('light.lights'),
|
title: localize('light.lights'),
|
||||||
showControls: true,
|
|
||||||
iconOn: 'mdi:lightbulb',
|
iconOn: 'mdi:lightbulb',
|
||||||
iconOff: 'mdi:lightbulb-off',
|
iconOff: 'mdi:lightbulb-off',
|
||||||
onService: 'light.turn_on',
|
onService: 'light.turn_on',
|
||||||
@@ -124,7 +122,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
|||||||
},
|
},
|
||||||
switch: {
|
switch: {
|
||||||
title: localize('switch.switches'),
|
title: localize('switch.switches'),
|
||||||
showControls: true,
|
|
||||||
iconOn: 'mdi:power-plug',
|
iconOn: 'mdi:power-plug',
|
||||||
iconOff: 'mdi:power-plug-off',
|
iconOff: 'mdi:power-plug-off',
|
||||||
onService: 'switch.turn_on',
|
onService: 'switch.turn_on',
|
||||||
|
@@ -123,7 +123,10 @@ class MushroomStrategy extends HTMLTemplateElement {
|
|||||||
|
|
||||||
const titleCard = new HeaderCard(
|
const titleCard = new HeaderCard(
|
||||||
{ entity_id: entities.map((entity) => entity.entity_id) },
|
{ entity_id: entities.map((entity) => entity.entity_id) },
|
||||||
Registry.strategyOptions.domains[domain],
|
{
|
||||||
|
...Registry.strategyOptions.domains['_'],
|
||||||
|
...Registry.strategyOptions.domains[domain],
|
||||||
|
},
|
||||||
).createCard();
|
).createCard();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -12,7 +12,7 @@ export type AbstractCardConfig = LovelaceCardConfig & EntitySharedConfig & Appea
|
|||||||
/**
|
/**
|
||||||
* Header Card Config.
|
* Header Card Config.
|
||||||
*
|
*
|
||||||
* @property {boolean} [showControls=true] - False to hide controls.
|
* @property {boolean} [showControls] - False to hide controls.
|
||||||
* @property {string} [iconOn] - Icon to show for switching entities from the off state.
|
* @property {string} [iconOn] - Icon to show for switching entities from the off state.
|
||||||
* @property {string} [iconOff] - Icon to show for switching entities to the off state.
|
* @property {string} [iconOff] - Icon to show for switching entities to the off state.
|
||||||
* @property {string} [onService=none] - Service to call for switching entities from the off state.
|
* @property {string} [onService=none] - Service to call for switching entities from the off state.
|
||||||
|
@@ -172,14 +172,14 @@ export interface ViewInfo {
|
|||||||
/**
|
/**
|
||||||
* All-Domains Configuration.
|
* All-Domains Configuration.
|
||||||
*
|
*
|
||||||
* @property {boolean | undefined} hide_config_entities - If True, all configuration entities are hidden from the
|
* @property {boolean} [hide_config_entities] - If True, all configuration entities are hidden from the dashboard.
|
||||||
* dashboard.
|
* @property {boolean} [hide_diagnostic_entities] - If True, all diagnostic entities are hidden from the dashboard.
|
||||||
* @property {boolean | undefined} hide_diagnostic_entities - If True, all diagnostic entities are hidden from the
|
* @property {boolean} [showControls] - False to hide controls.
|
||||||
* dashboard.
|
|
||||||
*/
|
*/
|
||||||
export interface AllDomainsConfig {
|
export interface AllDomainsConfig {
|
||||||
hide_config_entities: boolean | undefined;
|
hide_config_entities?: boolean;
|
||||||
hide_diagnostic_entities: boolean | undefined;
|
hide_diagnostic_entities?: boolean;
|
||||||
|
showControls?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,7 +22,7 @@ import RegistryFilter from '../utilities/RegistryFilter';
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractView {
|
abstract class AbstractView {
|
||||||
/** The base configuration of a view. */
|
/** The base configuration of a view. */
|
||||||
protected baseConfiguration: LovelaceViewConfig = {
|
protected baseConfiguration: ViewConfig = {
|
||||||
icon: 'mdi:view-dashboard',
|
icon: 'mdi:view-dashboard',
|
||||||
subview: false,
|
subview: false,
|
||||||
};
|
};
|
||||||
@@ -143,10 +143,14 @@ abstract class AbstractView {
|
|||||||
): void {
|
): void {
|
||||||
this.baseConfiguration = { ...this.baseConfiguration, ...viewConfiguration, ...customConfiguration };
|
this.baseConfiguration = { ...this.baseConfiguration, ...viewConfiguration, ...customConfiguration };
|
||||||
|
|
||||||
|
this.baseConfiguration.headerCardConfiguration = {
|
||||||
|
showControls:
|
||||||
|
Registry.strategyOptions.domains[this.domain as Exclude<SupportedDomains, 'home'>]?.showControls ??
|
||||||
|
Registry.strategyOptions.domains['_'].showControls,
|
||||||
|
};
|
||||||
|
|
||||||
this.viewHeaderCardConfiguration = new HeaderCard(this.getDomainTargets(), {
|
this.viewHeaderCardConfiguration = new HeaderCard(this.getDomainTargets(), {
|
||||||
...(('headerCardConfiguration' in this.baseConfiguration
|
...(this.baseConfiguration.headerCardConfiguration as StrategyHeaderCardConfig),
|
||||||
? this.baseConfiguration.headerCardConfiguration
|
|
||||||
: {}) as StrategyHeaderCardConfig),
|
|
||||||
...headerCardConfig,
|
...headerCardConfig,
|
||||||
}).createCard();
|
}).createCard();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user