Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
41b86e6
Fix media browse item width (#6870)
zsarnett Sep 9, 2020
cdf7558
[ci skip] Translation update
homeassistant Sep 10, 2020
af74f21
Dont virtualize logbook in more info (#6907)
bramkragten Sep 10, 2020
810d2a1
Fix onboarding dark mode (#6910)
bramkragten Sep 10, 2020
c2e6d40
Bump http-proxy from 1.17.0 to 1.18.1 (#6914)
dependabot[bot] Sep 10, 2020
96c5fdc
Fix some lovelace editors (#6911)
bramkragten Sep 10, 2020
7bf0655
Diable tts inputs when entities is unavailable (#6909)
bramkragten Sep 10, 2020
7fa9f10
Don't add space on the bottom when not showing tabs (#6913)
bramkragten Sep 10, 2020
b9699f7
Avoid watching all states in the default template (#6918)
bdraco Sep 10, 2020
092a02a
Convert ha-long-lived-access-tokens-card (#6917)
ludeeus Sep 10, 2020
c06357a
Only show what triggered a change if it wasn't a user (#6919)
bramkragten Sep 10, 2020
fa65f84
Ignore disconnect codes for shutdown and reboot (#6901)
ludeeus Sep 10, 2020
aa4bc2c
Make logbook a bit smaller in more info (#6921)
bramkragten Sep 10, 2020
2139a80
Use proper constants for "unavailable" checks (#6922)
spacegaier Sep 10, 2020
b0508f4
[ci skip] Translation update
homeassistant Sep 11, 2020
ce8ee56
Check if history and logbook are loaded (#6908)
bramkragten Sep 11, 2020
5af4ce2
Restrict long press to header of sidebar (#6933)
bramkragten Sep 11, 2020
1935df1
Fixed height of circular progress in history (#6929)
Arielpod Sep 11, 2020
76394ce
Use secondary text color for no entries (#6931)
ludeeus Sep 11, 2020
23a9b79
Expand groups in entitry row to check toggle (#6930)
ludeeus Sep 11, 2020
78e64e1
Show brigtness slider when light is off (#6935)
bramkragten Sep 11, 2020
a2cd227
Remove backpath in ozw (#6937)
bramkragten Sep 11, 2020
f18913b
Show which state changed events a template listeners for in dev tools…
bdraco Sep 11, 2020
dd1bf7b
show first visible view on default (#6567)
iantrich Sep 11, 2020
da1de8d
Create codeql-analysis.yml
bramkragten Sep 11, 2020
3fdd6a8
Update codeql-analysis.yml
bramkragten Sep 11, 2020
f01fe65
Show title and name for default panels (#6941)
bramkragten Sep 11, 2020
26fbc07
Add edit sidebar button to profile (#6943)
bramkragten Sep 11, 2020
8ee29b1
[ci skip] Translation update
homeassistant Sep 12, 2020
c979cfb
Fix sidebar for not existing hidden panel (#6944)
bramkragten Sep 12, 2020
266f2e7
Sort listening entity and domain in template dev tools (#6953)
bramkragten Sep 12, 2020
90e09fc
Add default hold actions (#6952)
bramkragten Sep 12, 2020
7e70ba6
FIx entities picker (#6951)
bramkragten Sep 12, 2020
8b490c5
Media Browser: Use Media Class (#6904)
zsarnett Sep 12, 2020
8a99836
Add padding to rendered template result (#6954)
ludeeus Sep 12, 2020
99d0a0a
Lazy load more info content, split logbook and history (#6936)
bramkragten Sep 12, 2020
5480e54
Mute stream outside of more info (#6959)
bramkragten Sep 12, 2020
c1afed7
Sort media sources (#6960)
ludeeus Sep 12, 2020
857e4e4
Bumped version to 20200912.0
ludeeus Sep 12, 2020
af0246c
convert ha-refresh-tokens-card (#6962)
ludeeus Sep 12, 2020
50d37ce
Remove icon slot (#6964)
ludeeus Sep 12, 2020
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
60 changes: 60 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "CodeQL"

on:
push:
branches: [dev, master]
pull_request:
# The branches below must be a subset of the branches above
branches: [dev]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion gallery/src/components/demo-more-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import "../../../src/components/ha-card";
import "../../../src/dialogs/more-info/more-info-content";
import "../../../src/state-summary/state-card-content";
import "./more-info-content";

class DemoMoreInfo extends PolymerElement {
static get template() {
Expand Down
73 changes: 73 additions & 0 deletions gallery/src/components/more-info-content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { HassEntity } from "home-assistant-js-websocket";
import { property, PropertyValues, UpdatingElement } from "lit-element";
import dynamicContentUpdater from "../../../src/common/dom/dynamic_content_updater";
import { stateMoreInfoType } from "../../../src/common/entity/state_more_info_type";
import "../../../src/dialogs/more-info/controls/more-info-alarm_control_panel";
import "../../../src/dialogs/more-info/controls/more-info-automation";
import "../../../src/dialogs/more-info/controls/more-info-camera";
import "../../../src/dialogs/more-info/controls/more-info-climate";
import "../../../src/dialogs/more-info/controls/more-info-configurator";
import "../../../src/dialogs/more-info/controls/more-info-counter";
import "../../../src/dialogs/more-info/controls/more-info-cover";
import "../../../src/dialogs/more-info/controls/more-info-default";
import "../../../src/dialogs/more-info/controls/more-info-fan";
import "../../../src/dialogs/more-info/controls/more-info-group";
import "../../../src/dialogs/more-info/controls/more-info-humidifier";
import "../../../src/dialogs/more-info/controls/more-info-input_datetime";
import "../../../src/dialogs/more-info/controls/more-info-light";
import "../../../src/dialogs/more-info/controls/more-info-lock";
import "../../../src/dialogs/more-info/controls/more-info-media_player";
import "../../../src/dialogs/more-info/controls/more-info-person";
import "../../../src/dialogs/more-info/controls/more-info-script";
import "../../../src/dialogs/more-info/controls/more-info-sun";
import "../../../src/dialogs/more-info/controls/more-info-timer";
import "../../../src/dialogs/more-info/controls/more-info-vacuum";
import "../../../src/dialogs/more-info/controls/more-info-water_heater";
import "../../../src/dialogs/more-info/controls/more-info-weather";
import { HomeAssistant } from "../../../src/types";

class MoreInfoContent extends UpdatingElement {
@property({ attribute: false }) public hass?: HomeAssistant;

@property() public stateObj?: HassEntity;

private _detachedChild?: ChildNode;

protected firstUpdated(): void {
this.style.position = "relative";
this.style.display = "block";
}

// This is not a lit element, but an updating element, so we implement update
protected update(changedProps: PropertyValues): void {
super.update(changedProps);
const stateObj = this.stateObj;
const hass = this.hass;

if (!stateObj || !hass) {
if (this.lastChild) {
this._detachedChild = this.lastChild;
// Detach child to prevent it from doing work.
this.removeChild(this.lastChild);
}
return;
}

if (this._detachedChild) {
this.appendChild(this._detachedChild);
this._detachedChild = undefined;
}

const moreInfoType =
stateObj.attributes && "custom_ui_more_info" in stateObj.attributes
? stateObj.attributes.custom_ui_more_info
: "more-info-" + stateMoreInfoType(stateObj);

dynamicContentUpdater(this, moreInfoType.toUpperCase(), {
hass,
stateObj,
});
}
}

customElements.define("more-info-content", MoreInfoContent);
2 changes: 1 addition & 1 deletion gallery/src/demos/demo-more-info-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { html } from "@polymer/polymer/lib/utils/html-tag";
import { PolymerElement } from "@polymer/polymer/polymer-element";
import "../../../src/components/ha-card";
import { SUPPORT_BRIGHTNESS } from "../../../src/data/light";
import "../../../src/dialogs/more-info/more-info-content";
import { getEntity } from "../../../src/fake_data/entity";
import { provideHass } from "../../../src/fake_data/provide_hass";
import "../components/demo-more-infos";
import "../components/more-info-content";

const ENTITIES = [
getEntity("light", "bed_light", "on", {
Expand Down
3 changes: 2 additions & 1 deletion hassio/src/dashboard/hassio-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "../../../src/components/ha-svg-icon";
import {
extractApiErrorMessage,
HassioResponse,
ignoredStatusCodes,
} from "../../../src/data/hassio/common";
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
import {
Expand Down Expand Up @@ -166,7 +167,7 @@ export class HassioUpdate extends LitElement {
} catch (err) {
// Only show an error if the status code was not expected (user behind proxy)
// or no status at all(connection terminated)
if (err.status_code && ![502, 503, 504].includes(err.status_code)) {
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
showAlertDialog(this, {
title: "Update failed",
text: extractApiErrorMessage(err),
Expand Down
27 changes: 18 additions & 9 deletions hassio/src/system/hassio-host-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import "../../../src/components/buttons/ha-progress-button";
import "../../../src/components/ha-button-menu";
import "../../../src/components/ha-card";
import "../../../src/components/ha-settings-row";
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
import {
extractApiErrorMessage,
ignoredStatusCodes,
} from "../../../src/data/hassio/common";
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
import {
changeHostOptions,
Expand Down Expand Up @@ -245,10 +248,13 @@ class HassioHostInfo extends LitElement {
try {
await rebootHost(this.hass);
} catch (err) {
showAlertDialog(this, {
title: "Failed to reboot",
text: extractApiErrorMessage(err),
});
// Ignore connection errors, these are all expected
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
showAlertDialog(this, {
title: "Failed to reboot",
text: extractApiErrorMessage(err),
});
}
}
button.progress = false;
}
Expand All @@ -272,10 +278,13 @@ class HassioHostInfo extends LitElement {
try {
await shutdownHost(this.hass);
} catch (err) {
showAlertDialog(this, {
title: "Failed to shutdown",
text: extractApiErrorMessage(err),
});
// Ignore connection errors, these are all expected
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
showAlertDialog(this, {
title: "Failed to shutdown",
text: extractApiErrorMessage(err),
});
}
}
button.progress = false;
}
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="20200909.0",
version="20200912.0",
description="The Home Assistant frontend",
url="https://github.com/home-assistant/home-assistant-polymer",
author="The Home Assistant Authors",
Expand Down
1 change: 0 additions & 1 deletion src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const DOMAINS_WITH_MORE_INFO = [
"script",
"sun",
"timer",
"updater",
"vacuum",
"water_heater",
"weather",
Expand Down
3 changes: 2 additions & 1 deletion src/common/entity/state_card_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { HomeAssistant } from "../../types";
import { DOMAINS_WITH_CARD } from "../const";
import { canToggleState } from "./can_toggle_state";
import { computeStateDomain } from "./compute_state_domain";
import { UNAVAILABLE } from "../../data/entity";

export const stateCardType = (hass: HomeAssistant, stateObj: HassEntity) => {
if (stateObj.state === "unavailable") {
if (stateObj.state === UNAVAILABLE) {
return "display";
}

Expand Down
50 changes: 50 additions & 0 deletions src/common/util/throttle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// From: underscore.js https://github.com/jashkenas/underscore/blob/master/underscore.js

// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `false for leading`. To disable execution on the trailing edge, ditto.
export const throttle = <T extends Function>(
func: T,
wait: number,
leading = true,
trailing = true
): T => {
let timeout: number | undefined;
let previous = 0;
let context: any;
let args: any;
const later = () => {
previous = leading === false ? 0 : Date.now();
timeout = undefined;
func.apply(context, args);
if (!timeout) {
context = null;
args = null;
}
};
// @ts-ignore
return function (...argmnts) {
// @ts-ignore
// @typescript-eslint/no-this-alias
context = this;
args = argmnts;

const now = Date.now();
if (!previous && leading === false) {
previous = now;
}
const remaining = wait - (now - previous);
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = undefined;
}
previous = now;
func.apply(context, args);
} else if (!timeout && trailing !== false) {
timeout = window.setTimeout(later, remaining);
}
};
};
6 changes: 3 additions & 3 deletions src/components/entity/ha-entity-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { HassEntity } from "home-assistant-js-websocket";
import {
css,
CSSResult,
customElement,
html,
LitElement,
property,
Expand Down Expand Up @@ -51,7 +52,8 @@ const rowRenderer = (
root.querySelector("[secondary]")!.textContent = model.item.entity_id;
};

class HaEntityPicker extends LitElement {
@customElement("ha-entity-picker")
export class HaEntityPicker extends LitElement {
@property({ type: Boolean }) public autofocus = false;

@property({ type: Boolean }) public disabled?: boolean;
Expand Down Expand Up @@ -276,8 +278,6 @@ class HaEntityPicker extends LitElement {
}
}

customElements.define("ha-entity-picker", HaEntityPicker);

declare global {
interface HTMLElementTagNameMap {
"ha-entity-picker": HaEntityPicker;
Expand Down
10 changes: 6 additions & 4 deletions src/components/entity/ha-state-label-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { stateIcon } from "../../common/entity/state_icon";
import { timerTimeRemaining } from "../../common/entity/timer_time_remaining";
import { HomeAssistant } from "../../types";
import "../ha-label-badge";
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";

@customElement("ha-state-label-badge")
export class HaStateLabelBadge extends LitElement {
Expand Down Expand Up @@ -81,7 +82,8 @@ export class HaStateLabelBadge extends LitElement {
? ""
: this.image
? this.image
: state.attributes.entity_picture_local || state.attributes.entity_picture}"
: state.attributes.entity_picture_local ||
state.attributes.entity_picture}"
.label="${this._computeLabel(domain, state, this._timerTimeRemaining)}"
.description="${this.name ? this.name : computeStateName(state)}"
></ha-label-badge>
Expand All @@ -108,7 +110,7 @@ export class HaStateLabelBadge extends LitElement {
return null;
case "sensor":
default:
return state.state === "unknown"
return state.state === UNKNOWN
? "-"
: state.attributes.unit_of_measurement
? state.state
Expand All @@ -121,7 +123,7 @@ export class HaStateLabelBadge extends LitElement {
}

private _computeIcon(domain: string, state: HassEntity) {
if (state.state === "unavailable") {
if (state.state === UNAVAILABLE) {
return null;
}
switch (domain) {
Expand Down Expand Up @@ -166,7 +168,7 @@ export class HaStateLabelBadge extends LitElement {

private _computeLabel(domain, state, _timerTimeRemaining) {
if (
state.state === "unavailable" ||
state.state === UNAVAILABLE ||
["device_tracker", "alarm_control_panel", "person"].includes(domain)
) {
// Localize the state with a special state_badge namespace, which has variations of
Expand Down
10 changes: 7 additions & 3 deletions src/components/ha-camera-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class HaCameraStream extends LitElement {

@property({ attribute: false }) public stateObj?: CameraEntity;

@property({ type: Boolean }) public showControls = false;
@property({ type: Boolean, attribute: "controls" })
public controls = false;

@property({ type: Boolean, attribute: "muted" })
public muted = false;

// We keep track if we should force MJPEG with a string
// that way it automatically resets if we change entity.
Expand Down Expand Up @@ -56,9 +60,9 @@ class HaCameraStream extends LitElement {
? html`
<ha-hls-player
autoplay
muted
playsinline
?controls=${this.showControls}
.muted=${this.muted}
.controls=${this.controls}
.hass=${this.hass}
.url=${this._url}
></ha-hls-player>
Expand Down
Loading