mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
Compare commits
16 Commits
v1.0.10b6
...
v1.0.10b12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6411e6e5f9 | ||
|
|
2020a840a8 | ||
|
|
f6c2cd025e | ||
|
|
ab599cd59d | ||
|
|
a349cbd4a4 | ||
|
|
bd1ba0379f | ||
|
|
70016dd69d | ||
|
|
5617e7afa5 | ||
|
|
bcdec2d793 | ||
|
|
c4aae6b3ec | ||
|
|
58d243dcc3 | ||
|
|
3488d4593a | ||
|
|
76b8988b83 | ||
|
|
4145eebbdd | ||
|
|
d4dddc61fd | ||
|
|
bc34c1a0b3 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 1.0.10b6
|
||||
current_version = 1.0.10b12
|
||||
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(?P<release>[bf]*)(?P<build>\d*)
|
||||
commit = True
|
||||
tag = True
|
||||
|
||||
@@ -104,6 +104,11 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: {
|
||||
vol.Optional(CONF_ALLOW_HOSTS): [str],
|
||||
vol.Optional('entities'): {
|
||||
vol.Optional(str): vol.Any(
|
||||
CUSTOMIZE_PORT,
|
||||
CUSTOMIZE_DS2413
|
||||
)},
|
||||
vol.Optional(vol.Any(str, int), description='id меги из веб-интерфейса'): {
|
||||
vol.Optional(CONF_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
|
||||
vol.Optional(
|
||||
|
||||
@@ -67,6 +67,7 @@ class MegaBinarySensor(BinarySensorEntity, MegaPushEntity):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.mega.binary_sensors.append(self.port)
|
||||
self._is_on = None
|
||||
self._attrs = None
|
||||
self._click_task = None
|
||||
|
||||
@@ -129,12 +129,14 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
if self.hass is None:
|
||||
return {}
|
||||
if self._customize is None:
|
||||
c_entity_id = self.hass.data.get(DOMAIN, {}).get('entities', {}).get(self.entity_id, {})
|
||||
c = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM) or {}
|
||||
c = c.get(self._mega_id) or {}
|
||||
c = c.get(self.port) or {}
|
||||
if self.addr is not None and self.index is not None and isinstance(c, dict):
|
||||
idx = self.addr.lower() + f'_a' if self.index == 0 else '_b'
|
||||
c = c.get(idx, {})
|
||||
c.update(c_entity_id)
|
||||
self._customize = c
|
||||
|
||||
return self._customize
|
||||
|
||||
@@ -134,7 +134,7 @@ class MegaView(HomeAssistantView):
|
||||
if ret == 'd' and act:
|
||||
await hub.request(cmd=act.replace(':3', f':{v}'))
|
||||
ret = 'd' if hub.force_d else ''
|
||||
else:
|
||||
elif port in hub.binary_sensors:
|
||||
hub.values[port] = data
|
||||
for cb in self.callbacks[hub.id][port]:
|
||||
cb(data)
|
||||
@@ -147,7 +147,7 @@ class MegaView(HomeAssistantView):
|
||||
_LOGGER.debug('response %s', ret)
|
||||
Response(body='' if hub.fake_response else ret, content_type='text/plain')
|
||||
|
||||
if hub.fake_response and 'value' not in data and 'pt' in data:
|
||||
if hub.fake_response and 'value' not in data and 'pt' in data and port in hub.binary_sensors:
|
||||
if 'd' in ret:
|
||||
await hub.request(pt=port, cmd=ret)
|
||||
else:
|
||||
|
||||
@@ -164,6 +164,7 @@ class MegaD:
|
||||
hass.data[DOMAIN][CONF_HTTP].protected = protected
|
||||
except Exception:
|
||||
self.lg.exception('while setting allowed hosts')
|
||||
self.binary_sensors = []
|
||||
|
||||
async def start(self):
|
||||
pass
|
||||
@@ -309,8 +310,8 @@ class MegaD:
|
||||
return ret
|
||||
except asyncio.TimeoutError:
|
||||
self.lg.warning(f'timeout while requesting {url}')
|
||||
raise
|
||||
# await asyncio.sleep(1)
|
||||
# raise
|
||||
await asyncio.sleep(1)
|
||||
raise asyncio.TimeoutError('after 3 tries')
|
||||
|
||||
async def save(self):
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
"@andvikt"
|
||||
],
|
||||
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
|
||||
"version": "v1.0.10b6"
|
||||
"version": "v1.0.10b12"
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class MegaI2C(FilterBadValues):
|
||||
ret = self.mega.values.get(self._params)
|
||||
if self.customize.get(CONF_HEX_TO_FLOAT):
|
||||
try:
|
||||
ret = struct.unpack('!f', bytes.fromhex('41973333'))[0]
|
||||
ret = struct.unpack('!f', bytes.fromhex(ret))[0]
|
||||
except:
|
||||
self.lg.warning(f'could not convert {ret} form hex to float')
|
||||
tmpl: Template = self.customize.get(CONF_CONV_TEMPLATE, self.customize.get(CONF_VALUE_TEMPLATE))
|
||||
@@ -228,6 +228,7 @@ class Mega1WSensor(FilterBadValues):
|
||||
self._device_class = device_class
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self.mega.sensors.append(self)
|
||||
self.prev_value = None
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
@@ -281,7 +282,8 @@ class Mega1WSensor(FilterBadValues):
|
||||
ret = float(ret)
|
||||
ret = str(ret)
|
||||
except:
|
||||
ret = None
|
||||
self.lg.warning(f'could not convert to float "{ret}"')
|
||||
ret = self.prev_value
|
||||
if self.customize.get(CONF_HEX_TO_FLOAT):
|
||||
try:
|
||||
ret = struct.unpack('!f', bytes.fromhex(ret))[0]
|
||||
@@ -296,6 +298,7 @@ class Mega1WSensor(FilterBadValues):
|
||||
except:
|
||||
pass
|
||||
ret = self.filter_value(ret)
|
||||
self.prev_value = ret
|
||||
return str(ret)
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user