@@ -510,101 +510,157 @@ text:
510
510
- platform : template
511
511
id : open_entrance_door_command_input
512
512
name : " Command: Open Entrance Door"
513
- optimistic : true
514
513
mode : text
515
- restore_value : true
516
- initial_value : ' 00001100'
517
- on_value :
514
+ lambda : |-
515
+ unsigned long number = id(first_door_opener_command);
516
+ return str_upper_case(format_hex(number));
517
+ set_action :
518
518
then :
519
519
- lambda : |-
520
- id(first_door_opener_command) = std::stoi(x.c_str(), nullptr, 16);
520
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
521
+ x.erase(0, x.find_first_not_of('0'));
522
+ x.resize(8);
523
+ unsigned long number = 0;
524
+ if(!x.empty()) {
525
+ number = std::stoul(x.c_str(), nullptr, 16);
526
+ }
527
+ id(first_door_opener_command) = number;
528
+ id(open_entrance_door_command_input)->publish_state(str_upper_case(format_hex(number)));
521
529
entity_category : CONFIG
522
530
icon : " mdi:console-network"
523
531
524
532
- platform : template
525
533
id : open_second_door_command_input
526
534
name : " Command: Open Second Door"
527
- optimistic : true
528
535
mode : text
529
- restore_value : true
530
- initial_value : ' 00001100'
531
- on_value :
536
+ lambda : |-
537
+ unsigned long number = id(second_door_opener_command);
538
+ return str_upper_case(format_hex(number));
539
+ set_action :
532
540
then :
533
541
- lambda : |-
534
- id(second_door_opener_command) = std::stoi(x.c_str(), nullptr, 16);
542
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
543
+ x.erase(0, x.find_first_not_of('0'));
544
+ x.resize(8);
545
+ unsigned long number = 0;
546
+ if(!x.empty()) {
547
+ number = std::stoul(x.c_str(), nullptr, 16);
548
+ }
549
+ id(second_door_opener_command) = number;
550
+ id(open_second_door_command_input)->publish_state(str_upper_case(format_hex(number)));
535
551
disabled_by_default : true
536
552
entity_category : CONFIG
537
553
icon : " mdi:console-network"
538
554
539
555
- platform : template
540
556
id : entrance_doorbell_command_input
541
557
name : " Command: Entrance Doorbell"
542
- optimistic : true
543
558
mode : text
544
- restore_value : true
545
- initial_value : ' 00000000'
546
- on_value :
559
+ lambda : |-
560
+ unsigned long number = id(entrance_doorbell_command);
561
+ return str_upper_case(format_hex(number));
562
+ set_action :
547
563
then :
548
564
- lambda : |-
549
- id(entrance_doorbell_command) = std::stoi(x.c_str(), nullptr, 16);
565
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
566
+ x.erase(0, x.find_first_not_of('0'));
567
+ x.resize(8);
568
+ unsigned long number = 0;
569
+ if(!x.empty()) {
570
+ number = std::stoul(x.c_str(), nullptr, 16);
571
+ }
572
+ id(entrance_doorbell_command) = number;
573
+ id(entrance_doorbell_command_input)->publish_state(str_upper_case(format_hex(number)));
550
574
entity_category : CONFIG
551
575
icon : " mdi:console-network"
552
576
553
577
- platform : template
554
578
id : apartment_doorbell_command_input
555
579
name : " Command: Apartment Doorbell"
556
- optimistic : true
557
580
mode : text
558
- restore_value : true
559
- initial_value : ' 00000000'
560
- on_value :
581
+ lambda : |-
582
+ unsigned long number = id(apartment_doorbell_command);
583
+ return str_upper_case(format_hex(number));
584
+ set_action :
561
585
then :
562
586
- lambda : |-
563
- id(apartment_doorbell_command) = std::stoi(x.c_str(), nullptr, 16);
587
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
588
+ x.erase(0, x.find_first_not_of('0'));
589
+ x.resize(8);
590
+ unsigned long number = 0;
591
+ if(!x.empty()) {
592
+ number = std::stoul(x.c_str(), nullptr, 16);
593
+ }
594
+ id(apartment_doorbell_command) = number;
595
+ id(apartment_doorbell_command_input)->publish_state(str_upper_case(format_hex(number)));
564
596
entity_category : CONFIG
565
597
icon : " mdi:console-network"
566
598
567
599
- platform : template
568
600
id : pick_up_phone_command_input
569
601
name : " Command: Pick up phone"
570
- optimistic : true
571
602
mode : text
572
- restore_value : true
573
- initial_value : ' 00000000'
574
- on_value :
603
+ lambda : |-
604
+ unsigned long number = id(pick_up_phone_command);
605
+ return str_upper_case(format_hex(number));
606
+ set_action :
575
607
then :
576
608
- lambda : |-
577
- id(pick_up_phone_command) = std::stoi(x.c_str(), nullptr, 16);
609
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
610
+ x.erase(0, x.find_first_not_of('0'));
611
+ x.resize(8);
612
+ unsigned long number = 0;
613
+ if(!x.empty()) {
614
+ number = std::stoul(x.c_str(), nullptr, 16);
615
+ }
616
+ id(pick_up_phone_command) = number;
617
+ id(pick_up_phone_command_input)->publish_state(str_upper_case(format_hex(number)));
578
618
disabled_by_default : true
579
619
entity_category : CONFIG
580
620
icon : " mdi:console-network"
581
621
582
622
- platform : template
583
623
id : hang_up_command_input
584
624
name : " Command: Hang up phone"
585
- optimistic : true
586
625
mode : text
587
- restore_value : true
588
- initial_value : ' 00003000'
589
- on_value :
626
+ lambda : |-
627
+ unsigned long number = id(hang_up_phone_command);
628
+ return str_upper_case(format_hex(number));
629
+ set_action :
590
630
then :
591
631
- lambda : |-
592
- id(hang_up_phone_command) = std::stoi(x.c_str(), nullptr, 16);
632
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
633
+ x.erase(0, x.find_first_not_of('0'));
634
+ x.resize(8);
635
+ unsigned long number = 0;
636
+ if(!x.empty()) {
637
+ number = std::stoul(x.c_str(), nullptr, 16);
638
+ }
639
+ id(hang_up_phone_command) = number;
640
+ id(hang_up_command_input)->publish_state(str_upper_case(format_hex(number)));
593
641
disabled_by_default : true
594
642
entity_category : CONFIG
595
643
icon : " mdi:console-network"
596
644
597
645
- platform : template
598
646
id : ring_to_open_toggle_command_input
599
647
name : " Command: Toggle Ring To Open"
600
- optimistic : true
601
648
mode : text
602
- restore_value : true
603
- initial_value : ' 00000000'
604
- on_value :
649
+ lambda : |-
650
+ unsigned long number = id(ring_to_open_toggle_command);
651
+ return str_upper_case(format_hex(number));
652
+ set_action :
605
653
then :
606
654
- lambda : |-
607
- id(ring_to_open_toggle_command) = std::stoi(x.c_str(), nullptr, 16);
655
+ x.erase(std::remove_if(x.begin(), x.end(), [](char c) { return !std::isxdigit(c); }), x.end());
656
+ x.erase(0, x.find_first_not_of('0'));
657
+ x.resize(8);
658
+ unsigned long number = 0;
659
+ if(!x.empty()) {
660
+ number = std::stoul(x.c_str(), nullptr, 16);
661
+ }
662
+ id(ring_to_open_toggle_command) = number;
663
+ id(ring_to_open_toggle_command_input)->publish_state(str_upper_case(format_hex(number)));
608
664
disabled_by_default : true
609
665
entity_category : CONFIG
610
666
icon : " mdi:console-network"
0 commit comments