Skip to content

Commit ead72e9

Browse files
committed
buttons for testing
1 parent 1240b00 commit ead72e9

File tree

3 files changed

+174
-21
lines changed

3 files changed

+174
-21
lines changed

base.yaml

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,97 @@ button:
218218
on_press:
219219
then:
220220
lambda: !lambda |-
221-
id($id_prefix).sync();
221+
id($id_prefix).sync();
222+
223+
- platform: template
224+
id: ${id_prefix}_GET_TTC_DURATION
225+
name: "Request TTC current duration"
226+
entity_category: diagnostic
227+
on_press:
228+
then:
229+
lambda: !lambda |-
230+
id($id_prefix).get_ttc_duration();
231+
232+
- platform: template
233+
id: ${id_prefix}_CANCEL_TTC_OFF
234+
name: "Turn TTC Off"
235+
entity_category: diagnostic
236+
on_press:
237+
then:
238+
lambda: !lambda |-
239+
id($id_prefix).turn_ttc_off();
240+
241+
- platform: template
242+
id: ${id_prefix}_CANCEL_TTC_TOGGLE_HOLD
243+
name: "Toggle TTC Hold Open"
244+
entity_category: diagnostic
245+
on_press:
246+
then:
247+
lambda: !lambda |-
248+
id($id_prefix).ttc_toggle_hold();
249+
250+
- platform: template
251+
id: ${id_prefix}_ttc_1_min
252+
name: "TTC Set 1 min"
253+
entity_category: diagnostic
254+
on_press:
255+
then:
256+
lambda: !lambda |-
257+
id($id_prefix).set_ttc_1_min();
258+
259+
- platform: template
260+
id: ${id_prefix}_ttc_5_min
261+
name: "TTC Set 5 min"
262+
entity_category: diagnostic
263+
on_press:
264+
then:
265+
lambda: !lambda |-
266+
id($id_prefix).set_ttc_5_min();
267+
268+
- platform: template
269+
id: ${id_prefix}_ttc_10_min
270+
name: "TTC Set 10 min"
271+
entity_category: diagnostic
272+
on_press:
273+
then:
274+
lambda: !lambda |-
275+
id($id_prefix).set_ttc_10_min();
276+
277+
- platform: template
278+
id: ${id_prefix}_beef
279+
name: "Set TTC 0xBEEF"
280+
entity_category: diagnostic
281+
on_press:
282+
then:
283+
lambda: !lambda |-
284+
id($id_prefix).set_ttc_beef();
285+
286+
- platform: template
287+
id: ${id_prefix}_set_ttc_0_sec
288+
name: "Set TTC 0 Sec"
289+
entity_category: diagnostic
290+
on_press:
291+
then:
292+
lambda: !lambda |-
293+
id($id_prefix).set_ttc_0_sec();
294+
295+
296+
- platform: template
297+
id: ${id_prefix}_set_ttc_1_sec
298+
name: "Set TTC 1 Sec"
299+
entity_category: diagnostic
300+
on_press:
301+
then:
302+
lambda: !lambda |-
303+
id($id_prefix).set_ttc_1_sec();
304+
305+
306+
- platform: template
307+
id: ${id_prefix}_set_ttc_255
308+
name: "Set TTC 255 Sec"
309+
entity_category: diagnostic
310+
on_press:
311+
then:
312+
lambda: !lambda |-
313+
id($id_prefix).set_ttc_255_sec();
314+

components/ratgdo/ratgdo.cpp

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace ratgdo {
149149
this->door_position = 0.0;
150150
if(this->clear_TTC_) {
151151
//TODO this send_command gets sent same time as GET_OPENINGS on line 189
152-
this->send_command(Command::CANCEL_TTC, data::CANCEL_TTC_OFF);
152+
this->send_command(Command::TTC_CANCEL, data::TTC_CANCEL_OFF);
153153
this->clear_TTC_ = false;
154154
}
155155
} else {
@@ -227,7 +227,7 @@ namespace ratgdo {
227227
this->send_command(Command::GET_STATUS);
228228
}
229229
ESP_LOGD(TAG, "Motion: %s", MotionState_to_string(*this->motion_state));
230-
} else if (cmd == Command::SET_TTC_DURATION) {
230+
} else if (cmd == Command::TTC_SET_DURATION) {
231231
auto seconds = (byte1 << 8) | byte2;
232232
ESP_LOGD(TAG, "Time to close (TTC) update request: %ds", seconds);
233233
} else if (cmd == Command::TTC_DURATION) {
@@ -236,13 +236,13 @@ namespace ratgdo {
236236
} else if (cmd == Command::TTC_COUNTDOWN) {
237237
auto seconds = (byte1 << 8) | byte2;
238238
ESP_LOGD(TAG, "(TTC) door will close in: %ds", seconds);
239-
} else if (cmd == Command::CANCEL_TTC) {
239+
} else if (cmd == Command::TTC_CANCEL) {
240240
if (byte1 == 0x04) {
241-
ESP_LOGD(TAG, "CANCEL_TTC: Auto Hold Toggled");
241+
ESP_LOGD(TAG, "TTC: Auto Hold Toggled");
242242
} else if (byte1 == 0x05) {
243-
ESP_LOGD(TAG, "CANCEL_TTC: Disabled");
243+
ESP_LOGD(TAG, "TTC: Disabled");
244244
} else {
245-
ESP_LOGD(TAG, "CANCEL_TTC: Unknown Data");
245+
ESP_LOGD(TAG, "TTC_CANCEL: Unknown Data");
246246
}
247247
}
248248

@@ -401,10 +401,7 @@ namespace ratgdo {
401401

402402
void RATGDOComponent::query_status()
403403
{
404-
//send_command(Command::GET_STATUS);
405-
406-
//TODO revert testing
407-
send_command(Command::GET_TTC_DURATION, data::GET_TTC_DURATION);
404+
send_command(Command::GET_STATUS);
408405
}
409406

410407
void RATGDOComponent::query_openings()
@@ -415,14 +412,65 @@ namespace ratgdo {
415412
void RATGDOComponent::close_with_alert()
416413
{
417414
//TODO check if door is closed and ignore
418-
//TODO check if this will work with door partially open
415+
//Only works if fully open
419416

420417
//SET_TTC closes door in 1 second with light and beeper
421-
send_command(Command::SET_TTC_DURATION, data::TTC_BEEF);
422-
423-
//this->clear_TTC_ = true;
418+
send_command(Command::TTC_SET_DURATION, data::TTC_1_SEC);
419+
this->clear_TTC_ = true;
424420
}
425421

422+
void RATGDOComponent::get_ttc_duration()
423+
{
424+
send_command(Command::TTC_GET_DURATION, data::TTC_GET_DURATION);
425+
}
426+
427+
void RATGDOComponent::turn_ttc_off()
428+
{
429+
send_command(Command::TTC_CANCEL, data::TTC_CANCEL_OFF);
430+
}
431+
432+
void RATGDOComponent::ttc_toggle_hold()
433+
{
434+
send_command(Command::TTC_CANCEL, data::TTC_CANCEL_TOGGLE_HOLD);
435+
}
436+
437+
void RATGDOComponent::set_ttc_1_min()
438+
{
439+
send_command(Command::TTC_SET_DURATION, data::TTC_1_MIN);
440+
}
441+
442+
void RATGDOComponent::set_ttc_5_min()
443+
{
444+
send_command(Command::TTC_SET_DURATION, data::TTC_5_MIN);
445+
}
446+
447+
void RATGDOComponent::set_ttc_10_min()
448+
{
449+
send_command(Command::TTC_SET_DURATION, data::TTC_10_MIN);
450+
}
451+
452+
void RATGDOComponent::set_ttc_beef()
453+
{
454+
send_command(Command::TTC_SET_DURATION, data::TTC_BEEF);
455+
}
456+
457+
void RATGDOComponent::set_ttc_0_sec()
458+
{
459+
send_command(Command::TTC_SET_DURATION, data::TTC_0_SEC);
460+
}
461+
462+
void RATGDOComponent::set_ttc_1_sec()
463+
{
464+
send_command(Command::TTC_SET_DURATION, data::TTC_1_SEC);
465+
}
466+
467+
void RATGDOComponent::set_ttc_255_sec()
468+
{
469+
send_command(Command::TTC_SET_DURATION, data::TTC_255_SEC);
470+
}
471+
472+
473+
426474
/************************* DOOR COMMUNICATION *************************/
427475
/*
428476
* Transmit a message to the door opener over uart1

components/ratgdo/ratgdo.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ratgdo {
5252
const uint32_t DOOR_TOGGLE = 2;
5353
const uint32_t DOOR_STOP = 3;
5454

55-
const uint32_t GET_TTC_DURATION= 1 ;
55+
const uint32_t TTC_GET_DURATION= 1 ;
5656

5757
const uint32_t TTC_0_SEC = 0x000001;
5858
const uint32_t TTC_1_SEC = 0x010001;
@@ -64,8 +64,8 @@ namespace ratgdo {
6464
const uint32_t TTC_291_SEC = 0x230101; ////TODO remove test values
6565
const uint32_t TTC_BEEF = 0xBEEF01; ////TODO remove test values
6666

67-
const uint32_t CANCEL_TTC_OFF = 0x000501; //Unknown meaning for these bytes, mimic button pad
68-
const uint32_t CANCEL_TTC_TOGGLE_HOLD = 0x000401; //Unknown meaning for these bytes, mimic button pad
67+
const uint32_t TTC_CANCEL_OFF = 0x000501; //Unknown meaning for these bytes, mimic button pad
68+
const uint32_t TTC_CANCEL_TOGGLE_HOLD = 0x000401; //Unknown meaning for these bytes, mimic button pad
6969
}
7070

7171
ENUM(Command, uint16_t,
@@ -88,10 +88,10 @@ namespace ratgdo {
8888
(PING, 0x392),
8989
(PING_RESP, 0x393),
9090

91-
(GET_TTC_DURATION, 0x400),
91+
(TTC_GET_DURATION, 0x400),
9292
(TTC_DURATION, 0x401), //data appears to contain the current TTC setting in gdo
93-
(SET_TTC_DURATION, 0x402), // Set time to close in seconds = (byte1<<8)+byte2
94-
(CANCEL_TTC, 0x408), //OFF or TOGGLE_HOLD are options
93+
(TTC_SET_DURATION, 0x402), // Set time to close in seconds = (byte1<<8)+byte2
94+
(TTC_CANCEL, 0x408), //OFF or TOGGLE_HOLD are options
9595
(TTC_COUNTDOWN, 0x40a), // Time to close countdown in seconds
9696

9797
(GET_OPENINGS, 0x48b),
@@ -186,6 +186,18 @@ namespace ratgdo {
186186
void sync();
187187
void close_with_alert();
188188

189+
//TODO remove these buttons for testing
190+
void get_ttc_duration();
191+
void turn_ttc_off();
192+
void ttc_toggle_hold();
193+
void set_ttc_1_min();
194+
void set_ttc_5_min();
195+
void set_ttc_10_min();
196+
void set_ttc_beef();
197+
void set_ttc_0_sec();
198+
void set_ttc_1_sec();
199+
void set_ttc_255_sec();
200+
189201
// children subscriptions
190202
void subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f);
191203
void subscribe_opening_duration(std::function<void(float)>&& f);

0 commit comments

Comments
 (0)