diff --git a/src/configurationDefaults.ts b/src/configurationDefaults.ts index 1fb8cc7..d0c02c1 100644 --- a/src/configurationDefaults.ts +++ b/src/configurationDefaults.ts @@ -141,6 +141,14 @@ export const ConfigurationDefaults: StrategyDefaults = { offService: 'vacuum.stop', 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_views: [], @@ -191,6 +199,10 @@ export const ConfigurationDefaults: StrategyDefaults = { order: 8, hidden: false, }, + valve: { + order: 11, + hidden: false, + }, }, quick_access_cards: [], }; diff --git a/src/translations/de.json b/src/translations/de.json index 731220d..65e3b36 100644 --- a/src/translations/de.json +++ b/src/translations/de.json @@ -75,6 +75,7 @@ "opening": "Öffnet", "closed": "Geschlossen", "closing": "Schließt", - "stopped": "Gestoppt" + "stopped": "Gestoppt", + "unclosed": "Nicht geschlossen" } } diff --git a/src/translations/en.json b/src/translations/en.json index 1ec9369..4f2c1f9 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -75,6 +75,7 @@ "opening": "Opening", "closed": "Closed", "closing": "Closing", - "stopped": "Stopped" + "stopped": "Stopped", + "unclosed": "Unclosed" } } diff --git a/src/translations/es.json b/src/translations/es.json index a991c95..a9edb8b 100644 --- a/src/translations/es.json +++ b/src/translations/es.json @@ -75,6 +75,7 @@ "opening": "Abriendo", "closed": "Cerrada", "closing": "Cerrando", - "stopped": "Detenida" + "stopped": "Detenida", + "unclosed": "No Cerrada" } } diff --git a/src/translations/nl.json b/src/translations/nl.json index 45a1e2b..20357ab 100644 --- a/src/translations/nl.json +++ b/src/translations/nl.json @@ -75,6 +75,7 @@ "opening": "Openen", "closed": "Gesloten", "closing": "Sluiten", - "stopped": "Gestopt" + "stopped": "Gestopt", + "unclosed": "Niet gesloten" } } diff --git a/src/translations/pt-BR.json b/src/translations/pt-BR.json index 7b971fb..b333a05 100644 --- a/src/translations/pt-BR.json +++ b/src/translations/pt-BR.json @@ -75,6 +75,7 @@ "opening": "Abrindo", "closed": "Fechado", "closing": "Fechando", - "stopped": "Parado" + "stopped": "Parado", + "unclosed": "Nao fechado" } } diff --git a/src/types/strategy/strategy-generics.ts b/src/types/strategy/strategy-generics.ts index 3778db8..e5ebf56 100644 --- a/src/types/strategy/strategy-generics.ts +++ b/src/types/strategy/strategy-generics.ts @@ -37,6 +37,7 @@ const SUPPORTED_DOMAINS = [ 'sensor', 'switch', 'vacuum', + 'valve', ] as const; /** @@ -55,6 +56,7 @@ const SUPPORTED_VIEWS = [ 'scene', 'switch', 'vacuum', + 'valve', ] as const; /** diff --git a/src/views/ValveView.ts b/src/views/ValveView.ts new file mode 100644 index 0000000..efa1573 --- /dev/null +++ b/src/views/ValveView.ts @@ -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;