-
Notifications
You must be signed in to change notification settings - Fork 0
/
ikea-ps-light.yaml
125 lines (110 loc) · 2.42 KB
/
ikea-ps-light.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
esphome:
name: ikea-ps-light
friendly_name: "IKEA PS Light"
on_boot:
priority: -100
then:
lambda: |-
id(cover_status).publish_state("Unknown");
esp8266:
board: d1_mini
# Enable loggings
logger:
# Enable Home Assistant API
api:
password: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ikea-Ps-Light Fallback Hotspot"
password: !secret fallback_ap_password
captive_portal:
servo:
- id: light_servo
output: pwm_output
output:
- platform: esp8266_pwm
id: pwm_output
pin: D1
frequency: 50 Hz
binary_sensor:
- platform: gpio
pin:
number: D2
mode:
input: true
pullup: true
inverted: true
name: Endstop
id: endstop_switch
icon: "mdi:electric-switch"
filters:
- delayed_on: 50ms
- delayed_off: 50ms
on_press:
then:
- servo.write:
id: light_servo
level: 0%
- lambda: |-
id(cover_status).publish_state("Open");
number:
- platform: template
id: close_delay
name: Close delay
min_value: 0
max_value: 20000
step: 100
initial_value: 11000
restore_value: true
optimistic: true
button:
- platform: template
name: Open
id: open_button
icon: "mdi:arrow-expand-horizontal"
on_press:
- if:
condition:
binary_sensor.is_off: endstop_switch
then:
- lambda: |-
id(cover_status).publish_state("Opening");
- servo.write:
id: light_servo
level: -25%
- platform: template
name: Close
id: close_button
icon: "mdi:arrow-collapse-horizontal"
on_press:
- lambda: |-
id(cover_status).publish_state("Closing");
- servo.write:
id: light_servo
level: 25%
- delay: !lambda "return id(close_delay).state;"
- servo.write:
id: light_servo
level: 0%
- lambda: |-
id(cover_status).publish_state("Closed");
- platform: template
name: Stop
id: stop_button
icon: "mdi:stop"
on_press:
- servo.write:
id: light_servo
level: 0%
text_sensor:
- platform: template
name: "Cover status"
id: cover_status
update_interval: never
lambda: |-
return {};