Skip to content

EU86 4 relay support #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
237 changes: 202 additions & 35 deletions tx_ultimate_local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ substitutions:
toggle_relay_1_on_touch: "true"
toggle_relay_2_on_touch: "true"
toggle_relay_3_on_touch: "true"
toggle_relay_4_on_touch: "true"

vibra_time: 150ms
button_on_time: 500ms
Expand Down Expand Up @@ -81,6 +82,9 @@ esphome:
- binary_sensor.template.publish:
id: touchfield_3
state: OFF
- binary_sensor.template.publish:
id: touchfield_4
state: OFF
- binary_sensor.template.publish:
id: multi_touch
state: OFF
Expand Down Expand Up @@ -166,9 +170,7 @@ globals:
- id: touch_color
type: int [3]
restore_value: no
initial_value: ${touch_color}


initial_value: ${touch_color}

binary_sensor:
- platform: template
Expand Down Expand Up @@ -216,6 +218,21 @@ binary_sensor:
state: OFF
- script.execute: refresh_led_default

- platform: template
name: "Touchfield 4"
id: touchfield_4
on_press:
- if:
condition:
lambda: "return ${toggle_relay_4_on_touch};"
then:
- switch.toggle: relay_4
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: touchfield_4
state: OFF
- script.execute: refresh_led_default

- platform: template
name: "Swipe left"
id: swipe_left
Expand Down Expand Up @@ -293,6 +310,18 @@ switch:
then:
- script.execute: refresh_led_default

- platform: gpio
id: relay_4
name: "${friendly_name} L4"
pin: ${relay_4_pin}
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- script.execute: refresh_led_default
on_turn_off:
then:
- script.execute: refresh_led_default

- platform: gpio
id: vibra
pin: ${vibra_motor_pin}
Expand Down Expand Up @@ -375,24 +404,32 @@ light:
internal: true
segments:
- id: leds
from: 7
to: 7
from: 6
to: 6
- platform: partition
name: "LEDs Button middle"
id: leds_button_middle
name: "LEDs Button middle_right"
id: leds_button_middle_right
internal: true
segments:
- id: leds
from: 9
to: 9
from: 8
to: 8
- platform: partition
name: "LEDs Button middle left"
id: leds_button_middle_left
internal: true
segments:
- id: leds
from: 10
to: 10
- platform: partition
name: "LEDs Button left"
id: leds_button_left
internal: true
segments:
- id: leds
from: 11
to: 11
from: 12
to: 12

- platform: partition
name: "LEDs Nightlight"
Expand All @@ -401,22 +438,25 @@ light:
segments:
- id: leds
from: 0
to: 6
to: 5
- id: leds
from: 8
to: 8
from: 7
to: 7
- id: leds
from: 10
to: 10
from: 9
to: 9
- id: leds
from: 12
from: 11
to: 11
- id: leds
from: 13
to: 19
- id: leds
from: 27
to: 27
- id: leds_top
from: 0
to: 6
to: 5

- platform: partition
name: "LEDs Top"
Expand Down Expand Up @@ -575,27 +615,93 @@ script:

- if:
condition:
lambda: "return (${relay_count}>1 && id(relay_1).state) ;"
lambda: "return ${relay_count}==1;"
then:
- script.execute: led_on_button_left
else:
- script.execute: led_off_button_left
- if:
condition:
lambda: "return id(relay_1).state;"
then:
- script.execute: led_on_button_middle_right
else:
- script.execute: led_off_button_middle_right

- if:
condition:
lambda: "return (${relay_count}==3 && id(relay_2).state) || (${relay_count}==1 && id(relay_1).state);"
lambda: "return ${relay_count}==2;"
then:
- script.execute: led_on_button_middle
else:
- script.execute: led_off_button_middle
- if:
condition:
lambda: "return (id(relay_1).state);"
then:
- script.execute: led_on_button_left
else:
- script.execute: led_off_button_left
- if:
condition:
lambda: "return id(relay_2).state;"
then:
- script.execute: led_on_button_right
else:
- script.execute: led_off_button_right

- if:
condition:
lambda: "return (${relay_count}==2 && id(relay_2).state) || (${relay_count}==3 && id(relay_3).state);"
lambda: "return ${relay_count}==3;"
then:
- script.execute: led_on_button_right
else:
- script.execute: led_off_button_right
- if:
condition:
lambda: "return (id(relay_1).state);"
then:
- script.execute: led_on_button_left
else:
- script.execute: led_off_button_left
- if:
condition:
lambda: "return id(relay_2).state;"
then:
- script.execute: led_on_button_middle_right
else:
- script.execute: led_off_button_middle_right
- if:
condition:
lambda: "return id(relay_3).state;"
then:
- script.execute: led_on_button_right
else:
- script.execute: led_off_button_right

- if:
condition:
lambda: "return ${relay_count}==4;"
then:
- if:
condition:
lambda: "return (id(relay_1).state);"
then:
- script.execute: led_on_button_left
else:
- script.execute: led_off_button_left
- if:
condition:
lambda: "return id(relay_2).state;"
then:
- script.execute: led_on_button_middle_left
else:
- script.execute: led_off_button_middle_left
- if:
condition:
lambda: "return id(relay_3).state;"
then:
- script.execute: led_on_button_middle_right
else:
- script.execute: led_off_button_middle_right
- if:
condition:
lambda: "return id(relay_4).state;"
then:
- script.execute: led_on_button_right
else:
- script.execute: led_off_button_right

- if:
condition:
Expand All @@ -615,16 +721,26 @@ script:
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"

- id: led_on_button_middle
- id: led_on_button_middle_left
mode: restart
then:
- light.turn_on:
id: leds_button_middle
id: leds_button_middle_left
brightness: ${button_brightness}
red: !lambda "return id(button_color)[0]/100.0;"
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"

- id: led_on_button_middle_right
mode: restart
then:
- light.turn_on:
id: leds_button_middle_right
brightness: ${button_brightness}
red: !lambda "return id(button_color)[0]/100.0;"
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"

- id: led_on_button_right
mode: restart
then:
Expand Down Expand Up @@ -653,23 +769,39 @@ script:
- light.turn_off:
id: leds_button_left

- id: led_off_button_middle
- id: led_off_button_middle_left
mode: restart
then:
- if:
condition:
lambda: "return id(nightlight).state || id(nightlight_active).state;"
then:
- light.turn_on:
id: leds_button_middle
id: leds_button_middle_left
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
else:
- light.turn_off:
id: leds_button_middle
id: leds_button_middle_left

- id: led_off_button_middle_right
mode: restart
then:
- if:
condition:
lambda: "return id(nightlight).state || id(nightlight_active).state;"
then:
- light.turn_on:
id: leds_button_middle_right
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
else:
- light.turn_off:
id: leds_button_middle_right

- id: led_off_button_right
mode: restart
Expand Down Expand Up @@ -820,6 +952,41 @@ script:
id: touchfield_3
state: ON

- if:
condition:
lambda: "return ${relay_count}==4;"
then:
- if:
condition:
lambda: "return pos <= 2;"
then:
- binary_sensor.template.publish:
id: touchfield_1
state: ON

else:
- if:
condition:
lambda: "return pos <= 5;"
then:
- binary_sensor.template.publish:
id: touchfield_2
state: ON

else:
- if:
condition:
lambda: "return pos <= 8;"
then:
- binary_sensor.template.publish:
id: touchfield_3
state: ON

else:
- binary_sensor.template.publish:
id: touchfield_4
state: ON

- id: touch_led_marker
mode: restart
parameters:
Expand Down