|
3 | 3 | """ |
4 | 4 | import asyncio |
5 | 5 | import datetime as dt |
6 | | -import logging |
7 | 6 |
|
8 | 7 | # This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts) |
9 | 8 | from aiohttp import BasicAuth, ClientSession, ClientTimeout, ServerTimeoutError |
|
20 | 19 | ATTR_TYPE, |
21 | 20 | ATTR_UNIT_OF_MEASUREMENT, |
22 | 21 | BINARY_SENSORS, |
| 22 | + DAYS, |
23 | 23 | DEVICE_MEASUREMENTS, |
24 | 24 | ENERGY_KILO_WATT_HOUR, |
25 | 25 | ENERGY_WATT_HOUR, |
26 | 26 | FAKE_LOC, |
27 | 27 | HEATER_CENTRAL_MEASUREMENTS, |
28 | 28 | HOME_MEASUREMENTS, |
29 | 29 | LOCATIONS, |
| 30 | + LOGGER, |
30 | 31 | POWER_WATT, |
31 | 32 | SENSORS, |
32 | 33 | SWITCH_GROUP_TYPES, |
|
46 | 47 | version_to_model, |
47 | 48 | ) |
48 | 49 |
|
49 | | -_LOGGER = logging.getLogger(__name__) |
50 | | - |
51 | | -DAYS = { |
52 | | - "mo": 0, |
53 | | - "tu": 1, |
54 | | - "we": 2, |
55 | | - "th": 3, |
56 | | - "fr": 4, |
57 | | - "sa": 5, |
58 | | - "su": 6, |
59 | | -} |
60 | 50 |
|
61 | 51 |
|
62 | 52 | def pw_notification_updater(devs, d_id, d_dict, notifs): |
@@ -223,14 +213,14 @@ async def _request_validate(self, resp, method): |
223 | 213 |
|
224 | 214 | result = await resp.text() |
225 | 215 | if not result or "<error>" in result: |
226 | | - _LOGGER.error("Smile response empty or error in %s", result) |
| 216 | + LOGGER.error("Smile response empty or error in %s", result) |
227 | 217 | raise ResponseError |
228 | 218 |
|
229 | 219 | try: |
230 | 220 | # Encode to ensure utf8 parsing |
231 | 221 | xml = etree.XML(escape_illegal_xml_characters(result).encode()) |
232 | 222 | except etree.ParseError: |
233 | | - _LOGGER.error("Smile returns invalid XML for %s", self._endpoint) |
| 223 | + LOGGER.error("Smile returns invalid XML for %s", self._endpoint) |
234 | 224 | raise InvalidXMLError |
235 | 225 |
|
236 | 226 | return xml |
@@ -265,7 +255,7 @@ async def _request( |
265 | 255 | ) |
266 | 256 | except ServerTimeoutError: |
267 | 257 | if retry < 1: |
268 | | - _LOGGER.error("Timed out sending command to Plugwise: %s", command) |
| 258 | + LOGGER.error("Timed out sending command to Plugwise: %s", command) |
269 | 259 | raise DeviceTimeoutError |
270 | 260 | return await self._request(command, retry - 1) |
271 | 261 |
|
|
0 commit comments