mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 17:44:28 +05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f99877ca | ||
|
|
6c50b81bff | ||
|
|
c810693ba5 |
@@ -63,7 +63,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for mega."""
|
"""Handle a config flow for mega."""
|
||||||
|
|
||||||
VERSION = 19
|
VERSION = 20
|
||||||
CONNECTION_CLASS = config_entries.CONN_CLASS_ASSUMED
|
CONNECTION_CLASS = config_entries.CONN_CLASS_ASSUMED
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
|
|||||||
@@ -530,10 +530,16 @@ class MegaD:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
_params = tuple(params.items())
|
_params = tuple(params.items())
|
||||||
|
delay = None
|
||||||
|
if 'delay' in params:
|
||||||
|
delay = params.pop('delay')
|
||||||
ret = {
|
ret = {
|
||||||
_params: await self.request(**params)
|
_params: await self.request(**params)
|
||||||
}
|
}
|
||||||
self.lg.debug('i2c response: %s', ret)
|
self.lg.debug('i2c response: %s', ret)
|
||||||
|
if delay:
|
||||||
|
self.lg.debug('delay %s', delay)
|
||||||
|
await asyncio.sleep(delay)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def get_config(self, nports=37):
|
async def get_config(self, nports=37):
|
||||||
@@ -592,6 +598,9 @@ class MegaD:
|
|||||||
self.lg.debug(f'scan results: %s', (req, parsed))
|
self.lg.debug(f'scan results: %s', (req, parsed))
|
||||||
ret['i2c'][port].extend(parsed)
|
ret['i2c'][port].extend(parsed)
|
||||||
i2c_sensors.extend(req)
|
i2c_sensors.extend(req)
|
||||||
|
elif cfg.pty == '4' and cfg.m == '2':
|
||||||
|
# scl исключаем из сканирования
|
||||||
|
continue
|
||||||
elif cfg.pty in ('3', '2', '4'):
|
elif cfg.pty in ('3', '2', '4'):
|
||||||
http_cmd = 'get'
|
http_cmd = 'get'
|
||||||
if cfg.d == '5' and cfg.pty == '3':
|
if cfg.d == '5' and cfg.pty == '3':
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
from urllib.parse import parse_qsl, urlparse
|
from urllib.parse import parse_qsl, urlparse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@@ -27,6 +28,12 @@ def parse_scan_page(page: str):
|
|||||||
elif c is Request:
|
elif c is Request:
|
||||||
req.append(params)
|
req.append(params)
|
||||||
continue
|
continue
|
||||||
|
elif isinstance(c, Request):
|
||||||
|
if c.delay:
|
||||||
|
params = params.copy()
|
||||||
|
params['delay'] = c.delay
|
||||||
|
req.append(params)
|
||||||
|
continue
|
||||||
elif isinstance(c, tuple):
|
elif isinstance(c, tuple):
|
||||||
suffix, c = c
|
suffix, c = c
|
||||||
elif isinstance(c, str):
|
elif isinstance(c, str):
|
||||||
@@ -55,8 +62,9 @@ class Skip:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class Request:
|
class Request:
|
||||||
pass
|
delay: float = None
|
||||||
|
|
||||||
|
|
||||||
i2c_classes = {
|
i2c_classes = {
|
||||||
@@ -92,7 +100,7 @@ i2c_classes = {
|
|||||||
('object', DEVICE_CLASS_TEMPERATURE),
|
('object', DEVICE_CLASS_TEMPERATURE),
|
||||||
],
|
],
|
||||||
'ptsensor': [
|
'ptsensor': [
|
||||||
Request, # запрос на измерение
|
Request(delay=1), # запрос на измерение
|
||||||
DEVICE_CLASS_PRESSURE,
|
DEVICE_CLASS_PRESSURE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user