mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-15 19:14:27 +05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4145eebbdd | ||
|
|
d4dddc61fd | ||
|
|
bc34c1a0b3 |
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 1.0.10b6
|
current_version = 1.0.10b7
|
||||||
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(?P<release>[bf]*)(?P<build>\d*)
|
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(?P<release>[bf]*)(?P<build>\d*)
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|||||||
@@ -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.10b6"
|
"version": "v1.0.10b7"
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ class MegaI2C(FilterBadValues):
|
|||||||
ret = self.mega.values.get(self._params)
|
ret = self.mega.values.get(self._params)
|
||||||
if self.customize.get(CONF_HEX_TO_FLOAT):
|
if self.customize.get(CONF_HEX_TO_FLOAT):
|
||||||
try:
|
try:
|
||||||
ret = struct.unpack('!f', bytes.fromhex('41973333'))[0]
|
ret = struct.unpack('!f', bytes.fromhex(ret))[0]
|
||||||
except:
|
except:
|
||||||
self.lg.warning(f'could not convert {ret} form hex to float')
|
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))
|
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._device_class = device_class
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.mega.sensors.append(self)
|
self.mega.sensors.append(self)
|
||||||
|
self.prev_value = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
@@ -281,7 +282,8 @@ class Mega1WSensor(FilterBadValues):
|
|||||||
ret = float(ret)
|
ret = float(ret)
|
||||||
ret = str(ret)
|
ret = str(ret)
|
||||||
except:
|
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):
|
if self.customize.get(CONF_HEX_TO_FLOAT):
|
||||||
try:
|
try:
|
||||||
ret = struct.unpack('!f', bytes.fromhex(ret))[0]
|
ret = struct.unpack('!f', bytes.fromhex(ret))[0]
|
||||||
@@ -296,6 +298,7 @@ class Mega1WSensor(FilterBadValues):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
ret = self.filter_value(ret)
|
ret = self.filter_value(ret)
|
||||||
|
self.prev_value = ret
|
||||||
return str(ret)
|
return str(ret)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user