mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 17:44:28 +05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fab2384b0 | ||
|
|
70a2e5bbb0 | ||
|
|
83c843d722 | ||
|
|
af684a6c00 | ||
|
|
d94efbe1a7 | ||
|
|
eaa46a99ae | ||
|
|
e65598fe63 | ||
|
|
e12ab45c04 | ||
|
|
7fb72be646 |
@@ -99,7 +99,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
{
|
{
|
||||||
DOMAIN: {
|
DOMAIN: {
|
||||||
vol.Optional(CONF_ALLOW_HOSTS): [str],
|
vol.Optional(CONF_ALLOW_HOSTS): [str],
|
||||||
vol.Required(str, description='id меги из веб-интерфейса'): {
|
vol.Optional(vol.Any(str, int), description='id меги из веб-интерфейса'): {
|
||||||
vol.Optional(CONF_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
|
vol.Optional(CONF_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_DEF_RESPONSE,
|
CONF_DEF_RESPONSE,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ LUX = 'lux'
|
|||||||
SINGLE_CLICK = 'single'
|
SINGLE_CLICK = 'single'
|
||||||
DOUBLE_CLICK = 'double'
|
DOUBLE_CLICK = 'double'
|
||||||
|
|
||||||
PATT_FW = re.compile(r'fw:\s(.+)\)')
|
PATT_FW = re.compile(r'fw:\s(.+?)\)')
|
||||||
|
|
||||||
REMOVE_CONFIG = [
|
REMOVE_CONFIG = [
|
||||||
'extenders',
|
'extenders',
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class MegaD:
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
|
self.skip_ports = set()
|
||||||
if config is not None:
|
if config is not None:
|
||||||
lg.debug(f'load config: %s', config.data)
|
lg.debug(f'load config: %s', config.data)
|
||||||
self.config = config
|
self.config = config
|
||||||
@@ -477,6 +478,11 @@ class MegaD:
|
|||||||
:param params: параметры url
|
:param params: параметры url
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
pt = params.get('pt')
|
||||||
|
if pt in self.skip_ports:
|
||||||
|
return
|
||||||
|
if pt is not None:
|
||||||
|
pass
|
||||||
_params = tuple(params.items())
|
_params = tuple(params.items())
|
||||||
delay = None
|
delay = None
|
||||||
if 'delay' in params:
|
if 'delay' in params:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from homeassistant.const import (
|
|||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
DEVICE_CLASS_ILLUMINANCE,
|
||||||
DEVICE_CLASS_PRESSURE,
|
DEVICE_CLASS_PRESSURE,
|
||||||
|
DEVICE_CLASS_CO2,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
@@ -103,6 +104,10 @@ i2c_classes = {
|
|||||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||||
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None)
|
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None)
|
||||||
],
|
],
|
||||||
|
'dps368': [
|
||||||
|
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||||
|
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||||
|
],
|
||||||
'mlx90614': [
|
'mlx90614': [
|
||||||
Skip,
|
Skip,
|
||||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'),
|
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'),
|
||||||
@@ -119,9 +124,21 @@ i2c_classes = {
|
|||||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
|
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
|
||||||
],
|
],
|
||||||
't67xx': [
|
't67xx': [
|
||||||
DeviceType(None, CONCENTRATION_PARTS_PER_MILLION, None) # для co2 нет класса в HA
|
DeviceType(DEVICE_CLASS_CO2, CONCENTRATION_PARTS_PER_MILLION, None)
|
||||||
],
|
],
|
||||||
'tmp117': [
|
'tmp117': [
|
||||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||||
]
|
],
|
||||||
|
'ads1115': [
|
||||||
|
DeviceType(None, None, 'ch0'),
|
||||||
|
DeviceType(None, None, 'ch1'),
|
||||||
|
DeviceType(None, None, 'ch2'),
|
||||||
|
DeviceType(None, None, 'ch3'),
|
||||||
|
],
|
||||||
|
'ads1015': [
|
||||||
|
DeviceType(None, None, 'ch0'),
|
||||||
|
DeviceType(None, None, 'ch1'),
|
||||||
|
DeviceType(None, None, 'ch2'),
|
||||||
|
DeviceType(None, None, 'ch3'),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"domain": "mega",
|
"domain": "mega",
|
||||||
"name": "mega",
|
"name": "mega",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/mega_hacs",
|
"documentation": "https://github.com/andvikt/mega_hacs",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"beautifulsoup4",
|
"beautifulsoup4",
|
||||||
"lxml"
|
"lxml"
|
||||||
@@ -15,5 +15,5 @@
|
|||||||
"@andvikt"
|
"@andvikt"
|
||||||
],
|
],
|
||||||
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
|
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
|
||||||
"version": "v1.0.1"
|
"version": "v1.0.6b4"
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.template import Template
|
from homeassistant.helpers.template import Template
|
||||||
from .entities import MegaPushEntity
|
from .entities import MegaPushEntity
|
||||||
from .const import CONF_KEY, TEMP, HUM, W1, W1BUS, CONF_CONV_TEMPLATE, CONF_HEX_TO_FLOAT
|
from .const import CONF_KEY, TEMP, HUM, W1, W1BUS, CONF_CONV_TEMPLATE, CONF_HEX_TO_FLOAT, DOMAIN, CONF_CUSTOM, CONF_SKIP
|
||||||
from .hub import MegaD
|
from .hub import MegaD
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -84,9 +84,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
|||||||
mid = config_entry.data[CONF_ID]
|
mid = config_entry.data[CONF_ID]
|
||||||
hub: MegaD = hass.data['mega'][mid]
|
hub: MegaD = hass.data['mega'][mid]
|
||||||
devices = []
|
devices = []
|
||||||
|
customize = hass.data.get(DOMAIN, {}).get(CONF_CUSTOM, {}).get(mid, {})
|
||||||
for tp in ['sensor', 'i2c']:
|
for tp in ['sensor', 'i2c']:
|
||||||
for port, cfg in config_entry.data.get(tp, {}).items():
|
for port, cfg in config_entry.data.get(tp, {}).items():
|
||||||
port = int_ignore(port)
|
port = int_ignore(port)
|
||||||
|
c = customize.get(port, {})
|
||||||
|
if c.get(CONF_SKIP):
|
||||||
|
hub.skip_ports |= {port}
|
||||||
|
continue
|
||||||
for data in cfg:
|
for data in cfg:
|
||||||
hub.lg.debug(f'add sensor on port %s with data %s', port, data)
|
hub.lg.debug(f'add sensor on port %s with data %s', port, data)
|
||||||
sensor = _constructors[tp](
|
sensor = _constructors[tp](
|
||||||
|
|||||||
Reference in New Issue
Block a user