Skip to content

Commit

Permalink
add cover set_position to standard configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
niels committed Sep 19, 2020
1 parent 5cb3dff commit dc44f9b
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 38 deletions.
18 changes: 9 additions & 9 deletions dist/scheduler-card.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions src/config-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ export class Config {
action = { ...action };
if (getDomainFromEntityId(action['service']) == domain) action = Object.assign(action, { service: action['service'].split('.').pop() });
if (domain == "light" && entity.attributes.hasOwnProperty('supported_features')) {
let isDimmable = entity.attributes['supported_features'] & 0b1;
if (!isDimmable && action['variable']) delete action['variable'];
let SUPPORT_BRIGHTNESS = entity.attributes['supported_features'] & 1;
if (!SUPPORT_BRIGHTNESS && action['variable']) delete action['variable'];
}
else if (domain == "cover" && entity.attributes.hasOwnProperty('supported_features')) {
let SUPPORT_POSITION = entity.attributes['supported_features'] & 4;
if (!SUPPORT_POSITION && action['variable']) return null;
}
return this.CreateAction(action)
});
actions = filter(actions, el => el); //remove null elements
each(actions, e => entityActions.push(e));
}
}
Expand All @@ -218,11 +223,16 @@ export class Config {
action = { ...action };
if (getDomainFromEntityId(action['service']) == domain) action = Object.assign(action, { service: action['service'].split('.').pop() });
if (domain == "light" && entity.attributes.hasOwnProperty('supported_features')) {
let isDimmable = entity.attributes['supported_features'] & 0b1;
if (!isDimmable && action['variable']) delete action['variable'];
let SUPPORT_BRIGHTNESS = entity.attributes['supported_features'] & 1;
if (!SUPPORT_BRIGHTNESS && action['variable']) delete action['variable'];
}
else if (domain == "cover" && entity.attributes.hasOwnProperty('supported_features')) {
let SUPPORT_POSITION = entity.attributes['supported_features'] & 4;
if (!SUPPORT_POSITION && action['variable']) return null;
}
return this.CreateAction(action)
});
actions = filter(actions, el => el); //remove null elements
each(actions, e => entityActions.push(e));
}
skip_entity = false;
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { IUserSelection, IUserConfig } from './types'
import { parseTimestamp } from './date-time'

export const CARD_VERSION = "1.3.0"
export const CARD_VERSION = "1.3.1"


export const DefaultUserSelection: IUserSelection = {
Expand Down
16 changes: 16 additions & 0 deletions src/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const defaultDomainConfig: IDictionary<IDomainConfig> = {
service: "close_cover",
name: localize('services.close_cover')
},
{
service: "set_cover_position",
name: localize('services.set_position'),
variable: { field: "position" }
},
]
},
climate: {
Expand Down Expand Up @@ -124,6 +129,7 @@ export function getIconForAction(action: string): string {
else if (action == 'open_cover') return 'window-shutter-open';
else if (action == 'close_cover') return 'window-shutter';
else if (action == 'set_temperature') return 'thermometer';
else if (action == 'set_cover_position') return 'window-shutter';
return 'flash';
}

Expand All @@ -133,6 +139,7 @@ export function getNameForService(service: string): string {
else if (service == 'open_cover') return localize('services.open_cover')
else if (service == 'close_cover') return localize('services.close_cover')
else if (service == 'set_temperature') return localize('services.set_temperature')
else if (service == 'set_cover_position') return localize('services.set_position')
if (service.indexOf('.') !== -1) return service.split('.').pop()!;
return service;
}
Expand All @@ -157,6 +164,15 @@ export function getDefaultActionVariableConfig(field_name: string): object {
optional: false,
show_percentage: false
},
position: {
name: localize('fields.position'),
unit: "",
min: 0,
max: 255,
step: 1,
optional: false,
show_percentage: true
},
default: {
name: field_name,
unit: "",
Expand Down
6 changes: 4 additions & 2 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "benutzerdefiniert",
"shift_with_sun": "Zeit automatisch an Sonnenauf- bzw. Sonnenuntergang anpassen",
"brightness": "Helligkeit",
"temperature": "Temperatur"
"temperature": "Temperatur",
"position": "Position"
},
"days_short": {
"mon": "Mo",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "schließen",
"open_cover": "öffnen",
"set_temperature": "Temperatur einstellen",
"set_to": "setzen auf"
"set_to": "setzen auf",
"set_position": "Position setzen"
},
"domains": {
"climate": "Heizung",
Expand Down
6 changes: 4 additions & 2 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "custom",
"shift_with_sun": "automatically adjust time to sunrise/sunset",
"brightness": "Brightness",
"temperature": "Temperature"
"temperature": "Temperature",
"position": "Position"
},
"days_short": {
"mon": "mon",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "close",
"open_cover": "open",
"set_temperature": "set temperature",
"set_to": "set to"
"set_to": "set to",
"set_position": "set position"
},
"domains": {
"climate": "climate",
Expand Down
6 changes: 4 additions & 2 deletions src/localize/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "personalizado",
"shift_with_sun": "ajusta automaticamente la hora al amanecer/atardecer",
"brightness": "Brillo",
"temperature": "Temperatura"
"temperature": "Temperatura",
"position": "Posición"
},
"days_short": {
"mon": "lun",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "cerrar",
"open_cover": "abrir",
"set_temperature": "establecer temperatura",
"set_to": "establecer a"
"set_to": "establecer a",
"set_position": "posición de ajuste"
},
"domains": {
"climate": "climatización",
Expand Down
8 changes: 5 additions & 3 deletions src/localize/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "sur mesure",
"shift_with_sun": "ajuster automatiquement l'heure au lever/coucher du soleil",
"brightness": "Luminosité",
"temperature": "Température"
"temperature": "Température",
"position": "Position"
},
"days_short": {
"mon": "lun",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "fermer",
"open_cover": "ouvrir",
"set_temperature": "régler la température",
"set_to": "défini à"
"set_to": "défini à",
"set_position": "position définie"
},
"domains": {
"climate": "climat",
Expand All @@ -73,4 +75,4 @@
"switch": "interrupteurs",
"vacuum": "aspirateur"
}
}
}
8 changes: 5 additions & 3 deletions src/localize/languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "egyedi",
"shift_with_sun": "Az idő automatikus igazítása napkeltéhez/naplementéhez",
"brightness": "Fényerő",
"temperature": "Hőmérséklet"
"temperature": "Hőmérséklet",
"position": "Pozíciót"
},
"days_short": {
"mon": "hét",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "zárás",
"open_cover": "nyitás",
"set_temperature": "hőmérséklet",
"set_to": "beállítva"
"set_to": "beállítva",
"set_position": "változtass pozíciót"
},
"domains": {
"climate": "termosztát",
Expand All @@ -73,4 +75,4 @@
"switch": "kapcsoló",
"vacuum": "pórszívó"
}
}
}
6 changes: 4 additions & 2 deletions src/localize/languages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "Anders",
"shift_with_sun": "Automatisch aanpassen aan zonsopgang/zonsondergang",
"brightness": "Helderheid",
"temperature": "Temperatuur"
"temperature": "Temperatuur",
"position": "Positie"
},
"days_short": {
"mon": "ma",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "sluiten",
"open_cover": "openen",
"set_temperature": "temperatuur instellen",
"set_to": "Zet op"
"set_to": "Zet op",
"set_position": "positie instellen"
},
"domains": {
"climate": "verwarming",
Expand Down
6 changes: 4 additions & 2 deletions src/localize/languages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "egendefinert",
"shift_with_sun": "automatisk juster tid for soloppgang/solnedgang",
"brightness": "Lysstyrke",
"temperature": "Temperatur"
"temperature": "Temperatur",
"position": "Posisjon"
},
"days_short": {
"mon": "man",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "lukk",
"open_cover": "åpne",
"set_temperature": "sett temperatur",
"set_to": "sett til"
"set_to": "sett til",
"set_position": "sett posisjon"
},
"domains": {
"climate": "klima",
Expand Down
6 changes: 4 additions & 2 deletions src/localize/languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "niestandardowy",
"shift_with_sun": "automatycznie dopasuj czas do wschodów/zachodów",
"brightness": "Jasność",
"temperature": "Temperatura"
"temperature": "Temperatura",
"position": "Pozycję"
},
"days_short": {
"mon": "pon",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "zamknij",
"open_cover": "otwórz",
"set_temperature": "Ustaw temperaturę",
"set_to": "ustaw na"
"set_to": "ustaw na",
"set_position": "Ustaw pozycję"
},
"domains": {
"climate": "termostat",
Expand Down
8 changes: 5 additions & 3 deletions src/localize/languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "personalizado",
"shift_with_sun": "automaticamente ajusta hora pelo nascer do sol/pôr do sol",
"brightness": "Brilho",
"temperature": "Temperatura"
"temperature": "Temperatura",
"position": "Posição"
},
"days_short": {
"mon": "seg",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "fechar",
"open_cover": "abrir",
"set_temperature": "ajustar temperatura",
"set_to": "ajustar para"
"set_to": "ajustar para",
"set_position": "ajustar posição"
},
"domains": {
"climate": "ar condicionado",
Expand All @@ -73,4 +75,4 @@
"switch": "interruptor",
"vacuum": "aspirador"
}
}
}
6 changes: 4 additions & 2 deletions src/localize/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"day_type_custom": "выбрать дни",
"shift_with_sun": "автоматически настраивать время на восход / закат",
"brightness": "Яркость",
"temperature": "Температура"
"temperature": "Температура",
"position": "Позицию"
},
"days_short": {
"mon": "пн",
Expand Down Expand Up @@ -63,7 +64,8 @@
"close_cover": "закрыть",
"open_cover": "открыть",
"set_temperature": "задать температуру",
"set_to": "установить"
"set_to": "установить",
"set_position": "установить позицию"
},
"domains": {
"climate": "Климат",
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class SchedulerCard extends LitElement {

let unit = cfg.hasOwnProperty('unit') ? cfg.unit : "";

if (cfg.showPercentage) {
if (cfg.show_percentage) {
value = Math.round(((value - cfg.min) / (cfg.max - cfg.min)) * 100);
if (value < cfg.min) value = cfg.min;
else if (value > cfg.max) value = cfg.max;
Expand Down

0 comments on commit dc44f9b

Please sign in to comment.