Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add power cosumption for switch state #206

Open
wants to merge 39 commits into
base: feat/name-state-template
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
00a210a
feat: add lock controller
Jun 16, 2021
9748d00
fix: reverse label
Jun 16, 2021
961b061
chore: reverse template feat
Jun 30, 2021
3865669
chore: update readme
Jun 30, 2021
9a2f130
Merge pull request #67 from mattieha/feat/climate-controller
mattieha Jun 30, 2021
3bf095b
1.9.0
Jun 30, 2021
a30f089
chore: update readme with examples
Jul 2, 2021
676637a
chore: update readme with full examples
Jul 2, 2021
a72c4bc
Merge pull request #85 from mattieha/chore/examples
mattieha Jul 2, 2021
9d25e01
Merge remote-tracking branch 'origin/main' into feat/lock-domain
Jul 2, 2021
5b7ab93
chore: update readme with lock examples
Jul 2, 2021
a5f63f1
Merge pull request #36 from mattieha/feat/lock-domain
mattieha Jul 2, 2021
c47e205
1.10.0
Jul 2, 2021
cf0c234
fix: gradient for ios and css vars on host
Jul 5, 2021
d02b202
Merge pull request #88 from mattieha/fix/css-misc
mattieha Jul 5, 2021
70aa0d4
1.10.1
Jul 5, 2021
db7d239
chore: add extra preview to readme
Jul 5, 2021
c16dd2c
chore: add Portuguese language
Jul 5, 2021
3417b3e
Merge pull request #89 from mattieha/chore/pt-translation
mattieha Jul 5, 2021
a6d8989
1.10.2
Jul 5, 2021
9ea1d91
add Korean translation
okhomeco Jul 7, 2021
60a5342
Create de.json
frauhottelmann Jul 7, 2021
85979f0
copy and paste english
frauhottelmann Jul 7, 2021
887e426
add German translation
frauhottelmann Jul 7, 2021
50846a6
chore: add group section to readme
Jul 7, 2021
4ae999a
Merge pull request #94 from JoshandNancy/chore
mattieha Jul 7, 2021
29a5df6
add German
frauhottelmann Jul 7, 2021
b96df39
add German
frauhottelmann Jul 7, 2021
dd9e046
Merge pull request #96 from frauhottelmann/main
mattieha Jul 7, 2021
85f8cb0
1.10.3
Jul 7, 2021
00d07a4
Create fr.json
PedroDelCargo Jul 12, 2021
90da80a
Update localize.ts
PedroDelCargo Jul 12, 2021
4b13eb0
Update README.md
PedroDelCargo Jul 12, 2021
3b83b51
Update README.md
mattieha Jul 14, 2021
77c2ead
Merge pull request #103 from PedroDelCargo/patch-1
mattieha Jul 14, 2021
271a203
Merge pull request #104 from PedroDelCargo/patch-4
mattieha Jul 14, 2021
3cf981a
Merge pull request #105 from PedroDelCargo/patch-5
mattieha Jul 14, 2021
f3bc694
chore(deps): bump path-parse from 1.0.6 to 1.0.7
dependabot[bot] Aug 13, 2021
877bc94
Merge pull request #117 from mattieha/dependabot/npm_and_yarn/path-pa…
mattieha Nov 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
597 changes: 574 additions & 23 deletions README.md

Large diffs are not rendered by default.

Binary file added assets/examples/action-custom-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/action-custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/action-minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/climate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/cover.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/fan.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/general-compact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/general-minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/icon-icon-override.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/icon-minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/lock.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/media.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/slider-force-square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/slider-minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/slider-show-track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/slider-state-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/examples/switch.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/preview-2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 95 additions & 57 deletions dist/slider-button-card.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slider-button-card",
"version": "1.8.0",
"version": "1.10.3",
"description": "Lovelace slider-button-card",
"keywords": [
"home-assistant",
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/get-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CoverController } from './cover-controller';
import { FanController } from './fan-controller';
import { InputBooleanController } from './input-boolean-controller';
import { LightController } from './light-controller';
import { LockController } from './lock-controller';
import { MediaController } from './media-controller';
import { SwitchController } from './switch-controller';

Expand All @@ -20,6 +21,7 @@ export class ControllerFactory {
[Domain.INPUT_BOOLEAN]: InputBooleanController,
[Domain.MEDIA_PLAYER]: MediaController,
[Domain.CLIMATE]: ClimateController,
[Domain.LOCK]: LockController,
};
if (typeof mapping[domain] === 'undefined') {
throw new Error(`Unsupported entity type: ${domain}`)
Expand Down
35 changes: 35 additions & 0 deletions src/controllers/lock-controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { STATES_OFF } from 'custom-card-helpers';
import { Controller } from './controller';

export class LockController extends Controller {
_min = 0;
_max = 1;
_targetValue;
_invert = false;

get _value(): number {
return !STATES_OFF.includes(this.stateObj.state)
? 1
: 0;
}

set _value(value) {
const service = value > 0 ? 'lock' : 'unlock';
this._hass.callService('lock', service, {
// eslint-disable-next-line @typescript-eslint/camelcase
entity_id: this.stateObj.entity_id
});
}

get _step(): number {
return 1;
}

get label(): string {
if (this.percentage > 0) {
return this._hass.localize('component.lock.state._.unlocked');
}
return this._hass.localize('component.lock.state._.locked');
}

}
62 changes: 62 additions & 0 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"common": {
"version": "v",
"invalid_configuration": "Ungültige Konfiguration",
"show_warning": "Zeige Warnung",
"show_error": "Zeige Fehler"
},
"tabs": {
"general": {
"title": "Allgemein",
"entity": "Entiät (vorgeschrieben)",
"name": "Name (optional)",
"show_name": "Namen zeigen?",
"show_state": "Zustand zeigen?",
"compact": "Kompakt?"
},
"icon": {
"title": "Icon",
"icon": "Icon (optional)",
"show_icon": "Icon zeigen?",
"use_state_color": "Zustandsfarbe verwenden?",
"tap_action": "Tap action"
},
"slider": {
"title": "Schieberegler",
"direction": "Richtung",
"background": "Hintergrund",
"use_brightness": "Helligkeit benutzen?",
"show_track": "Spur anzeigen?",
"toggle_on_click": "Als Schalter benutzen (schieben deaktivieren)",
"force_square": "Quadrat erzwingen?"
},
"action_button": {
"title": "Action-Knopf",
"mode": "Modus",
"icon": "Icon",
"show_button": "Knopf zeigen?",
"show_spinner": "Spinner anzeigen?",
"tap_action": "Tap action"
}
},
"state": {
"off": "Aus",
"on": "An"
},
"direction": {
"left-right": "Links nach Rechts",
"top-bottom": "Oben nach Unten",
"bottom-top": "Unten nach Oben"
},
"background": {
"striped": "gestreift",
"gradient": "Farbverlauf",
"solid": "Einfarbig",
"triangle": "Dreieck",
"custom": "benuzerdefiniert"
},
"mode": {
"toggle": "Umschalter",
"custom": "benuzerdefiniert"
}
}
62 changes: 62 additions & 0 deletions src/localize/languages/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"common": {
"version": "v",
"invalid_configuration": "Configuration incorrecte",
"show_warning": "Afficher les avertissement",
"show_error": "Afficher les erreurs"
},
"tabs": {
"general": {
"title": "Général",
"entity": "Entité (Obligatoire)",
"name": "Nom (Optionnel)",
"show_name": "Afficher le nom ?",
"show_state": "Afficher l'état ?",
"compact": "Compact ?"
},
"icon": {
"title": "Icône",
"icon": "Icône (Optionnel)",
"show_icon": "Afficher l'icône ?",
"use_state_color": "Afficher la couleur d'état?",
"tap_action": "Action"
},
"slider": {
"title": "Curseur",
"direction": "Direction",
"background": "Fond",
"use_brightness": "Utiliser la luminosité ?",
"show_track": "Afficher le chemin ?",
"toggle_on_click": "Agir comme un bouton (désactive le curseur)",
"force_square": "Forcer carré ?"
},
"action_button": {
"title": "Bouton d'action",
"mode": "Mode",
"icon": "Icône",
"show_button": "Afficher le bouton ?",
"show_spinner": "Afficher spinner ?",
"tap_action": "Action"
}
},
"state": {
"off": "Inactif",
"on": "Actif"
},
"direction": {
"left-right": "gauche à droite",
"top-bottom": "haut à bas",
"bottom-top": "Bas à haut"
},
"background": {
"striped": "Rayures",
"gradient": "Dégradé",
"solid": "Uni",
"triangle": "Triangle",
"custom": "Personnalisé"
},
"mode": {
"toggle": "Bascule",
"custom": "Personnalisé"
}
}
63 changes: 63 additions & 0 deletions src/localize/languages/ko.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"common": {
"version": "v",
"invalid_configuration": "유효하지 않은 설정입니다",
"show_warning": "경고 표시",
"show_error": "에러 표시"
},
"tabs": {
"general": {
"title": "일반",
"entity": "구성 요소 (필수)",
"name": "이름 (옵션)",
"show_name": "이름 표시",
"show_state": "상태 표시",
"compact": "슬림 모드"
},
"icon": {
"title": "아이콘",
"icon": "아이콘 (옵션)",
"show_icon": "아이콘 표시",
"use_state_color": "상태 색상 사용",
"tap_action": "탭 액션"
},
"slider": {
"title": "슬라이더",
"direction": "방향 지정",
"background": "배경",
"use_brightness": "밝기 사용",
"show_track": "범위 표시",
"toggle_on_click": "토글 버튼으로 동작(슬라이더 비활성화)",
"force_square": "정사각형 모양으로 고정"
},
"action_button": {
"title": "액션 버튼",
"mode": "모드",
"icon": "아이콘",
"show_button": "버튼 표시",
"show_spinner": "로딩 스피너 표시",
"tap_action": "탭 액셥"
}
},
"state": {
"off": "꺼짐",
"on": "켜짐"
},
"direction": {
"left-right": "왼쪽에서 오른쪽",
"top-bottom": "위에서 아래",
"bottom-top": "아래에서 위"
},
"background": {
"striped": "줄무늬",
"gradient": "그레디언트",
"solid": "단색",
"triangle": "삼각형",
"custom": "커스텀"
},
"mode": {
"toggle": "토글 모드",
"custom": "커스텀 모드"
}
}

62 changes: 62 additions & 0 deletions src/localize/languages/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"common": {
"version": "v",
"invalid_configuration": "Configuração Inválida",
"show_warning": "Mostrar Aviso",
"show_error": "Mostrar Erro"
},
"tabs": {
"general": {
"title": "Geral",
"entity": "Entidade (Obrigatório)",
"name": "Nome (Opcional)",
"show_name": "Mostrar Nome?",
"show_state": "Mostrar Estado?",
"compact": "Compactar?"
},
"icon": {
"title": "Ícone",
"icon": "Ícone (Opcional)",
"show_icon": "Mostrar Ícone?",
"use_state_color": "Usar Cor de Estado?",
"tap_action": "Ação de Toque"
},
"slider": {
"title": "Slider",
"direction": "Direção",
"background": "Fundo",
"use_brightness": "Usar Brilho?",
"show_track": "Mostrar Acompanhamento?",
"toggle_on_click": "Atua como um alternador (desative o deslizamento)",
"force_square": "Forçar Quadrado?"
},
"action_button": {
"title": "Botão de Ação",
"mode": "Modo",
"icon": "Ícone",
"show_button": "Mostrar Botão?",
"show_spinner": "Mostrar Spinner?",
"tap_action": "Ação de Toque"
}
},
"state": {
"off": "Desligar",
"on": "Ligar"
},
"direction": {
"left-right": "Esquerda para a Direita",
"top-bottom": "De Cima para Baixo",
"bottom-top": "De Baixo para Cima"
},
"background": {
"striped": "Listrado",
"gradient": "Gradiente",
"solid": "Sólido",
"triangle": "Triângulo",
"custom": "Personalizado"
},
"mode": {
"toggle": "Alternancia",
"custom": "Personalizado"
}
}
9 changes: 9 additions & 0 deletions src/localize/localize.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import * as en from './languages/en.json';
import * as de from './languages/de.json';
import * as fr from './languages/fr.json';
import * as he from './languages/he.json';
import * as nl from './languages/nl.json';
import * as pl from './languages/pl.json';
import * as pt from './languages/pt.json';
import * as ru from './languages/ru.json';
import * as ko from './languages/ko.json';



// eslint-disable-next-line @typescript-eslint/no-explicit-any
const languages: any = {
en: en,
de: de,
fr: fr,
he: he,
nl: nl,
pl: pl,
pt: pt,
ru: ru,
ko: ko,
};

export function localize(string: string, search = '', replace = ''): string {
Expand Down
Loading
Loading