-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHA-Roller.yaml
764 lines (725 loc) · 28.5 KB
/
HA-Roller.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# REALiAM: https://github.com/R34LiAM/HA-Roller
# Heavily inspried by PeterG: https://www.thingiverse.com/pgote/designs
# And RoadkillUK: https://github.com/RoadkillUK/Motor-on-a-Roller-Blind-for-ESPHOME
# Once the ESP has booted for the first time it's time for configuration
# Either access it's webGUI at <coverip>:80 or <hostname>.local:80 if you have mDNS, or use a hardwired button to configure it.
# I recommend wiring a button so the roller can be controlled "manually" at the window, See setup option 1 below
# If no button is wired see setup option 2 below for setup using the webGUI (intructions by RoadkillUK with abit of modifications by me)
# Setup option 1 (Recommended)
#-----------------------------
# This sketch also includes a momentary button on D7 which can be used in the following way
# 1) Press button for > 4 seconds and then release, to enter setup mode
# 2) Press button again to start closing the blind
# 3) Once the position you want as 100% closed (fully closed) is reached, press the button. The blind will instantly start to open again (actually resets the stepper position to 0)
# 4) Once the position you want as 100% open (fully open) is reached, press the button.
# 5) Job Done
# The button loops through states as: open/stop/close/stop/open....... once configured.
# Repeat from step 1 if you need to reconfigure it in the future.
# Setup option 2
#---------------
# 1) Turn on the Setup Switch to enter setup mode
# 2) Press Setup button to start the blind closing
# 3) Press Setup button again when closed and blind starts to open (actually resets the stepper position to 0)
# 4) Press Setup button again when blind is fully open
# 5) Job Done
# Add to you frontend of choice.
# Home Assistant using the ESPHhome integration or MQTT
# HomeKit using Homebridge and mqttthing or via Home Assistant's HomeKit integration
# And more...
# What has been changed added?!
# Added some extra sensors that report back to HA since they are availiable for free (uptime / reset button / wifi signal and so on)
# added support for stopping while rolling up and down and resume in the other direction using one button
# added ability to choose wether ESP should report back to HA continously or only when action has finished (combined the functionallity of RoadkillUK's two seperate scripts)
# added ability to switch stepper speed (slow/fast)/(silent/noisy) perfect for automations that run late at night when quiet operation is preferred over speed.
# Pretty much everything is customized in the "substitutions"-section below.
# If not using a "secrets"-file (which I recommend) you also have to change:
# !secret ota_password
# !secret wifi_ssid
# !secret wifi_password
# !secret api_password
# !secret ap_fallback_wifi_password
##########################################################
##########################################################
# CONTROL USING MQTT TOPICS
##########################################################
##########################################################
# If you enable MQTT and you do not use the “native API” for Home Assistant, comment out "api:" see here:
# https://esphome.io/components/mqtt.html
#
# The topics change according to your [hostname] defined
# under the substitutions section below. Example below
# is with hostname set to "rullgardin01"
# MQTT needs to be activated and configured below
#
# For current position, subscribe to the following topic:
# rullgardin01/cover/rullgardin01_roller/position/state
#
# To set position, publish to the following topic: (0-100, 0=close, 100=open)
# rullgardin01/cover/rullgardin01_roller/position/command
#
# To stop, closing or opening, publish the current position to the following topic:
# rullgardin01/cover/rullgardin01_roller/position/command
#
# To set "Silent drive switch", publish (ON/OFF) to the following topic:
# rullgardin01/switch/rullgardin01_drive_mode_silent/command
# rullgardin01/switch/rullgardin01_drive_mode_silent/command
#
# To set "Continous feedback switch", (ON/OFF) publish to the following topic:
# rullgardin01/switch/rullgardin01_continous_feedback/command
# rullgardin01/switch/rullgardin01_continous_feedback/command
#
# To Reboot ESP, publish (ON) to the following topic:
# rullgardin01/switch/rullgardin01_restart/command
#
##########################################################
##########################################################
# CONTROL USING POST TO REST API
##########################################################
##########################################################
# The calls change according to your [hostname] defined
# under the substitutions section below. Example below
# is with hostname set to "rullgardin01".
# Works with IP instead of .local if you don't use mDNS/Multicast
#
# Using POST you can control it using the following URL's
# Open:
# http://rullgardin01.local/cover/rullgardin01_roller/open
#
# Close:
# http://rullgardin01.local/cover/rullgardin01_roller/close
#
# Stop current operation (while opening or closing):
# http://rullgardin01.local/cover/rullgardin01_roller/stop
#
# Set position:
# fully closed:
# http://rullgardin01.local/cover/rullgardin01_roller/set?position=0.0
# fully open:
# http://rullgardin01.local/cover/rullgardin01_roller/set?position=1.0
# halfway open/closed:
# http://rullgardin01.local/cover/rullgardin01_roller/set?position=0.5
# And so on...
esphome:
name: $hostname
platform: ESP8266
board: nodemcuv2
esp8266_restore_from_flash: true
on_boot:
- priority: -200.0
then:
- text_sensor.template.publish:
id: current_status
state: 'Started'
- stepper.report_position: # Set stepper to global variable
id: $mystepper
position: !lambda return id(${mystepper}_global);
- stepper.set_target: # Set stepper to global variable
id: $mystepper
target: !lambda return id(${mystepper}_global);
- if: # If blind is Closed
condition:
- lambda: 'return id(${mystepper}_global) == 0;'
then: # Publish state etc.
- cover.template.publish:
id: blinded
state: CLOSED
- globals.set:
id: last_action
value: '2'
- text_sensor.template.publish:
id: current_status
state: 'Closed'
- if: # If blind is Open
condition:
- lambda: 'return id(${mystepper}_global) == id(endstop);'
then: # Publish state etc.
- cover.template.publish:
id: blinded
state: OPEN
current_operation: IDLE
- globals.set:
id: last_action
value: '0'
- text_sensor.template.publish:
id: current_status
state: 'Open'
- if: # If blind is Neither
condition:
- lambda: 'return (id(${mystepper}_global) != 0) && (id(${mystepper}_global) != id(endstop));'
then: # # Publish state etc.
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: IDLE
- globals.set:
id: last_action
value: '0'
- text_sensor.template.publish:
id: current_status
state: !lambda |-
int pos = round(float(float(id($mystepper).current_position) / float(id(endstop))) * 100);
return (
("Open: ") +
(pos ? String(pos) + "%" : "")
).c_str();
## Substitutions
substitutions:
hostname: "rullgardin01" #hostname/devicename/esphome sensors (keep lcase)
friendly_name: 'Vardagsrum stora fönstret' #More easily identify you roller
coverip: "192.168.x.x" #static IP
covergatway: "192.168.x.x"
coversubnet: "255.255.255.0"
speed: 600 steps/s # Set the speed of the motor 600 ok for 6vdc@300ma (actually 7.6vdc) from ikea screwdriver for a fridans of 140 in width
silentspeed: 100 steps/s # Set the speed of silent drive 100 near audible.
#mqtt-broker ip, uncomment to use and don't forget to uncomment in the MQTT section below as well
#mqtt_broker_ip: "192.168.x.x"
#uncomment pina, pinb and pinc for the microcontroller you are using
#wemos d1 mini
#pinButton: TX # physical button to controll roller (up/stop/down/stop/up.......) (hold for ~5 seconds to enter setup mode/press once to start closing,press again at maximum-/bottom position,lastly press at minimum-/top position)
#pinReedSwitch: RX #Used for window reed(magnetic) sensor
#pinXtra: D1 #Used for something
#pina: D4
#pinb: D3
#pinc: D2
#nodemcu v2/v3
pinButton: D7 # physical button to controll roller (up/stop/down/stop/up.......) (hold for ~5 seconds to enter setup mode/press once to start closing,press again at maximum-/bottom position,lastly press at minimum-/top position)
pinReedSwitch: D6 #Used for window reed(magnetic) sensor
#pinXtra: D5 #Used for something
pina: TX
pinb: RX
pinc: D8
mystepper: my_stepper # Name of the stepper motor (leave as is)
delaybetweenupdates: 999 ms # milliseconds between pushing updates to home assistant (for the lulz, feel free to set 1000 ms if annoyed =P)
## WIFI
wifi:
power_save_mode: none
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
manual_ip:
static_ip: $coverip
gateway: $covergatway
subnet: $coversubnet
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "$hostname Hotspot"
password: !secret ap_fallback_wifi_password
## Webserver
web_server:
port: 80
## Enable logging
logger:
# level: VERBOSE
## Enable Home Assistant API
## Comment out if not using Home Assistant
api:
password: !secret api_password
reboot_timeout: 120s
## MQTT
## Uncomment below if you want to control it using MQTT
#mqtt:
# broker: $mqtt_broker_ip
# username:
# password:
## Captive portal
captive_portal:
## OTA
ota:
password: !secret ota_password
## Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
## Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: '$hostname ESPHome Version'
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: '$hostname IP'
ssid:
name: '$hostname SSID'
bssid:
name: '$hostname BSSID'
mac_address:
name: "$hostname MAC"
- platform: template
name: '$hostname Friendly Name'
icon: 'mdi:information-outline'
lambda: |-
return {"$friendly_name"};
- platform: template
name: '$hostname Status'
update_interval: never
id: current_status
icon: 'mdi:chart-box-outline'
- platform: template
name: $hostname Uptime HR
id: uptime_human
icon: mdi:clock-start
## Buttons
button:
# Button to restart the device
- platform: restart
name: '$hostname Restart'
- platform: template
name: ${hostname} Setup Button # Button to replicate the Physical Button once Settings Mode has been entered
icon: 'mdi:gesture-tap-button'
on_press:
- if: # If settings variable is on
condition:
- lambda: 'return id(settingmode) != 0;'
then: # Enter Setting Mode
- script.execute: setupbutton
## Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: '$hostname Uptime'
id: 'upptime'
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(upptime).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
# WiFi Signal sensor.
- platform: wifi_signal
name: '$hostname WiFi Signal'
update_interval: 120s
## Binary sensors
binary_sensor:
- platform: gpio
pin:
number: $pinButton # Connect Button to D1 and GND
mode: INPUT_PULLUP
inverted: true
name: '$hostname Button'
internal: true
on_click:
- min_length: 50ms
max_length: 500ms
then: # Short press to OPEN/CLOSE blinds and also for setting up
- if: # If settings variable is on
condition:
- lambda: 'return id(settingmode) != 0;'
then: # Enter Setting Mode
- script.execute: setupbutton
else:
- if: # If blind is stopped while opening #0=STOPPED WHILE OPENING
condition:
- lambda: 'return id(last_action) == 0;'
then:
- text_sensor.template.publish:
id: current_status
state: 'Closing...'
- globals.set:
id: last_action
value: '1'
- lambda: 'auto call = id(blinded).make_call().set_command_close(); call.perform();'
else:
- if: # If blind is moving down #1=MOVING DOWN
condition:
- lambda: 'return id(last_action) == 1;'
then:
- text_sensor.template.publish:
id: current_status
state: !lambda |-
int pos = round(float(float(id($mystepper).current_position) / float(id(endstop))) * 100);
return (
(pos ? String(pos) + "% open" : "") +
(" / Stopped while closing")
).c_str();
- globals.set:
id: last_action
value: '2'
- lambda: 'auto call = id(blinded).make_call().set_command_stop(); call.perform();'
else:
- if: # If blind is stopped while closing #2=STOPPED WHILE CLOSING
condition:
- lambda: 'return id(last_action) == 2;'
then:
- text_sensor.template.publish:
id: current_status
state: 'Opening...'
- globals.set:
id: last_action
value: '3'
- lambda: 'auto call = id(blinded).make_call().set_command_open(); call.perform();'
else:
- if: # If blind is moving up #3=MOVING UP
condition:
- lambda: 'return id(last_action) == 3;'
then:
- text_sensor.template.publish:
id: current_status
state: !lambda |-
int pos = round(float(float(id($mystepper).current_position) / float(id(endstop))) * 100);
return (
(pos ? String(pos) + "% open" : "") +
(" / Stopped while opening")
).c_str();
- globals.set:
id: last_action
value: '0'
- lambda: 'auto call = id(blinded).make_call().set_command_stop(); call.perform();'
- min_length: 4000ms
max_length: 10000ms
then: # Long press to Enter Setting Mode (4-10 Sec press)
- logger.log: 'Entered Settings Mode'
## TODO: blink wemos D1 mini onboard LED when in settings mode
- globals.set:
id: settingmode
value: '1'
- text_sensor.template.publish:
id: current_status
state: 'Setup activated, click to start'
- platform: gpio
pin:
number: $pinReedSwitch
mode: INPUT_PULLUP
name: '$hostname Window'
filters:
- delayed_on: 999ms
device_class: window
## Stepper
stepper:
- platform: a4988
id: $mystepper
dir_pin:
number: $pina
inverted: false
step_pin:
number: $pinb
inverted: false
sleep_pin:
number: $pinc
inverted: false
max_speed: ${speed} # Speed of the motor
acceleration: inf
deceleration: inf
## Globals
globals:
- id: ${mystepper}_global # Integer for storing the stepper position in case of reboot
type: int
restore_value: true
initial_value: '0'
- id: openclosed # Boolean to store OPEN/CLOSED state
type: bool
restore_value: true
initial_value: '0'
- id: endstop # Variable for storing ENDSTOP (how far to move stepper)
type: int
restore_value: true
initial_value: '1000'
- id: settingmode # Integer for Setup Mode
type: int
restore_value: no
initial_value: '0'
- id: drivemode # Boolean for Silent Drive Mode
type: bool
restore_value: no
initial_value: '0' # Default value for stepper drive mode/speed: Set to '1' for silent / Set to '0' for speed
- id: feedback # Boolean for continous feedback
type: bool
restore_value: no
initial_value: '1' # Default value for continous feedback: Set to '1' and the cover reports back current position continously / Set to '0' and the cover updates in the beginning and end of the requested operation
- id: last_action # Integer for last action
type: int
restore_value: no
# initial_value: '0'
#0=STOPPED WHILE OPENING
#1=CLOSING / MOVING DOWN
#2=STOPPED WHILE CLOSING
#3=OPENING / MOVING UP
## Switch
switch:
- platform: template
name: '$hostname Activate Setup' # Switch to enter Setup Mode
icon: 'mdi:cog-outline'
id: setupswitch
lambda: |-
if (id(settingmode) != 0) {
return true;
} else {
return false;
}
turn_on_action:
then:
- logger.log: 'Entered Settings Mode'
- globals.set:
id: settingmode
value: '1'
- text_sensor.template.publish:
id: current_status
state: 'Setup activated, click to start'
turn_off_action:
then:
- logger.log: 'Exiting Settings Mode'
- globals.set:
id: settingmode
value: '0'
- text_sensor.template.publish:
id: current_status
state: 'Setup cancelled'
- platform: template
icon: 'mdi:tortoise'
name: '$hostname Drive Mode Silent' # Switch to activate silent drive mode
id: drivemodeswitch
lambda: |-
if (id(drivemode) != 0) {
return true;
} else {
return false;
}
restore_state: false
turn_on_action:
- logger.log: 'Drive Mode Silent'
- globals.set:
id: drivemode
value: '1'
- stepper.set_speed:
id: $mystepper
speed: ${silentspeed}
turn_off_action:
- logger.log: 'Drive Mode Speed'
- globals.set:
id: drivemode
value: '0'
- stepper.set_speed:
id: $mystepper
speed: ${speed}
- platform: template
icon: 'mdi:sync'
name: '$hostname Continous Feedback' # Switch to activate continous feedback
id: feedbackswitch
lambda: |-
if (id(feedback) != 0) {
return true;
} else {
return false;
}
restore_state: false
turn_on_action:
- logger.log: 'Activated Continous Feedback'
- globals.set:
id: feedback
value: '1'
turn_off_action:
- logger.log: 'Disabled Continous Feedback'
- globals.set:
id: feedback
value: '0'
## Cover
cover:
- platform: template
name: '$hostname Roller'
id: blinded
open_action:
then:
- logger.log: 'Opening'
- stepper.set_target: # Send stepper to endstop
id: $mystepper
target: !lambda return id(endstop);
- if: # If continous feedback switch is on
condition:
- lambda: 'return id(feedback) != 0;'
then: # with continous feedback
- while:
condition:
lambda: 'return id($mystepper).current_position != id(endstop);'
then:
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: OPENING
- delay: ${delaybetweenupdates}
else: # without continous feedback
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: OPENING
- wait_until: # Wait until endstop reached
lambda: 'return (id($mystepper).current_position == id(endstop));'
- globals.set: # Set global to current position
id: ${mystepper}_global
value: !lambda return id($mystepper).current_position;
- globals.set: # Set toggle to OPEN (No need for 'optimistic mode')
id: openclosed
value: '1'
- cover.template.publish:
id: blinded
state: OPEN
current_operation: IDLE
- globals.set:
id: last_action
value: '0'
- text_sensor.template.publish:
id: current_status
state: 'Open'
close_action:
then:
- logger.log: 'Closing'
- stepper.set_target: # Send stepper to 0
id: $mystepper
target: '0'
- if: # If continous feedback switch is on
condition:
- lambda: 'return id(feedback) != 0;'
then: # with continous feedback
- while:
condition:
lambda: 'return id($mystepper).current_position != 0;'
then:
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: CLOSING
- delay: ${delaybetweenupdates}
else: # without continous feedback
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: CLOSING
- wait_until: # Wait until endstop reached
lambda: 'return id($mystepper).current_position == 0;'
- globals.set: # Set global to current position
id: ${mystepper}_global
value: !lambda return id($mystepper).current_position;
- globals.set: # Set toggle to CLOSED (No need for 'optimistic mode')
id: openclosed
value: '0'
- cover.template.publish:
id: blinded
state: CLOSED
current_operation: IDLE
- globals.set:
id: last_action
value: '2'
- text_sensor.template.publish:
id: current_status
state: 'Closed'
position_action:
then:
- stepper.set_target:
id: $mystepper
target: !lambda return int(id(endstop) * pos);
- if: # If continous feedback switch is on
condition:
- lambda: 'return id(feedback) != 0;'
then: # with continous feedback
- while:
condition:
lambda: 'return id($mystepper).current_position != int(id(endstop) * pos);'
then:
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
- delay: ${delaybetweenupdates}
else: # without continous feedback
- wait_until: # Wait until endstop reached
lambda: 'return id($mystepper).current_position == (int(id(endstop) * pos));'
- globals.set: # Set global to current position
id: ${mystepper}_global
value: !lambda return id($mystepper).current_position;
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: IDLE
stop_action:
then:
- stepper.set_target:
id: $mystepper
target: !lambda return id($mystepper).current_position;
- globals.set: # Set global to current position
id: ${mystepper}_global
value: !lambda return id($mystepper).current_position;
- cover.template.publish:
id: blinded
position: !lambda 'return (float(float(id($mystepper).current_position) / float(id(endstop))));'
current_operation: IDLE
has_position: true
device_class: blind
## Scripts
script:
- id: setupbutton
then:
- if:
condition:
- lambda: 'return (id(settingmode) == 3);'
then:
- logger.log: 'Pressed Setup Button: Mode 3'
- stepper.set_target: # Set Stepper position
id: $mystepper
target: !lambda return id($mystepper).current_position;
- globals.set: # Set Endstop Variable
id: endstop
value: !lambda return id($mystepper).current_position;
- globals.set: # Set Global stepper position
id: ${mystepper}_global
value: !lambda return id($mystepper).current_position;
- globals.set: # Reset Setting Mode
id: settingmode
value: '0'
- globals.set: # Set toggle to Open
id: openclosed
value: '1'
- cover.template.publish:
id: blinded
state: OPEN
current_operation: IDLE
- logger.log: 'Exiting Setting Mode'
- text_sensor.template.publish:
id: current_status
state: 'Setup complete'
- if:
condition:
- lambda: 'return (id(settingmode) == 2);'
then:
- logger.log: 'Pressed Setup Button: Mode 2'
- stepper.report_position: # Reset Stepper position to 0
id: $mystepper
position: '0'
- stepper.set_target: # Reset Stepper position to 0
id: $mystepper
target: '0'
- globals.set: # Move stepper to 0 (doesn't move it's already there!)
id: ${mystepper}_global
value: '0'
- stepper.set_target: # Reset Stepper position to 72000
id: $mystepper
target: '720000'
- globals.set: # Advance setup to next mode
id: settingmode
value: '3'
- text_sensor.template.publish:
id: current_status
state: 'Click once at top positon'
- if:
condition:
- lambda: 'return (id(settingmode) == 1);'
then:
- logger.log: 'Pressed Setup Button: Mode 1'
- stepper.report_position: # Set Stepper position to 72000, makes it move to 0 (Closed)
id: $mystepper
position: '720000'
- globals.set: # Advance setup to next mode
id: settingmode
value: '2'
- text_sensor.template.publish:
id: current_status
state: 'Click once at bottom position'