|
6 | 6 | pw_constants = importlib.import_module("plugwise_usb.constants") |
7 | 7 |
|
8 | 8 | # test using utc timezone - 2025-04-03 22:00:00 |
9 | | -utc_now = datetime(2025, 4, 3, 22, 0, 0) # datetime.now(tz=UTC).replace(tzinfo=UTC) |
10 | | -# utc_now_offset = datetime.now(tz=UTC).replace(tzinfo=UTC) + timedelta( |
11 | | -# days=1, hours=4, seconds=30 |
12 | | -# ) |
13 | | - |
| 9 | +fixed_time = datetime(2025, 4, 3, 22, 0, 0) # changed from datetime.now(tz=UTC).replace(tzinfo=UTC) |
14 | 10 |
|
15 | 11 | # generate energy log timestamps with fixed hour timestamp used in tests |
16 | | -hour_timestamp = utc_now.replace(minute=0, second=0, microsecond=0) |
| 12 | +hour_timestamp = fixed_time.replace(minute=0, second=0, microsecond=0) |
17 | 13 |
|
18 | 14 | LOG_TIMESTAMPS = {} |
19 | 15 | _one_hour = timedelta(hours=1) |
|
598 | 594 | b"000000C1", # Success ack |
599 | 595 | b"003A" # msg_id |
600 | 596 | + b"0098765432101234" # mac |
601 | | - + bytes(f"{(utc_now + timedelta(seconds=10)).second:02d}", pw_constants.UTF8) # noqa: UP031 |
602 | | - + bytes(f"{utc_now.minute:02d}", pw_constants.UTF8) # noqa: UP031 |
603 | | - + bytes(f"{utc_now.hour:02d}", pw_constants.UTF8) # noqa: UP031 |
604 | | - + bytes(f"{utc_now.weekday():02d}", pw_constants.UTF8) # noqa: UP031 |
605 | | - + bytes(f"{utc_now.day:02d}", pw_constants.UTF8) # noqa: UP031 |
606 | | - + bytes(f"{utc_now.month:02d}", pw_constants.UTF8) # noqa: UP031 |
607 | | - + bytes(f"{(utc_now.year - 2000):02d}", pw_constants.UTF8), # noqa: UP031 |
| 597 | + + bytes(f"{(fixed_time + timedelta(seconds=10)).second:02d}", pw_constants.UTF8) # noqa: UP031 |
| 598 | + + bytes(f"{fixed_time.minute:02d}", pw_constants.UTF8) # noqa: UP031 |
| 599 | + + bytes(f"{fixed_time.hour:02d}", pw_constants.UTF8) # noqa: UP031 |
| 600 | + + bytes(f"{fixed_time.weekday():02d}", pw_constants.UTF8) # noqa: UP031 |
| 601 | + + bytes(f"{fixed_time.day:02d}", pw_constants.UTF8) # noqa: UP031 |
| 602 | + + bytes(f"{fixed_time.month:02d}", pw_constants.UTF8) # noqa: UP031 |
| 603 | + + bytes(f"{(fixed_time.year - 2000):02d}", pw_constants.UTF8), # noqa: UP031 |
608 | 604 | ), |
609 | 605 | b"\x05\x05\x03\x0300280098765432101234000022030304259DDF\r\n": ( |
610 | 606 | "Circle+ Realtime set clock for 0098765432101234", |
|
616 | 612 | b"000000C1", # Success ack |
617 | 613 | b"003F" # msg_id |
618 | 614 | + b"1111111111111111" # mac |
619 | | - + bytes(f"{utc_now.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
620 | | - + bytes(f"{utc_now.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
621 | | - + bytes(f"{(utc_now + timedelta(seconds=10)).second:02x}", pw_constants.UTF8) # noqa: UP031 |
622 | | - + bytes(f"{utc_now.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
| 615 | + + bytes(f"{fixed_time.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
| 616 | + + bytes(f"{fixed_time.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
| 617 | + + bytes(f"{(fixed_time + timedelta(seconds=10)).second:02x}", pw_constants.UTF8) # noqa: UP031 |
| 618 | + + bytes(f"{fixed_time.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
623 | 619 | + b"00" # unknown |
624 | 620 | + b"0000", # unknown2 |
625 | 621 | ), |
|
628 | 624 | b"000000C1", # Success ack |
629 | 625 | b"003F" # msg_id |
630 | 626 | + b"2222222222222222" # mac |
631 | | - + bytes(f"{utc_now.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
632 | | - + bytes(f"{utc_now.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
633 | | - + bytes(f"{utc_now.second:02x}", pw_constants.UTF8) # noqa: UP031 |
634 | | - + bytes(f"{utc_now.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
| 627 | + + bytes(f"{fixed_time.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
| 628 | + + bytes(f"{fixed_time.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
| 629 | + + bytes(f"{fixed_time.second:02x}", pw_constants.UTF8) # noqa: UP031 |
| 630 | + + bytes(f"{fixed_time.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
635 | 631 | + b"00" # unknown |
636 | 632 | + b"0000", # unknown2 |
637 | 633 | ), |
|
640 | 636 | b"000000C1", # Success ack |
641 | 637 | b"003F" # msg_id |
642 | 638 | + b"3333333333333333" # mac |
643 | | - + bytes(f"{utc_now.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
644 | | - + bytes(f"{utc_now.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
645 | | - + bytes(f"{utc_now.second:02x}", pw_constants.UTF8) # noqa: UP031 |
646 | | - + bytes(f"{utc_now.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
| 639 | + + bytes(f"{fixed_time.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
| 640 | + + bytes(f"{fixed_time.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
| 641 | + + bytes(f"{fixed_time.second:02x}", pw_constants.UTF8) # noqa: UP031 |
| 642 | + + bytes(f"{fixed_time.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
647 | 643 | + b"00" # unknown |
648 | 644 | + b"0000", # unknown2 |
649 | 645 | ), |
|
652 | 648 | b"000000C1", # Success ack |
653 | 649 | b"003F" # msg_id |
654 | 650 | + b"4444444444444444" # mac |
655 | | - + bytes(f"{utc_now.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
656 | | - + bytes(f"{utc_now.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
657 | | - + bytes(f"{utc_now.second:02x}", pw_constants.UTF8) # noqa: UP031 |
658 | | - + bytes(f"{utc_now.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
| 651 | + + bytes(f"{fixed_time.hour:02x}", pw_constants.UTF8) # noqa: UP031 |
| 652 | + + bytes(f"{fixed_time.minute:02x}", pw_constants.UTF8) # noqa: UP031 |
| 653 | + + bytes(f"{fixed_time.second:02x}", pw_constants.UTF8) # noqa: UP031 |
| 654 | + + bytes(f"{fixed_time.weekday():02x}", pw_constants.UTF8) # noqa: UP031 |
659 | 655 | + b"00" # unknown |
660 | 656 | + b"0000", # unknown2 |
661 | 657 | ), |
|
0 commit comments