|
27 | 27 | LOCATIONS, |
28 | 28 | LOGGER, |
29 | 29 | NONE, |
30 | | - OBSOLETE_MEASUREMENTS, |
31 | 30 | OFF, |
32 | 31 | P1_MEASUREMENTS, |
33 | 32 | SENSORS, |
|
55 | 54 | InvalidXMLError, |
56 | 55 | ResponseError, |
57 | 56 | ) |
58 | | -from plugwise.util import check_model, escape_illegal_xml_characters, format_measure |
| 57 | +from plugwise.util import ( |
| 58 | + check_model, |
| 59 | + escape_illegal_xml_characters, |
| 60 | + format_measure, |
| 61 | + skip_obsolete_measurements, |
| 62 | +) |
59 | 63 |
|
60 | 64 | # This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts) |
61 | 65 | from aiohttp import BasicAuth, ClientError, ClientResponse, ClientSession, ClientTimeout |
@@ -574,20 +578,8 @@ def _appliance_measurements( |
574 | 578 | for measurement, attrs in measurements.items(): |
575 | 579 | p_locator = f'.//logs/point_log[type="{measurement}"]/period/measurement' |
576 | 580 | if (appl_p_loc := appliance.find(p_locator)) is not None: |
577 | | - # Skip known obsolete measurements |
578 | | - updated_date_locator = ( |
579 | | - f'.//logs/point_log[type="{measurement}"]/updated_date' |
580 | | - ) |
581 | | - if ( |
582 | | - measurement in OBSOLETE_MEASUREMENTS |
583 | | - and (updated_date_key := appliance.find(updated_date_locator)) |
584 | | - is not None |
585 | | - ): |
586 | | - updated_date = updated_date_key.text.split("T")[0] |
587 | | - date_1 = dt.datetime.strptime(updated_date, "%Y-%m-%d") |
588 | | - date_2 = dt.datetime.now() |
589 | | - if int((date_2 - date_1).days) > 7: |
590 | | - continue |
| 581 | + if skip_obsolete_measurements(appliance, measurement): |
| 582 | + continue |
591 | 583 |
|
592 | 584 | if new_name := getattr(attrs, ATTR_NAME, None): |
593 | 585 | measurement = new_name |
|
0 commit comments