From beec790af6bce89acf9f14f35b59d418428920a2 Mon Sep 17 00:00:00 2001 From: RFDarter Date: Thu, 18 Apr 2024 06:54:09 +0200 Subject: [PATCH 01/10] number | remove obsolete `numDecimalPlaces` (#71) --- packages/v3/src/esp-entity-table.ts | 22 ++++++++-------------- packages/v3/src/esp-range-slider.ts | 19 ++++++------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/packages/v3/src/esp-entity-table.ts b/packages/v3/src/esp-entity-table.ts index 002d490..3f9814d 100644 --- a/packages/v3/src/esp-entity-table.ts +++ b/packages/v3/src/esp-entity-table.ts @@ -29,8 +29,8 @@ interface entityConfig { target_temperature_high?: number; min_temp?: number; max_temp?: number; - min_value?: number; - max_value?: number; + min_value?: string; + max_value?: string; step?: number; min_length?: number; max_length?: number; @@ -337,18 +337,12 @@ class ActionRenderer { entity: entityConfig, action: string, opt: string, - value: number | string, - min?: number, - max?: number, + value: string | number, + min?: string | undefined, + max?: string | undefined, step = 1 ) { if(entity.mode == 1) { - const val = Number(value); - let stepString = step.toString(); - let numDecimalPlaces = 0 - if (stepString.indexOf('.') !== -1) { - numDecimalPlaces = stepString.split('.')[1].length; - } return html`
{ if(!document.querySelector('.popup-number-input')) { return; @@ -133,7 +126,7 @@ export class EspRangeSlider extends LitElement { updateCurrentValueOverlay(): void { const newValueAsPercent = Number( (this.inputRange.value - this.inputRange.min) * 100 / (this.inputRange.max - this.inputRange.min) ), newPosition = 10 - (newValueAsPercent * 0.2); - this.currentValue.innerHTML = `${Number(this.inputRange?.value).toFixed(this.numDecimalPlaces)}`; + this.currentValue.innerHTML = `${this.inputRange?.value}`; this.currentValue.style.left = `calc(${newValueAsPercent}% + (${newPosition}px))`; const spanTooltip = this.currentValue?.querySelector('span'); @@ -178,7 +171,7 @@ export class EspRangeSlider extends LitElement { step="${this.step}" min="${this.min || Math.min(0, this.value)}" max="${this.max || Math.max(10, this.value)}" - .value="${(this.value.toFixed(this.numDecimalPlaces))}" + .value="${this.value}" @input="${this.onInputEvent}" @change="${this.onInputChangeEvent}" /> From d60667a3a82b47778be9a858eb6366de19e37c46 Mon Sep 17 00:00:00 2001 From: RFDarter Date: Tue, 23 Apr 2024 02:00:14 +0200 Subject: [PATCH 02/10] v2 Support Datetime Component (#83) --- packages/v2/src/esp-entity-table.ts | 49 +++++++++++++++++++++++++++++ packages/v2/vite.config.ts | 2 ++ 2 files changed, 51 insertions(+) diff --git a/packages/v2/src/esp-entity-table.ts b/packages/v2/src/esp-entity-table.ts index c233bd3..c8458fe 100644 --- a/packages/v2/src/esp-entity-table.ts +++ b/packages/v2/src/esp-entity-table.ts @@ -285,6 +285,29 @@ class ActionRenderer {
`; } + private _datetime( + entity: entityConfig, + type: string, + action: string, + opt: string, + value: string, + ) { + return html` + + `; + } private _textinput( entity: entityConfig, @@ -411,6 +434,32 @@ class ActionRenderer { ); } + render_date() { + if (!this.entity) return; + return html` + ${this._datetime( + this.entity, + "date", + "set", + "value", + this.entity.value, + )} + `; + } + + render_time() { + if (!this.entity) return; + return html` + ${this._datetime( + this.entity, + "time", + "set", + "value", + this.entity.value, + )} + `; + } + render_text() { if (!this.entity) return; return this._textinput( diff --git a/packages/v2/vite.config.ts b/packages/v2/vite.config.ts index 9159f94..2c75de0 100644 --- a/packages/v2/vite.config.ts +++ b/packages/v2/vite.config.ts @@ -87,6 +87,8 @@ export default defineConfig({ "/climate": proxy_target, "/events": proxy_target, "/text": proxy_target, + "/date": proxy_target, + "/time": proxy_target, }, }, }); From 604bb8faa4118df0e1a31955e49e62f31a991755 Mon Sep 17 00:00:00 2001 From: RFDarter Date: Tue, 23 Apr 2024 02:00:33 +0200 Subject: [PATCH 03/10] v3 Support datetime time entity (#84) --- packages/v3/src/esp-entity-table.ts | 23 ++++++++++++++++++----- packages/v3/vite.config.ts | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/v3/src/esp-entity-table.ts b/packages/v3/src/esp-entity-table.ts index 3f9814d..5991c03 100644 --- a/packages/v3/src/esp-entity-table.ts +++ b/packages/v3/src/esp-entity-table.ts @@ -271,15 +271,16 @@ class ActionRenderer { `; } - private _date( + private _datetime( entity: entityConfig, + type: string, action: string, opt: string, value: string, ) { return html` Date: Tue, 23 Apr 2024 04:42:11 +0200 Subject: [PATCH 04/10] v3 Truncate long enity name (#87) --- packages/v3/src/css/app.ts | 2 +- packages/v3/src/css/esp-entity-table.ts | 6 +++++- packages/v3/src/esp-range-slider.ts | 7 ++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/v3/src/css/app.ts b/packages/v3/src/css/app.ts index 3b196f9..60a5df3 100644 --- a/packages/v3/src/css/app.ts +++ b/packages/v3/src/css/app.ts @@ -3,7 +3,7 @@ import { css } from "lit"; export default css` .flex-grid-half { display: grid; - grid-template-columns: 500px 2fr; + grid-template-columns: 600px 2fr; } .flex-grid-half.expanded_entity, .flex-grid-half.expanded_logs { diff --git a/packages/v3/src/css/esp-entity-table.ts b/packages/v3/src/css/esp-entity-table.ts index ee62f5a..82a93a6 100644 --- a/packages/v3/src/css/esp-entity-table.ts +++ b/packages/v3/src/css/esp-entity-table.ts @@ -46,14 +46,18 @@ export default css` text-align: center; } .entity-row > :nth-child(2) { - flex: 1 1 50%; + flex: 1 1 40%; margin-left: 16px; margin-right: 8px; text-wrap: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: 150px; } .entity-row > :nth-child(3) { flex: 1 1 50%; margin-right: 8px; + margin-left: 20px; text-align: right; display: flex; justify-content: space-between; diff --git a/packages/v3/src/esp-range-slider.ts b/packages/v3/src/esp-range-slider.ts index 1f87eba..af02ecf 100644 --- a/packages/v3/src/esp-range-slider.ts +++ b/packages/v3/src/esp-range-slider.ts @@ -161,7 +161,7 @@ export class EspRangeSlider extends LitElement { render() { return html`
- +
Date: Tue, 23 Apr 2024 04:42:45 +0200 Subject: [PATCH 05/10] v3 Silder mobile devices fix (#85) --- packages/v3/src/esp-range-slider.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/v3/src/esp-range-slider.ts b/packages/v3/src/esp-range-slider.ts index af02ecf..66d1a54 100644 --- a/packages/v3/src/esp-range-slider.ts +++ b/packages/v3/src/esp-range-slider.ts @@ -192,6 +192,7 @@ export class EspRangeSlider extends LitElement { -webkit-appearance: none; margin: 20px 0; width: 100%; + touch-action: none; } input[type=range]:focus { outline: none; From f11c1a4fe020a632ee620e208172ff59f98a9afc Mon Sep 17 00:00:00 2001 From: Peter Zich Date: Thu, 25 Apr 2024 13:49:02 -0700 Subject: [PATCH 06/10] Add #ifdef USE_WEBSERVER_LOCAL to make_header.sh (#89) --- scripts/make_header.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/make_header.sh b/scripts/make_header.sh index b88d28e..a916ae9 100755 --- a/scripts/make_header.sh +++ b/scripts/make_header.sh @@ -2,7 +2,10 @@ cat <./$1/$2 #pragma once // Generated from https://github.com/esphome/esphome-webserver -$(if [ -n "$4" ]; then echo "#if USE_WEBSERVER_VERSION == $4"; fi) +$(if [ -n "$4" ]; then + echo "#ifdef USE_WEBSERVER_LOCAL" + echo "#if USE_WEBSERVER_VERSION == $4" +fi) #include "esphome/core/hal.h" namespace esphome { @@ -15,5 +18,8 @@ cat <>./$1/$2 } // namespace $3 } // namespace esphome -$(if [ -n "$4" ]; then echo "#endif"; fi) +$(if [ -n "$4" ]; then + echo "#endif" + echo "#endif" +fi) EOT From 832a6c84ab55cb224b691a6ca712784d91a76b92 Mon Sep 17 00:00:00 2001 From: RFDarter Date: Thu, 25 Apr 2024 22:49:38 +0200 Subject: [PATCH 07/10] v3 Expand-on-header-dbclick-only (#81) --- packages/v3/src/esp-app.ts | 23 +++++++++-------------- packages/v3/src/esp-entity-table.ts | 13 ++++++++++++- packages/v3/src/esp-log.ts | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/packages/v3/src/esp-app.ts b/packages/v3/src/esp-app.ts index c48e2c0..a4104d8 100644 --- a/packages/v3/src/esp-app.ts +++ b/packages/v3/src/esp-app.ts @@ -120,6 +120,14 @@ export default class EspApp extends LitElement { setInterval(() => { this.connected = !!this.ping && Date.now() - this.lastUpdate < 15000; }, 5000); + document.addEventListener('entity-tab-header-double-clicked', (e) => { + const mainElement = this.shadowRoot?.querySelector('main.flex-grid-half'); + mainElement?.classList.toggle('expanded_entity'); + }); + document.addEventListener('log-tab-header-double-clicked', (e) => { + const mainElement = this.shadowRoot?.querySelector('main.flex-grid-half'); + mainElement?.classList.toggle('expanded_logs'); + }); } schemeDefault() { @@ -162,7 +170,6 @@ export default class EspApp extends LitElement { ? html`
` @@ -210,8 +217,7 @@ export default class EspApp extends LitElement {
${this.renderOta()} @@ -221,17 +227,6 @@ export default class EspApp extends LitElement { `; } - private _handleDblClick(e: Event) { - e.currentTarget?.parentNode?.classList.toggle( - "expanded_entity", - e.currentTarget?.id === "col_entities" ? undefined : false - ); - e.currentTarget?.parentNode?.classList.toggle( - "expanded_logs", - e.currentTarget?.id === "col_logs" ? undefined : false - ); - } - private _updateUptime(e: MessageEvent) { if (e.lastEventId) { this.ping = parseInt(e.lastEventId); diff --git a/packages/v3/src/esp-entity-table.ts b/packages/v3/src/esp-entity-table.ts index 5991c03..b624d3f 100644 --- a/packages/v3/src/esp-entity-table.ts +++ b/packages/v3/src/esp-entity-table.ts @@ -185,7 +185,10 @@ export class EntityTable extends LitElement implements RestAction {
${elems.map( (group) => html` -
+
${EntityTable.ENTITY_CATEGORIES[parseInt(group.name)] || EntityTable.ENTITY_UNDEFINED}
@@ -240,8 +243,16 @@ export class EntityTable extends LitElement implements RestAction { ); } } + _handleTabHeaderDblClick(e: Event) { + const doubleClickEvent = new CustomEvent('entity-tab-header-double-clicked', { + bubbles: true, + composed: true, + }); + e.target?.dispatchEvent(doubleClickEvent); + } } + type ActionRendererNonCallable = "entity" | "actioner" | "exec"; type ActionRendererMethodKey = keyof Omit< ActionRenderer, diff --git a/packages/v3/src/esp-log.ts b/packages/v3/src/esp-log.ts index ff353cf..1868554 100644 --- a/packages/v3/src/esp-log.ts +++ b/packages/v3/src/esp-log.ts @@ -50,7 +50,12 @@ export class DebugLog extends LitElement { render() { return html` -
Debug Log
+
+ Debug Log +
@@ -77,6 +82,14 @@ export class DebugLog extends LitElement { `; } + _handleTabHeaderDblClick(e: Event) { + const doubleClickEvent = new CustomEvent('log-tab-header-double-clicked', { + bubbles: true, + composed: true, + }); + e.target?.dispatchEvent(doubleClickEvent); + } + static get styles() { return [ cssTab, From 7c1c9763c88ce65dc81bae4fc4e6890b6792821c Mon Sep 17 00:00:00 2001 From: Rebbe Pod <66928914+RebbePod@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:21:19 -0400 Subject: [PATCH 08/10] Prefix `textinput` & `datetime` value with `.` (#91) --- packages/v2/src/esp-entity-table.ts | 4 ++-- packages/v3/src/esp-entity-table.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/v2/src/esp-entity-table.ts b/packages/v2/src/esp-entity-table.ts index c8458fe..6191030 100644 --- a/packages/v2/src/esp-entity-table.ts +++ b/packages/v2/src/esp-entity-table.ts @@ -297,7 +297,7 @@ class ActionRenderer { type="${type}" name="${entity.unique_id}" id="${entity.unique_id}" - value="${value}" + .value="${value}" @change="${(e: Event) => { const val = (e.target)?.value; this.actioner?.restAction( @@ -326,7 +326,7 @@ class ActionRenderer { minlength="${min || Math.min(0, value as number)}" maxlength="${max || Math.max(255, value as number)}" pattern="${pattern || ''}" - value="${value!}" + .value="${value!}" @change="${(e: Event) => { let val = e.target?.value; this.actioner?.restAction(entity, `${action}?${opt}=${encodeURIComponent(val)}`); diff --git a/packages/v3/src/esp-entity-table.ts b/packages/v3/src/esp-entity-table.ts index b624d3f..16d3ec7 100644 --- a/packages/v3/src/esp-entity-table.ts +++ b/packages/v3/src/esp-entity-table.ts @@ -294,7 +294,7 @@ class ActionRenderer { type="${type}" name="${entity.unique_id}" id="${entity.unique_id}" - value="${value}" + .value="${value}" @change="${(e: Event) => { const val = (e.target)?.value; this.actioner?.restAction( @@ -378,7 +378,7 @@ class ActionRenderer { step="${step}" min="${min}" max="${max}" - value="${value}" + .value="${value}" @state="${(e: CustomEvent) => { const val = (e.target)?.value; this.actioner?.restAction(entity, `${action}?${opt}=${e.detail.state}`); From 93b96bd6b5aeeda049323de4bddcb992506618c6 Mon Sep 17 00:00:00 2001 From: RFDarter Date: Mon, 29 Apr 2024 21:22:45 +0200 Subject: [PATCH 09/10] v3 light slider width (#88) --- packages/v3/src/esp-entity-table.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/v3/src/esp-entity-table.ts b/packages/v3/src/esp-entity-table.ts index 16d3ec7..2c72fa2 100644 --- a/packages/v3/src/esp-entity-table.ts +++ b/packages/v3/src/esp-entity-table.ts @@ -510,7 +510,8 @@ class ActionRenderer { render_light() { if (!this.entity) return; return [ - html`
+ html`
${this._switch(this.entity)} ${this.entity.brightness ? this._range( From affdab5915a1dd08dcc7bbc24a28c69e30ae541e Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 30 Apr 2024 08:48:21 +1200 Subject: [PATCH 10/10] Add workflow job to PR new files into ESPHome (#92) --- .github/workflows/release.yaml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b648b96..3774334 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,6 +41,8 @@ jobs: name: Tag and Release runs-on: ubuntu-latest needs: build + outputs: + tag: ${{ steps.create_tag.outputs.tag }} steps: # Checkout repo, create new git tag, and git release with artifacts - name: Checkout the repo @@ -67,3 +69,41 @@ jobs: name: Release ${{ steps.create_tag.outputs.tag }} files: headers/**/*.h generate_release_notes: true + + esphome-pr: + name: Make PR into ESPHome repo + runs-on: ubuntu-latest + environment: esphome + needs: + - release + steps: + - name: Checkout esphome repo + uses: actions/checkout@v4.1.1 + with: + repository: esphome/esphome + ref: dev + + - name: Download Artifacts + uses: actions/download-artifact@v4.1.4 + with: + path: /tmp/headers + merge-multiple: true + + - name: Move headers into palce + run: |- + mv /tmp/headers/captive_portal/captive_index.h esphome/components/captive_portal/captive_index.h + mv /tmp/headers/v2/server_index_v2.h esphome/components/web_server/server_index_v2.h + mv /tmp/headers/v3/server_index_v3.h esphome/components/web_server/server_index_v3.h + + - name: PR Changes + uses: peter-evans/create-pull-request@v6.0.4 + with: + commit-message: "Update webserver local assets to ${{ needs.release.outputs.tag }}" + committer: esphomebot + author: esphomebot + branch: sync/webserver-assets + delete-branch: true + title: "Update webserver local assets to ${{ needs.release.outputs.tag }}" + body-path: .github/PULL_REQUEST_TEMPLATE.md + token: ${{ secrets.ESPHOME_WEBSERVER_SYNC_TOKEN }} + assignees: "@esphome/core"