-
Notifications
You must be signed in to change notification settings - Fork 0
/
office-blinds.yaml
93 lines (86 loc) · 2.08 KB
/
office-blinds.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
---
esphome:
name: iot-office-blinds
platform: ESP8266
board: d1_mini
esp8266_restore_from_flash: true
on_boot:
priority: 700.0
then:
- stepper.report_position:
id: blinds_stepper
position: !lambda return id(stepper_position);
- stepper.set_target:
id: blinds_stepper
target: !lambda return id(stepper_position);
wifi:
ssid: "IoT"
domain: .i.thepromisedlan.club
password: !secret iot_wifi_key
fast_connect: true
logger:
api:
services:
- service: control_stepper
variables:
target: int
then:
- stepper.set_target:
id: blinds_stepper
target: !lambda "return target;"
ota:
globals:
- id: stepper_position
type: float
restore_value: true
stepper:
- platform: uln2003
id: blinds_stepper
pin_a: GPIO5
pin_b: GPIO4
pin_c: GPIO0
pin_d: GPIO2
max_speed: 1019 steps/s
step_mode: FULL_STEP
sleep_when_done: true
cover:
- platform: template
id: office_blinds
name: "Office Blinds"
device_class: blind
assumed_state: false
has_position: true
lambda: |-
if (id(blinds_stepper).current_position < -10) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- stepper.set_target:
id: blinds_stepper
target: "-13000"
- globals.set:
id: stepper_position
value: "-13000"
close_action:
- stepper.set_target:
id: blinds_stepper
target: "0"
- globals.set:
id: stepper_position
value: "0"
position_action:
- stepper.set_target:
id: blinds_stepper
target: !lambda return int(-13000 * pos);
- globals.set:
id: stepper_position
value: !lambda return int(-13000 * pos);
stop_action:
- globals.set:
id: stepper_position
value: !lambda return id(blinds_stepper).current_position;
- stepper.set_target:
id: blinds_stepper
target: !lambda return id(blinds_stepper).current_position;