upd: hw-button hold

This commit is contained in:
deejaybeam
2023-02-02 17:52:41 +01:00
parent a46b3ad20b
commit 276524686a
2 changed files with 48 additions and 38 deletions

View File

@@ -345,15 +345,11 @@ binary_sensor:
inverted: true
on_click:
- min_length: 50ms
max_length: 999ms
max_length: 1000ms
then:
- binary_sensor.template.publish:
id: left_button_short
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: left_button_short
state: OFF
- if:
condition:
and:
@@ -369,28 +365,35 @@ binary_sensor:
switch.is_on: relay_1
then:
- lambda: id(disp1).send_command_printf("home.icon_top_01.pic=105");
- min_length: 1000ms
max_length: 10000ms
then:
- binary_sensor.template.publish:
id: left_button_hold
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: left_button_hold
id: left_button_short
state: OFF
on_press:
then:
- lambda: |-
if (id(disp1_currentpage).state == "lightsettings" or id(disp1_currentpage).state == "coversettings") {
ESP_LOGD("nspanel", "settingspage -> no press");
} else {
// ESP_LOGD("nspanel", "release button");
id(disp1_lastclick_general).set_state("pressbuttonleft",true,true);
}
on_release:
then:
- lambda: |-
if (id(disp1_currentpage).state == "lightsettings" or id(disp1_currentpage).state == "coversettings") {
ESP_LOGD("nspanel", "settingspage -> no release");
} else {
// ESP_LOGD("nspanel", "release button");
id(disp1_lastclick_general).set_state("releasebuttonleft",true,true);
}
- platform: template
name: ${device_name} Left Button
id: left_button_short
lambda: |-
return {};
- platform: template
name: ${device_name} Left Button hold
id: left_button_hold
lambda: |-
return {};
##### RIGHT BUTTON BELOW DISPLAY TO TOGGLE RELAY #####
- platform: gpio
@@ -401,15 +404,11 @@ binary_sensor:
inverted: true
on_click:
- min_length: 50ms
max_length: 999ms
max_length: 1000ms
then:
- binary_sensor.template.publish:
id: right_button_short
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: right_button_short
state: OFF
- if:
condition:
and:
@@ -425,29 +424,34 @@ binary_sensor:
switch.is_on: relay_2
then:
- lambda: id(disp1).send_command_printf("home.icon_top_02.pic=106");
- min_length: 1000ms
max_length: 10000ms
then:
- binary_sensor.template.publish:
id: right_button_hold
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: right_button_hold
id: right_button_short
state: OFF
on_press:
then:
- lambda: |-
if (id(disp1_currentpage).state == "lightsettings" or id(disp1_currentpage).state == "coversettings") {
ESP_LOGD("nspanel", "settingspage -> no press");
} else {
// ESP_LOGD("nspanel", "release button");
id(disp1_lastclick_general).set_state("pressbuttonright",true,true);
}
on_release:
then:
- lambda: |-
if (id(disp1_currentpage).state == "lightsettings" or id(disp1_currentpage).state == "coversettings") {
ESP_LOGD("nspanel", "settingspage -> no release");
} else {
// ESP_LOGD("nspanel", "release button");
id(disp1_lastclick_general).set_state("releasebuttonright",true,true);
}
- platform: template
name: ${device_name} Right Button
id: right_button_short
lambda: |-
return {};
- platform: template
name: ${device_name} Right Button hold
id: right_button_hold
lambda: |-
return {};
##### Restart NSPanel Button - Setting Page #####
- platform: nextion