mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-01 02:44:27 +02:00
Add Valve view
This commit is contained in:
@@ -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: [],
|
||||
};
|
||||
|
@@ -75,6 +75,7 @@
|
||||
"opening": "Öffnet",
|
||||
"closed": "Geschlossen",
|
||||
"closing": "Schließt",
|
||||
"stopped": "Gestoppt"
|
||||
"stopped": "Gestoppt",
|
||||
"unclosed": "Nicht geschlossen"
|
||||
}
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@
|
||||
"opening": "Opening",
|
||||
"closed": "Closed",
|
||||
"closing": "Closing",
|
||||
"stopped": "Stopped"
|
||||
"stopped": "Stopped",
|
||||
"unclosed": "Unclosed"
|
||||
}
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@
|
||||
"opening": "Abriendo",
|
||||
"closed": "Cerrada",
|
||||
"closing": "Cerrando",
|
||||
"stopped": "Detenida"
|
||||
"stopped": "Detenida",
|
||||
"unclosed": "No Cerrada"
|
||||
}
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@
|
||||
"opening": "Openen",
|
||||
"closed": "Gesloten",
|
||||
"closing": "Sluiten",
|
||||
"stopped": "Gestopt"
|
||||
"stopped": "Gestopt",
|
||||
"unclosed": "Niet gesloten"
|
||||
}
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@
|
||||
"opening": "Abrindo",
|
||||
"closed": "Fechado",
|
||||
"closing": "Fechando",
|
||||
"stopped": "Parado"
|
||||
"stopped": "Parado",
|
||||
"unclosed": "Nao fechado"
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
|
56
src/views/ValveView.ts
Normal file
56
src/views/ValveView.ts
Normal 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;
|
Reference in New Issue
Block a user