From 2d69512dce8dfcc6699d12b8aaee2936f190a02f Mon Sep 17 00:00:00 2001 From: madmicio Date: Sun, 7 Apr 2024 19:39:49 +0200 Subject: [PATCH] home_long_press --- src/lg-remote-control.ts | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/lg-remote-control.ts b/src/lg-remote-control.ts index 5f9cbcc..28d2816 100644 --- a/src/lg-remote-control.ts +++ b/src/lg-remote-control.ts @@ -45,6 +45,9 @@ class LgRemoteControl extends LitElement { private soundOutput: string; private output_entity: string; private valueDisplayTimeout: NodeJS.Timeout; + private homeisLongPress: boolean = false; + private homelongPressTimer: any; // Tipo generico, ma puoi specificare il tipo corretto se lo conosci + static getConfigElement() { // Create and return an editor element @@ -82,7 +85,8 @@ class LgRemoteControl extends LitElement { _show_keypad: {}, _show_vol_text: {}, volume_value: { type: Number, reflect: true }, - output_entity: { type: Number, reflect: true } + output_entity: { type: Number, reflect: true }, + }; } @@ -262,7 +266,17 @@ class LgRemoteControl extends LitElement {
- + + + + + + + + + @@ -464,6 +478,21 @@ class LgRemoteControl extends LitElement { } } + _homeButtonDown(event: MouseEvent | TouchEvent) { + this.homeisLongPress = false; + this.homelongPressTimer = setTimeout(() => { + this.homeisLongPress = true; + this._button("MENU") + }, 1000); // Tempo in millisecondi per determinare una pressione prolungata + } + + _homeButtonUp(event: MouseEvent | TouchEvent) { + clearTimeout(this.homelongPressTimer); + if (!this.homeisLongPress) { + this._button("HOME") + } + } + _select_source(source) { this.hass.callService("media_player", "select_source", {