diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index cc84601..75344d7 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -338,49 +338,116 @@ binary_sensor: ###### LEFT BUTTON BELOW DISPLAY TO TOGGLE RELAY##### - platform: gpio - name: ${device_name} Left Button + # name: ${device_name} Left Button + id: left_button pin: number: 14 inverted: true on_click: - if: - condition: - and: - - switch.is_on: relay1_fallback - - not: - api.connected: - then: - - switch.toggle: relay_1 - - lambda: id(disp1).send_command_printf("home.icon_top_01.pic=51"); - - lambda: id(disp1).send_command_printf("home.left_bt_pic.pic=98"); - - if: - condition: - switch.is_on: relay_1 - then: - - lambda: id(disp1).send_command_printf("home.icon_top_01.pic=105"); + - min_length: 50ms + max_length: 999ms + 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: + - switch.is_on: relay1_fallback + - not: + api.connected: + then: + - switch.toggle: relay_1 + - lambda: id(disp1).send_command_printf("home.icon_top_01.pic=51"); + - lambda: id(disp1).send_command_printf("home.left_bt_pic.pic=98"); + - if: + condition: + 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 + state: OFF + + - 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 - name: ${device_name} Right Button + # name: ${device_name} Right Button + id: right_button pin: number: 27 inverted: true on_click: - if: - condition: - and: - - switch.is_on: relay2_fallback - - not: - api.connected: - then: - - switch.toggle: relay_2 - - lambda: id(disp1).send_command_printf("home.icon_top_02.pic=51"); - - lambda: id(disp1).send_command_printf("home.right_bt_pic.pic=98"); - - if: - condition: - switch.is_on: relay_2 - then: - - lambda: id(disp1).send_command_printf("home.icon_top_02.pic=106"); + - min_length: 50ms + max_length: 999ms + 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: + - switch.is_on: relay2_fallback + - not: + api.connected: + then: + - switch.toggle: relay_2 + - lambda: id(disp1).send_command_printf("home.icon_top_02.pic=51"); + - lambda: id(disp1).send_command_printf("home.right_bt_pic.pic=98"); + - if: + condition: + 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 + state: OFF + + - 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