Compare commits

..

3 Commits

Author SHA1 Message Date
Zack Arnett
39200b62d5 Fix custom vlaue 2020-11-17 13:22:28 -06:00
Zack Arnett
0eb28ea733 comment 2020-11-17 11:58:32 -06:00
Zack Arnett
62d471888f Only allow selectable attributes in dropdown 2020-11-15 16:18:58 -06:00
17 changed files with 102 additions and 1291 deletions

View File

@@ -1,27 +0,0 @@
# Vite
Vite is a new type of compiler that compiles each file as they come in.
## Running Vite
- Checkout this branch
- `yarn`
- Run `script/develop` until it finishes first webpack build. Then turn it off. We use this right now to prepare the static files + auth/onboarding pages.
- Update `hass_frontend/index.html`, find where we import the scripts and replace with:
```html
<script>
// Define in vite config doesn't work.
window.__DEV__ = true;
window.__DEMO__ = false;
window.__BACKWARDS_COMPAT__ = false;
window.__BUILD__ = "latest";
window.__VERSION__ = "dev";
// Temporary to stop an error
document.adoptedStyleSheets = [];
// Load scripts from Vite dev server
import("http://localhost:3000/src/entrypoints/core.ts");
import("http://localhost:3000/src/entrypoints/app.ts");
```
If Vite transforms would work correctly, we would just have to drop the "use-credentials" part in dev and update the import URLs to import from Vite dev server.
- Start vite `vite serve -c build-scripts/vite/vite.config.ts`
- Open Home Assistant as usual.

View File

@@ -1,61 +0,0 @@
import * as path from "path";
import * as vite from "vite";
// https://github.com/vitejs/vite/blob/master/src/node/config.ts
const ignore = new Set(["/src/resources/compatibility.ts"]);
const conf: vite.ServerConfig = {
root: path.resolve(__dirname, "../.."),
optimizeDeps: {
// We don't automatically optimize dependencies because
// that causes duplicate imports of custom elements
auto: false,
},
resolvers: [
// This resolver is meant to filter out files that we don't
// need in latest build, like compatibility.
// But resolving it to an empty file doesn't yield expected
// results.
// {
// requestToFile(publicPath: string, root: string) {
// console.log("requestToFile", {
// publicPath,
// root,
// match: ignore.has(publicPath),
// resolved:
// ignore.has(publicPath) &&
// path.resolve(conf.root!, "src/util/empty.js"),
// });
// if (ignore.has(publicPath)) {
// return path.resolve(conf.root!, "src/util/empty.js");
// }
// return undefined;
// },
// fileToRequest(filePath: string, root: string) {
// if (!filePath.endsWith("/src/util/empty.js")) {
// return undefined;
// }
// console.log("fileToRequest", {
// filePath,
// root,
// match: filePath.endsWith("/src/util/empty.js"),
// });
// return "/src/util/empty.js";
// },
// },
],
// These don't seem to be picked up. Workaround is to manually
// add them to hass_frontend/index.html for now.
define: {
__DEV__: true,
__BUILD__: "latest",
__VERSION__: "dev",
__DEMO__: false,
__BACKWARDS_COMPAT__: false,
__STATIC_PATH__: "/static/",
},
cors: true,
};
console.log(conf);
export default conf;

View File

@@ -90,6 +90,7 @@
"codemirror": "^5.49.0",
"comlink": "^4.3.0",
"core-js": "^3.6.5",
"cpx": "^1.5.0",
"cropperjs": "^1.5.7",
"deep-clone-simple": "^1.1.1",
"deep-freeze": "^0.0.1",
@@ -161,7 +162,6 @@
"@typescript-eslint/parser": "^4.4.0",
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"cpx": "^1.5.0",
"del": "^4.0.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-typescript": "^7.2.1",
@@ -209,7 +209,6 @@
"typescript": "^4.0.3",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"vite": "^1.0.0-rc.9",
"webpack": "5.1.3",
"webpack-cli": "4.1.0",
"webpack-dev-server": "^3.11.0",

View File

@@ -1,3 +1,4 @@
import "@material/mwc-icon-button/mwc-icon-button";
import { mdiClose, mdiMenuDown, mdiMenuUp } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import "@polymer/paper-item/paper-item";
@@ -14,13 +15,14 @@ import {
query,
TemplateResult,
} from "lit-element";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
import { computeDomain } from "../../common/entity/compute_domain";
import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types";
import { formatAttributeName } from "../../util/hass-attributes-util";
import "../ha-svg-icon";
import "./state-badge";
import { formatAttributeName } from "../../util/hass-attributes-util";
import "@material/mwc-icon-button/mwc-icon-button";
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
@@ -41,6 +43,41 @@ const rowRenderer = (root: HTMLElement, _owner, model: { item: string }) => {
);
};
const SELECTABLE_ATTRIBUTES: { [key: string]: string[] } = {
light: ["brightness"],
climate: [
"current_temperature",
"fan_mode",
"preset_mode",
"swing_mode",
"temperature",
"current_hundity",
"humidity",
"hvac_action",
],
fan: ["speed"],
air_quality: [
"nitrogen_oxide",
"particulate_matter_10",
"particulate_matter_2_5",
],
cover: ["current_position", "current_tilt_position"],
device_tracker: ["battery"],
humidifier: ["humidty"],
media_player: ["media_title"],
vacuum: ["battery_level", "status"],
water_heater: ["current_temperature", "temperature", "operation_mode"],
weather: [
"temperature",
"humidity",
"ozone",
"pressure",
"wind_bearing",
"wind_speed",
"visibility",
],
};
@customElement("ha-entity-attribute-picker")
class HaEntityAttributePicker extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -68,9 +105,8 @@ class HaEntityAttributePicker extends LitElement {
protected updated(changedProps: PropertyValues) {
if (changedProps.has("_opened") && this._opened) {
const state = this.entityId ? this.hass.states[this.entityId] : undefined;
(this._comboBox as any).items = state
? Object.keys(state.attributes)
(this._comboBox as any).items = this.entityId
? this._selectableAttributes(this.entityId)
: [];
}
}
@@ -85,7 +121,6 @@ class HaEntityAttributePicker extends LitElement {
.value=${this._value}
.allowCustomValue=${this.allowCustomValue}
.renderer=${rowRenderer}
attr-for-value="bind-value"
@opened-changed=${this._openedChanged}
@value-changed=${this._valueChanged}
>
@@ -137,6 +172,17 @@ class HaEntityAttributePicker extends LitElement {
`;
}
private _selectableAttributes = memoizeOne((entity: string) => {
const stateObj = this.hass.states[entity];
if (!stateObj) {
return [];
}
return Object.keys(stateObj.attributes).filter((attr) =>
SELECTABLE_ATTRIBUTES[computeDomain(entity)].includes(attr)
);
});
private _clearValue(ev: Event) {
ev.stopPropagation();
this._setValue("");

View File

@@ -115,6 +115,7 @@ export class HuiEntityCardEditor extends LitElement
</div>
<div class="side-by-side">
<ha-entity-attribute-picker
allow-custom-value
.hass=${this.hass}
.entityId=${this._entity}
.label="${this.hass.localize(

View File

@@ -10,7 +10,8 @@ Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import { AppStorageBehavior } from "@polymer/app-storage/app-storage-behavior";
import { Polymer } from "@polymer/polymer/polymer-legacy";
import { Polymer } from "@polymer/polymer/lib/legacy/polymer-fn";
import "@polymer/polymer/polymer-legacy";
/**
* app-localstorage-document synchronizes storage between an in-memory

View File

@@ -584,7 +584,7 @@
"entries_not_found": "No s'han trobat entrades al registre.",
"messages": {
"became_unavailable": "no està disponible",
"changed_to_state": "ha canviat a {state}",
"changed_to_state": "a canviat a {state}",
"cleared_device_class": "s'ha esborrat (no s'ha detectat cap {device_class})",
"detected_device_class": "s'ha detectat {device_class}",
"rose": "rosa",

View File

@@ -320,7 +320,7 @@
"hail": "Grêle",
"lightning": "Orage",
"lightning-rainy": "Orage / Pluvieux",
"partlycloudy": "Éclaircies",
"partlycloudy": "Partiellement nuageux",
"pouring": "Averses",
"rainy": "Pluvieux",
"snowy": "Neigeux",

View File

@@ -585,8 +585,8 @@
"messages": {
"became_unavailable": "elérhetetlenné vált",
"changed_to_state": "állapota megváltozott: {state}",
"cleared_device_class": "{device_class} észlelés befejeződött",
"detected_device_class": "{device_class} észlelve",
"cleared_device_class": "{device_class} érzékelés befejeződött",
"detected_device_class": "{device_class}-t érzékelt",
"rose": "felkelt",
"set": "lenyugodott",
"turned_off": "ki lett kapcsolva",
@@ -805,9 +805,7 @@
"more_info_control": {
"controls": "Vezérlők",
"cover": {
"close_cover": "Árnyékoló zárása",
"close_tile_cover": "Árnyékoló döntésének zárása",
"open_cover": "Árnyékoló nyitása",
"open_tilt_cover": "Árnyékoló döntésének nyitása",
"stop_cover": "Árnyékoló mozgásának leállítása"
},
@@ -1743,7 +1741,6 @@
"info": {
"built_using": "Buildelve:",
"caption": "Infó",
"copy_github": "A GitHub számára",
"copy_raw": "Nyers szöveg",
"custom_uis": "Egyéni felhasználói felületek:",
"description": "Telepítési információ megtekintése a Home Assistant-ról",

View File

@@ -1743,8 +1743,6 @@
"info": {
"built_using": "Bygget med",
"caption": "Informasjon",
"copy_github": "",
"copy_raw": "Rå tekst",
"custom_uis": "Tilpassede brukergrensesnitt:",
"description": "Vise informasjon om installasjonen av Home Assistant",
"developed_by": "Utviklet av en gjeng med fantastiske mennesker.",

View File

@@ -1743,8 +1743,6 @@
"info": {
"built_using": "Gebouwd met behulp van",
"caption": "Info",
"copy_github": "Voor GitHub",
"copy_raw": "Ruwe tekst",
"custom_uis": "Aangepaste UI's:",
"description": "Informatie over je Home Assistant installatie",
"developed_by": "Ontwikkeld door een stel geweldige mensen.",

View File

@@ -367,7 +367,7 @@
},
"climate": {
"aux_heat": "Дополнительный нагрев",
"away_mode": "Режим \"не дома\"",
"away_mode": "Режим ожидания",
"cooling": "{name} охлаждение",
"current_temperature": "{name} текущая температура",
"currently": "Сейчас",
@@ -514,7 +514,7 @@
"disable": "Отключить",
"enable": "Включить",
"error_required": "Обязательное поле",
"leave": "Выйти",
"leave": "Покинуть",
"loading": "Загрузка",
"menu": "Меню",
"next": "Далее",
@@ -1756,15 +1756,9 @@
"system_health": {
"checks": {
"cloud": {
"alexa_enabled": "Интеграция с Alexa",
"can_reach_cert_server": "Доступ к серверу сертификатов",
"can_reach_cloud": "Доступ к Home Assistant Cloud",
"can_reach_cloud_auth": "Доступ к серверу аутентификации",
"google_enabled": "Интеграция с Google",
"logged_in": "Вход в систему",
"relayer_connected": "Relayer подключен",
"remote_connected": "Удалённый доступ подключен",
"remote_enabled": "Удалённый доступ активирован",
"subscription_expiration": "Срок действия подписки"
},
"homeassistant": {

View File

@@ -805,9 +805,7 @@
"more_info_control": {
"controls": "Kontrolniki",
"cover": {
"close_cover": "Zapri pokrov",
"close_tile_cover": "Zapri nagib pokrova",
"open_cover": "Odpri pokrov",
"open_tilt_cover": "Odpri nagib pokrova",
"stop_cover": "Zaustavite premikanje pokrova"
},
@@ -874,28 +872,6 @@
},
"quick-bar": {
"commands": {
"navigation": {
"areas": "Področja",
"automation": "Avtomatizacije",
"core": "Splošno",
"customize": "Prilagoditve",
"devices": "Naprave",
"entities": "Entitete",
"helpers": "Pomočniki",
"info": "Informacije",
"integrations": "Integracije",
"logs": "Dnevniki",
"lovelace": "Nadzorne plošče Lovelace",
"navigate_to": "Pojdi na {panel}",
"navigate_to_config": "Pojdi na nastavitve {location}",
"person": "Osebe",
"scene": "Scene",
"script": "Skripti",
"server_control": "Nadzor strežnika",
"tags": "Značke",
"users": "Uporabniki",
"zone": "Območja"
},
"reload": {
"automation": "Znova naloži avtomatizacije",
"command_line": "Znova naloži entitete ukazne vrstice",
@@ -1417,7 +1393,7 @@
"instance_is_available": "Vaš primerek je na voljo na",
"instance_will_be_available": "Vaš primerek bo na voljo na",
"link_learn_how_it_works": "Naučite se, kako deluje",
"title": "Oddaljeno upravljanje"
"title": "Daljinsko Upravljanje"
},
"sign_out": "Izpis",
"thank_you_note": "Zahvaljujemo se vam za to, da ste del Home Assistant Cloud-a. Zaradi ljudi, kot ste vi, smo sposobni narediti dobro izkušnjo avtomatizacije doma za vsakogar. hvala!",
@@ -1430,7 +1406,7 @@
"no_hooks_yet": "Izgleda, da še nimate webhooks-ov. Začnite s konfiguracijo ",
"no_hooks_yet_link_automation": "webhook avtomatizacije",
"no_hooks_yet_link_integration": "integracijo, ki temelji na Webhook-u",
"no_hooks_yet2": " ali z ustvarjanjem ",
"no_hooks_yet2": "ali z ustvarjanjem",
"title": "Webhooks"
}
},
@@ -1591,7 +1567,7 @@
}
},
"devices": {
"add_prompt": "{name} še niso bile dodana za to napravo. Lahko jih dodaš s klikom na gumb + spodaj.",
"add_prompt": "Noben {name} še ni bil dodan s to napravo. Lahko ga dodaš s klikom na gumb + spodaj.",
"automation": {
"actions": {
"caption": "Ko se nekaj sproži ...",
@@ -1743,8 +1719,6 @@
"info": {
"built_using": "Zgrajen z uporabo",
"caption": "Info",
"copy_github": "Za GitHub",
"copy_raw": "Surovo besedilo",
"custom_uis": "Uporabniški vmesniki po meri:",
"description": "Ogled informacij o namestitvi Home Assistant",
"developed_by": "Razvija ga kup osupljivih ljudi.",
@@ -1819,7 +1793,7 @@
"entity_unavailable": "entiteta ni na voljo",
"firmware": "Firmware: {version}",
"hub": "Povezan prek",
"manuf": "naredil: {manufacturer}",
"manuf": "po {manufacturer}",
"no_area": "Brez območja",
"no_device": "Entitete brez naprav",
"no_devices": "Ta integracija je brez naprav.",
@@ -2336,7 +2310,6 @@
"update_user": "Posodobi"
},
"picker": {
"add_user": "Dodaj uporabnika",
"headers": {
"group": "Skupina",
"name": "Ime",
@@ -2617,8 +2590,6 @@
"filter_attributes": "Filter atributov",
"filter_entities": "Filter entitet",
"filter_states": "Filter stanj",
"last_changed": "Zadnja sprememba",
"last_updated": "Zadnja osvežitev",
"more_info": "Več informacij",
"no_entities": "Brez entitet",
"set_state": "Nastavi stanje",
@@ -2870,10 +2841,6 @@
"description": "Kartica Light omogoča spreminjanje svetlosti luči.",
"name": "Luči"
},
"logbook": {
"description": "Na kartici Dnevnik je prikazan seznam dogodkov za entitete.",
"name": "Dnevnik"
},
"map": {
"dark_mode": "Temni način?",
"default_zoom": "Privzeta povečava",

View File

@@ -806,10 +806,7 @@
"controls": "控制项",
"cover": {
"close_cover": "关闭卷帘",
"close_tile_cover": "关闭翻转式卷帘",
"open_cover": "打开卷帘",
"open_tilt_cover": "打开翻转式卷帘",
"stop_cover": "停止卷帘移动"
"open_cover": "打开卷帘"
},
"details": "详情",
"dismiss": "关闭对话框",

View File

@@ -1743,8 +1743,6 @@
"info": {
"built_using": "建置使用",
"caption": "更多資訊",
"copy_github": "GitHub",
"copy_raw": "原始文字",
"custom_uis": "自定介面:",
"description": "檢視 Home Assistant 安裝資訊",
"developed_by": "由一群充滿熱情的人們所開發。",

View File

@@ -15,7 +15,6 @@
"resolveJsonModule": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"plugins": [
{
"name": "ts-lit-plugin",

1166
yarn.lock

File diff suppressed because it is too large Load Diff