|
1 | 1 | import asyncio
|
2 | 2 | import logging
|
3 | 3 | import re
|
4 |
| - |
5 |
| -import voluptuous as vol |
6 |
| - |
7 | 4 | from datetime import timedelta
|
8 |
| -from smllib import SmlStreamReader |
9 |
| -from smllib.errors import CrcError |
10 |
| -from smllib.sml import SmlListEntry, ObisCode |
11 |
| -from smllib.const import UNITS |
12 | 5 |
|
| 6 | +import voluptuous as vol |
13 | 7 | from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
14 | 8 | from homeassistant.const import CONF_ID, CONF_HOST, CONF_SCAN_INTERVAL, CONF_PASSWORD, CONF_MODE
|
15 | 9 | from homeassistant.core import HomeAssistant
|
16 | 10 | from homeassistant.exceptions import ConfigEntryNotReady
|
17 | 11 | from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
18 | 12 | from homeassistant.helpers.entity import EntityDescription, Entity
|
19 | 13 | from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
| 14 | +from smllib import SmlStreamReader |
| 15 | +from smllib.const import UNITS |
| 16 | +from smllib.errors import CrcError |
| 17 | +from smllib.sml import SmlListEntry, ObisCode |
20 | 18 |
|
21 | 19 | from .const import (
|
22 | 20 | DOMAIN,
|
|
30 | 28 | MODE_0_AutoScanMode,
|
31 | 29 | MODE_3_SML_1_04,
|
32 | 30 | MODE_99_PLAINTEXT,
|
| 31 | + MODE_1_IEC_62056_21, |
| 32 | + ENUM_IMPLEMENTATIONS, |
33 | 33 | )
|
34 | 34 |
|
35 | 35 | _LOGGER = logging.getLogger(__name__)
|
@@ -255,6 +255,10 @@ async def detect_com_mode(self):
|
255 | 255 | elif self._com_mode == MODE_0_AutoScanMode:
|
256 | 256 | await self._check_modes_internal(MODE_3_SML_1_04, MODE_99_PLAINTEXT)
|
257 | 257 |
|
| 258 | + # finally raise value error if not implemented yet! |
| 259 | + if self._com_mode not in ENUM_IMPLEMENTATIONS: |
| 260 | + raise ValueError(f"NOT IMPLEMENTED yet! - Mode: {self._com_mode}") |
| 261 | + |
258 | 262 | async def _check_modes_internal(self, mode_1:int, mode_2:int):
|
259 | 263 | _LOGGER.debug(f"detect_com_mode is {self._com_mode}: will try to read {mode_1}")
|
260 | 264 | await self.read_tibber_local(mode_1, False, log_payload=True)
|
@@ -304,6 +308,8 @@ async def read_tibber_local(self, mode: int, retry: bool, log_payload: bool = Fa
|
304 | 308 | if res.status == 200:
|
305 | 309 | if mode == MODE_3_SML_1_04:
|
306 | 310 | await self.read_sml(await res.read(), retry, log_payload)
|
| 311 | + #elif mode == MODE_1_IEC_62056_21: |
| 312 | + # await self.read_ice62056(await res.read(), retry, log_payload) |
307 | 313 | elif mode == MODE_99_PLAINTEXT:
|
308 | 314 | await self.read_plaintext(await res.text(), retry, log_payload)
|
309 | 315 | else:
|
|
0 commit comments