mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-04 20:14:28 +02:00
57
src/cards/ValveCard.ts
Normal file
57
src/cards/ValveCard.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
|
||||
import { EntityRegistryEntry } from '../types/homeassistant/data/entity_registry';
|
||||
import { TemplateCardConfig } from '../types/lovelace-mushroom/cards/template-card-config';
|
||||
import { localize } from '../utilities/localize';
|
||||
import AbstractCard from './AbstractCard';
|
||||
|
||||
/**
|
||||
* Valve Card Class
|
||||
*
|
||||
* Used to create a card configuration to control an entity of the valve domain.
|
||||
*/
|
||||
class ValveCard extends AbstractCard {
|
||||
/** Returns the default configuration object for the card. */
|
||||
static getDefaultConfig(): TemplateCardConfig {
|
||||
return {
|
||||
type: 'custom:mushroom-template-card',
|
||||
icon: 'mdi:valve',
|
||||
icon_color: 'blue',
|
||||
double_tap_action: {
|
||||
action: 'toggle',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param {EntityRegistryEntry} entity The HASS entity to create a card configuration for.
|
||||
* @param {VacuumCardConfig} [customConfiguration] Custom card configuration.
|
||||
*/
|
||||
constructor(entity: EntityRegistryEntry, customConfiguration?: TemplateCardConfig) {
|
||||
super(entity);
|
||||
|
||||
// Initialize the default configuration.
|
||||
const configuration = ValveCard.getDefaultConfig();
|
||||
|
||||
configuration.entity = entity.entity_id;
|
||||
configuration.icon = entity.icon ?? configuration.icon;
|
||||
configuration.primary = entity.name ?? entity.original_name ?? '?';
|
||||
configuration.secondary = `{%
|
||||
set mapping = {
|
||||
'open': '${localize('valve.open')}',
|
||||
'opening': '${localize('valve.opening')}',
|
||||
'closed': '${localize('valve.closed')}',
|
||||
'closing': '${localize('valve.closing')}',
|
||||
'stopped': '${localize('valve.stopped')}',
|
||||
'unavailable': '${localize('generic.unavailable')}'
|
||||
}
|
||||
%}
|
||||
{{ mapping.get(states('${entity.entity_id}'), '${localize('generic.unknown')}') }}`;
|
||||
|
||||
this.configuration = { ...this.configuration, ...configuration, ...customConfiguration };
|
||||
}
|
||||
}
|
||||
|
||||
export default ValveCard;
|
@@ -29,8 +29,10 @@
|
||||
"off": "Aus",
|
||||
"on": "Ein",
|
||||
"open": "Offen",
|
||||
"unavailable": "Nicht verfügbar",
|
||||
"unclosed": "Nicht Geschlossen",
|
||||
"undisclosed": "Sonstiges"
|
||||
"undisclosed": "Sonstiges",
|
||||
"unknown": "Unbekannt"
|
||||
},
|
||||
"input_select": {
|
||||
"input_selects": "Auswahl-Eingaben"
|
||||
@@ -65,5 +67,14 @@
|
||||
"vacuum": {
|
||||
"all_vacuums": "Alle Staubsauger",
|
||||
"vacuums": "Staubsauger"
|
||||
},
|
||||
"valve": {
|
||||
"all_valves": "Alle Ventile",
|
||||
"valves": "Ventile",
|
||||
"open": "Offen",
|
||||
"opening": "Öffnet",
|
||||
"closed": "Geschlossen",
|
||||
"closing": "Schließt",
|
||||
"stopped": "Gestoppt"
|
||||
}
|
||||
}
|
||||
|
@@ -29,8 +29,10 @@
|
||||
"off": "Off",
|
||||
"on": "On",
|
||||
"open": "Open",
|
||||
"unavailable": "Unavailable",
|
||||
"unclosed": "Unclosed",
|
||||
"undisclosed": "Other"
|
||||
"undisclosed": "Other",
|
||||
"unknown": "Unknown"
|
||||
},
|
||||
"input_select": {
|
||||
"input_selects": "Input Selects"
|
||||
@@ -65,5 +67,14 @@
|
||||
"vacuum": {
|
||||
"all_vacuums": "All Vacuums",
|
||||
"vacuums": "Vacuums"
|
||||
},
|
||||
"valve": {
|
||||
"all_valves": "All Valves",
|
||||
"valves": "Valves",
|
||||
"open": "Open",
|
||||
"opening": "Opening",
|
||||
"closed": "Closed",
|
||||
"closing": "Closing",
|
||||
"stopped": "Stopped"
|
||||
}
|
||||
}
|
||||
|
@@ -29,8 +29,10 @@
|
||||
"off": "Apagado",
|
||||
"on": "Encendido",
|
||||
"open": "Abierto",
|
||||
"unavailable": "No Disponible",
|
||||
"unclosed": "Sin Cerrar",
|
||||
"undisclosed": "Varios"
|
||||
"undisclosed": "Varios",
|
||||
"unknown": "Desconocido"
|
||||
},
|
||||
"input_select": {
|
||||
"input_selects": "Selecciones de Entrada"
|
||||
@@ -65,5 +67,14 @@
|
||||
"vacuum": {
|
||||
"all_vacuums": "Todas las Aspiradoras",
|
||||
"vacuums": "Aspiradoras"
|
||||
},
|
||||
"valve": {
|
||||
"all_valves": "Todas las válvulas",
|
||||
"valves": "Válvulas",
|
||||
"open": "Abierta",
|
||||
"opening": "Abriendo",
|
||||
"closed": "Cerrada",
|
||||
"closing": "Cerrando",
|
||||
"stopped": "Detenida"
|
||||
}
|
||||
}
|
||||
|
@@ -29,8 +29,10 @@
|
||||
"off": "Uit",
|
||||
"on": "Aan",
|
||||
"open": "Open",
|
||||
"unavailable": "Onbeschikbaar",
|
||||
"unclosed": "Ongesloten",
|
||||
"undisclosed": "Overige"
|
||||
"undisclosed": "Overige",
|
||||
"unknown": "Onbekend"
|
||||
},
|
||||
"input_select": {
|
||||
"input_selects": "Lijsten"
|
||||
@@ -65,5 +67,14 @@
|
||||
"vacuum": {
|
||||
"all_vacuums": "Alle Afzuiging",
|
||||
"vacuums": "Afzuiging"
|
||||
},
|
||||
"valve": {
|
||||
"all_valves": "Alle kleppen",
|
||||
"valves": "Kleppen",
|
||||
"open": "Open",
|
||||
"opening": "Openen",
|
||||
"closed": "Gesloten",
|
||||
"closing": "Sluiten",
|
||||
"stopped": "Gestopt"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user