Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f06f3ee
Add Netatmo specific states
Twanislas Oct 24, 2019
44d1458
Revert "Add Netatmo specific states"
Twanislas Oct 24, 2019
13fbc81
Add Netatmo thermostat states
Twanislas Oct 24, 2019
466c48a
Merge pull request #4128 from Twanislas/netatmo-states-translation
bramkragten Oct 28, 2019
9078e41
Clarify tslint disable
balloob Oct 28, 2019
971865e
Added title attributes and translated them in Configure UI Mode
springstan Oct 28, 2019
669fbb7
Only do haptic on entity interactions
bramkragten Oct 29, 2019
c6fb896
Merge pull request #4152 from home-assistant/haptics
bramkragten Oct 29, 2019
04500bc
Merge pull request #4148 from springstan/addTitleAttributeConfigUIMode
bramkragten Oct 29, 2019
f2812bc
Translated automation and script editor (#4146)
springstan Oct 29, 2019
b41f477
More descriptive delete/move buttons + red delete (#4145)
mahval Oct 29, 2019
6196bbd
Translated hui-editor and hui-root pages (#4142)
springstan Oct 29, 2019
12be2a9
Merge branch 'master' into dev
bramkragten Oct 29, 2019
46f5224
Migrate voice command dialog (#4150)
bramkragten Oct 29, 2019
0fa8db1
Translated unused entities, device registry page and domain toggler d…
springstan Nov 1, 2019
f53eea8
Translated a bunch of strings (#4137)
springstan Nov 1, 2019
e37201f
enter is registering as double_tap (#4161)
iantrich Nov 1, 2019
b705de9
Fix hassio build (#4167)
bramkragten Nov 1, 2019
9b3891f
Fix state-label-badge override name (#4166)
bramkragten Nov 1, 2019
274c201
action-handler (#4115)
iantrich Nov 1, 2019
c730aab
Translated config flow form and steps (#4140)
springstan Nov 1, 2019
2a617a9
Revert "Add Netatmo specific states" (#4171)
bramkragten Nov 1, 2019
da35c26
Add scene editor (#4164)
bramkragten Nov 4, 2019
5ca82fd
Fix mobile support for voice dialog (#4154)
bramkragten Nov 4, 2019
ab476d2
Add conversation ID to voice dialog (#4189)
balloob Nov 7, 2019
e3ef3cf
Bumped version to 20191108.0
bramkragten Nov 8, 2019
901752b
Update translations (#4192)
bramkragten Nov 8, 2019
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
2 changes: 1 addition & 1 deletion build-scripts/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module.exports = {

hassio_dir: path.resolve(__dirname, "../hassio"),
hassio_root: path.resolve(__dirname, "../hassio/build"),
hassio_publicPath: "/api/hassio/app",
hassio_publicPath: "/api/hassio/app/",
};
4 changes: 2 additions & 2 deletions demo/src/custom-cards/card-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ if (!window.cardTools) {
};

cardTools.longpress = (element) => {
customElements.whenDefined("long-press").then(() => {
const longpress = document.body.querySelector("long-press");
customElements.whenDefined("action-handler").then(() => {
const longpress = document.body.querySelector("action-handler");
longpress.bind(element);
});
return element;
Expand Down
16 changes: 6 additions & 10 deletions gallery/src/demos/demo-util-long-press.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { html, LitElement, TemplateResult } from "lit-element";
import "@material/mwc-button";

import "../../../src/components/ha-card";
import { longPress } from "../../../src/panels/lovelace/common/directives/long-press-directive";
import { actionHandler } from "../../../src/panels/lovelace/common/directives/action-handler-directive";
import { ActionHandlerEvent } from "../../../src/data/lovelace";

export class DemoUtilLongPress extends LitElement {
protected render(): TemplateResult | void {
Expand All @@ -12,9 +13,8 @@ export class DemoUtilLongPress extends LitElement {
() => html`
<ha-card>
<mwc-button
@ha-click="${this._handleClick}"
@ha-hold="${this._handleHold}"
.longPress="${longPress()}"
@action=${this._handleAction}
.actionHandler=${actionHandler({})}
>
(long) press me!
</mwc-button>
Expand All @@ -28,12 +28,8 @@ export class DemoUtilLongPress extends LitElement {
`;
}

private _handleClick(ev: Event) {
this._addValue(ev, "tap");
}

private _handleHold(ev: Event) {
this._addValue(ev, "hold");
private _handleAction(ev: ActionHandlerEvent) {
this._addValue(ev, ev.detail.action!);
}

private _addValue(ev: Event, value: string) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"@types/leaflet": "^1.4.3",
"@types/memoize-one": "4.1.0",
"@types/mocha": "^5.2.6",
"@types/webspeechapi": "^0.0.29",
"babel-loader": "^8.0.5",
"chai": "^4.2.0",
"copy-webpack-plugin": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="home-assistant-frontend",
version="20191025.1",
version="20191108.0",
description="The Home Assistant frontend",
url="https://github.com/home-assistant/home-assistant-polymer",
author="The Home Assistant Authors",
Expand Down
6 changes: 2 additions & 4 deletions src/common/config/is_component_loaded.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { HomeAssistant } from "../../types";

/** Return if a component is loaded. */
export default function isComponentLoaded(
export const isComponentLoaded = (
hass: HomeAssistant,
component: string
): boolean {
return hass && hass.config.components.indexOf(component) !== -1;
}
): boolean => hass && hass.config.components.indexOf(component) !== -1;
26 changes: 6 additions & 20 deletions src/components/device/ha-device-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import {
DeviceRegistryEntry,
subscribeDeviceRegistry,
computeDeviceName,
} from "../../data/device_registry";
import { compare } from "../../common/string/compare";
import { PolymerChangedEvent } from "../../polymer-types";
Expand All @@ -33,7 +34,6 @@ import {
EntityRegistryEntry,
subscribeEntityRegistry,
} from "../../data/entity_registry";
import { computeStateName } from "../../common/entity/compute_state_name";

interface Device {
name: string;
Expand Down Expand Up @@ -102,11 +102,11 @@ class HaDevicePicker extends SubscribeMixin(LitElement) {
const outputDevices = devices.map((device) => {
return {
id: device.id,
name:
device.name_by_user ||
device.name ||
this._fallbackDeviceName(device.id, deviceEntityLookup) ||
"No name",
name: computeDeviceName(
device,
this.hass,
deviceEntityLookup[device.id]
),
area: device.area_id ? areaLookup[device.area_id].name : "No area",
};
});
Expand Down Expand Up @@ -209,20 +209,6 @@ class HaDevicePicker extends SubscribeMixin(LitElement) {
}
}

private _fallbackDeviceName(
deviceId: string,
deviceEntityLookup: DeviceEntityLookup
): string | undefined {
for (const entity of deviceEntityLookup[deviceId] || []) {
const stateObj = this.hass.states[entity.entity_id];
if (stateObj) {
return computeStateName(stateObj);
}
}

return undefined;
}

static get styles(): CSSResult {
return css`
paper-input > paper-icon-button {
Expand Down
22 changes: 19 additions & 3 deletions src/components/entity/ha-entities-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ import { HassEntity } from "home-assistant-js-websocket";
class HaEntitiesPickerLight extends LitElement {
@property() public hass?: HomeAssistant;
@property() public value?: string[];
@property({ attribute: "domain-filter" }) public domainFilter?: string;
/**
* Show entities from specific domains.
* @type {string}
* @attr include-domains
*/
@property({ type: Array, attribute: "include-domains" })
public includeDomains?: string[];
/**
* Show no entities of these domains.
* @type {Array}
* @attr exclude-domains
*/
@property({ type: Array, attribute: "exclude-domains" })
public excludeDomains?: string[];
@property({ attribute: "picked-entity-label" })
public pickedEntityLabel?: string;
@property({ attribute: "pick-entity-label" }) public pickEntityLabel?: string;
Expand All @@ -31,6 +44,7 @@ class HaEntitiesPickerLight extends LitElement {
if (!this.hass) {
return;
}

const currentEntities = this._currentEntities;
return html`
${currentEntities.map(
Expand All @@ -40,7 +54,8 @@ class HaEntitiesPickerLight extends LitElement {
allow-custom-entity
.curValue=${entityId}
.hass=${this.hass}
.domainFilter=${this.domainFilter}
.includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains}
.entityFilter=${this._entityFilter}
.value=${entityId}
.label=${this.pickedEntityLabel}
Expand All @@ -52,7 +67,8 @@ class HaEntitiesPickerLight extends LitElement {
<div>
<ha-entity-picker
.hass=${this.hass}
.domainFilter=${this.domainFilter}
.includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains}
.entityFilter=${this._entityFilter}
.label=${this.pickEntityLabel}
@value-changed=${this._addEntity}
Expand Down
31 changes: 26 additions & 5 deletions src/components/entity/ha-entity-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,29 @@ class HaEntityPicker extends LitElement {
@property() public hass?: HomeAssistant;
@property() public label?: string;
@property() public value?: string;
@property({ attribute: "domain-filter" }) public domainFilter?: string;
/**
* Show entities from specific domains.
* @type {string}
* @attr include-domains
*/
@property({ type: Array, attribute: "include-domains" })
public includeDomains?: string[];
/**
* Show no entities of these domains.
* @type {Array}
* @attr exclude-domains
*/
@property({ type: Array, attribute: "exclude-domains" })
public excludeDomains?: string[];
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
@property({ type: Boolean }) private _opened?: boolean;
@property() private _hass?: HomeAssistant;

private _getStates = memoizeOne(
(
hass: this["hass"],
domainFilter: this["domainFilter"],
includeDomains: this["includeDomains"],
excludeDomains: this["excludeDomains"],
entityFilter: this["entityFilter"]
) => {
let states: HassEntity[] = [];
Expand All @@ -78,9 +92,15 @@ class HaEntityPicker extends LitElement {
}
let entityIds = Object.keys(hass.states);

if (domainFilter) {
if (includeDomains) {
entityIds = entityIds.filter((eid) =>
includeDomains.includes(eid.substr(0, eid.indexOf(".")))
);
}

if (excludeDomains) {
entityIds = entityIds.filter(
(eid) => eid.substr(0, eid.indexOf(".")) === domainFilter
(eid) => !excludeDomains.includes(eid.substr(0, eid.indexOf(".")))
);
}

Expand Down Expand Up @@ -108,7 +128,8 @@ class HaEntityPicker extends LitElement {
protected render(): TemplateResult | void {
const states = this._getStates(
this._hass,
this.domainFilter,
this.includeDomains,
this.excludeDomains,
this.entityFilter
);

Expand Down
56 changes: 0 additions & 56 deletions src/components/ha-start-voice-button.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/data/conversation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { HomeAssistant } from "../types";

interface ProcessResults {
card: { [key: string]: { [key: string]: string } };
speech: {
[SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string }
};
}

export const processText = (
hass: HomeAssistant,
text: string,
// tslint:disable-next-line: variable-name
conversation_id: string
): Promise<ProcessResults> =>
hass.callApi("POST", "conversation/process", { text, conversation_id });
29 changes: 29 additions & 0 deletions src/data/device_registry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HomeAssistant } from "../types";
import { createCollection, Connection } from "home-assistant-js-websocket";
import { debounce } from "../common/util/debounce";
import { EntityRegistryEntry } from "./entity_registry";
import { computeStateName } from "../common/entity/compute_state_name";

export interface DeviceRegistryEntry {
id: string;
Expand All @@ -20,6 +22,33 @@ export interface DeviceRegistryEntryMutableParams {
name_by_user?: string | null;
}

export const computeDeviceName = (
device: DeviceRegistryEntry,
hass: HomeAssistant,
entities?: EntityRegistryEntry[] | string[]
) => {
return (
device.name_by_user ||
device.name ||
(entities && fallbackDeviceName(hass, entities)) ||
hass.localize("ui.panel.config.devices.unnamed_device")
);
};

export const fallbackDeviceName = (
hass: HomeAssistant,
entities: EntityRegistryEntry[] | string[]
) => {
for (const entity of entities || []) {
const entityId = typeof entity === "string" ? entity : entity.entity_id;
const stateObj = hass.states[entityId];
if (stateObj) {
return computeStateName(stateObj);
}
}
return undefined;
};

export const updateDeviceRegistryEntry = (
hass: HomeAssistant,
deviceId: string,
Expand Down
10 changes: 9 additions & 1 deletion src/data/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HomeAssistant } from "../types";
import { Connection, getCollection } from "home-assistant-js-websocket";
import { HASSDomEvent } from "../common/dom/fire_event";

export interface LovelaceConfig {
title?: string;
Expand Down Expand Up @@ -127,6 +128,13 @@ export interface WindowWithLovelaceProm extends Window {
llConfProm?: Promise<LovelaceConfig>;
}

export interface LongPressOptions {
export interface ActionHandlerOptions {
hasHold?: boolean;
hasDoubleClick?: boolean;
}

export interface ActionHandlerDetail {
action: string;
}

export type ActionHandlerEvent = HASSDomEvent<ActionHandlerDetail>;
Loading