-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfourway-valve-control.yaml
130 lines (114 loc) · 2.84 KB
/
fourway-valve-control.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
esphome:
name: fourway-valve-control
platform: ESP32
board: featheresp32
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
web_server:
port: 80
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
number:
- platform: template
id: test_servo_control
name: Test Servo Control
min_value: -100
initial_value: 0
max_value: 100
step: 1
optimistic: true
set_action:
then:
- servo.write:
id: valve_servo
level: !lambda 'return x / 100.0;'
sensor:
- platform: homeassistant
entity_id: sensor.fourway_valve_servo
id: valve_servo_value
on_value:
- servo.write:
id: valve_servo
level: !lambda 'return x / -100.0;'
- platform: homeassistant
entity_id: sensor.fourway_valve_position
id: valve_position
- platform: wifi_signal
name: fourway_valve_wifi_signal
update_interval: 30s
servo:
- id: valve_servo
output: servo_pwm
auto_detach_time: 2s
transition_length: 5s
min_level: 2.5%
idle_level: 7.5%
max_level: 12.5%
output:
- platform: ledc
pin: GPIO27
id: servo_pwm
frequency: 50Hz
channel: 0 # https://github.com/esphome/issues/issues/3114
- platform: ledc
pin: GPIO4
id: backlight_pwm
channel: 2
# small motor (continuos)
# range 700us - 2300us
# pulse_width 1_000_000 / 50Hz = 20_000us
# min_level: 700 / 20_000.0 * 100 = 3.5
# max_level 2300 / 20_000.0 * 100 = 11.5
# TD-8120MG
# https://www.tinytronics.nl/product_files/002172_Data%20Sheet%20of%20TD-8120MG%20Digital%20Servo%20Motor.pdf
# mid motor
# range 500us - 2500us, neutral 1500us
# ---------------------------------------
# pulse_width 1_000_000 / 50Hz = 20_000us
# min_level 500 / 20_000.0 * 100 = 2.5
# idle_level 1500 / 20_000.0 * 100 = 7.5
# max_level 2500 / 20_000.0 * 100 = 12.5
# ----------------------------------------
# pulse_width 1_000_000 / 100Hz = 10_000us
# min_level 500 / 10_000.0 * 100 = 5.0
# idle_level 1500 / 10_000.0 * 100 = 15.0
# max_level 2500 / 10_000.0 * 100 = 25.0
# ----------------------------------------
# servo tester
# pulse_width 1_000_000 / 50Hz = 20_000us
# min_level 4.5% = 900us
# idle_level 7.5% = 1500us
# max_level 10.5% = 2100us
font:
- id: l
file: "fonts/BebasNeue-Regular.ttf"
size: 70
display:
- id: fourway_display
platform: ili9xxx
model: ST7789V
#TTGO TDisplay 135x240
dimensions:
height: 240
width: 135
offset_height: 40
offset_width: 52
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 270°
invert_colors: true
lambda: |-
it.printf(20, 20, id(l), "%.0f%% %.0f", id(valve_position).state, id(valve_servo_value).state);
light:
- platform: monochromatic
output: backlight_pwm
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_ON
logger:
api:
ota:
platform: esphome