Add Valve view

This commit is contained in:
DigiLive
2025-05-23 12:43:35 +02:00
parent 4e912c5b8f
commit b9025a7fe8
8 changed files with 80 additions and 5 deletions

View File

@@ -141,6 +141,14 @@ export const ConfigurationDefaults: StrategyDefaults = {
offService: 'vacuum.stop', offService: 'vacuum.stop',
hidden: false, hidden: false,
}, },
valve: {
title: localize('valve.valves'),
iconOn: 'mdi:valve-open',
iconOff: 'mdi:valve-closed',
onService: 'valve.open_valve',
offService: 'valve.close_valve',
hidden: false,
},
}, },
extra_cards: [], extra_cards: [],
extra_views: [], extra_views: [],
@@ -191,6 +199,10 @@ export const ConfigurationDefaults: StrategyDefaults = {
order: 8, order: 8,
hidden: false, hidden: false,
}, },
valve: {
order: 11,
hidden: false,
},
}, },
quick_access_cards: [], quick_access_cards: [],
}; };

View File

@@ -75,6 +75,7 @@
"opening": "Öffnet", "opening": "Öffnet",
"closed": "Geschlossen", "closed": "Geschlossen",
"closing": "Schließt", "closing": "Schließt",
"stopped": "Gestoppt" "stopped": "Gestoppt",
"unclosed": "Nicht geschlossen"
} }
} }

View File

@@ -75,6 +75,7 @@
"opening": "Opening", "opening": "Opening",
"closed": "Closed", "closed": "Closed",
"closing": "Closing", "closing": "Closing",
"stopped": "Stopped" "stopped": "Stopped",
"unclosed": "Unclosed"
} }
} }

View File

@@ -75,6 +75,7 @@
"opening": "Abriendo", "opening": "Abriendo",
"closed": "Cerrada", "closed": "Cerrada",
"closing": "Cerrando", "closing": "Cerrando",
"stopped": "Detenida" "stopped": "Detenida",
"unclosed": "No Cerrada"
} }
} }

View File

@@ -75,6 +75,7 @@
"opening": "Openen", "opening": "Openen",
"closed": "Gesloten", "closed": "Gesloten",
"closing": "Sluiten", "closing": "Sluiten",
"stopped": "Gestopt" "stopped": "Gestopt",
"unclosed": "Niet gesloten"
} }
} }

View File

@@ -75,6 +75,7 @@
"opening": "Abrindo", "opening": "Abrindo",
"closed": "Fechado", "closed": "Fechado",
"closing": "Fechando", "closing": "Fechando",
"stopped": "Parado" "stopped": "Parado",
"unclosed": "Nao fechado"
} }
} }

View File

@@ -37,6 +37,7 @@ const SUPPORTED_DOMAINS = [
'sensor', 'sensor',
'switch', 'switch',
'vacuum', 'vacuum',
'valve',
] as const; ] as const;
/** /**
@@ -55,6 +56,7 @@ const SUPPORTED_VIEWS = [
'scene', 'scene',
'switch', 'switch',
'vacuum', 'vacuum',
'valve',
] as const; ] as const;
/** /**

56
src/views/ValveView.ts Normal file
View File

@@ -0,0 +1,56 @@
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
import { Registry } from '../Registry';
import { CustomHeaderCardConfig } from '../types/strategy/strategy-cards';
import { ViewConfig } from '../types/strategy/strategy-views';
import { localize } from '../utilities/localize';
import AbstractView from './AbstractView';
/**
* Valve View Class.
*
* Used to create a view configuration for entities of the valve domain.
*/
class ValveView extends AbstractView {
/** The domain of the entities that the view is representing. */
static readonly domain = 'valve' as const;
/**
* Class constructor.
*
* @param {ViewConfig} [customConfiguration] Custom view configuration.
*/
constructor(customConfiguration?: ViewConfig) {
super();
this.initializeViewConfig(ValveView.getDefaultConfig(), customConfiguration, ValveView.getViewHeaderCardConfig());
}
/** Returns the default configuration object for the view. */
static getDefaultConfig(): ViewConfig {
return {
title: localize('valve.valves'),
path: 'valves',
icon: 'mdi:valve',
subview: false,
headerCardConfiguration: {
iconOn: 'mdi:valve-open',
iconOff: 'mdi:valve-closed',
onService: 'valve.open_valve',
offService: 'valve.close_valve',
},
};
}
/** Returns the default configuration of the view's Header card. */
static getViewHeaderCardConfig(): CustomHeaderCardConfig {
return {
title: localize('valve.all_valves'),
subtitle:
Registry.getCountTemplate(ValveView.domain, 'in', '[closed]') +
` ${localize('valve.valves')} ${localize('valve.unclosed')}`,
};
}
}
export default ValveView;