make more functions synchronous
This commit is contained in:
@@ -151,7 +151,7 @@ class Mqtt(metaclass=Singleton):
|
|||||||
if self.__cb_mqtt_is_up:
|
if self.__cb_mqtt_is_up:
|
||||||
await self.__cb_mqtt_is_up()
|
await self.__cb_mqtt_is_up()
|
||||||
|
|
||||||
async def _out_coeff(self, message):
|
def _out_coeff(self, message):
|
||||||
payload = message.payload.decode("UTF-8")
|
payload = message.payload.decode("UTF-8")
|
||||||
try:
|
try:
|
||||||
val = round(float(payload) * 1024/100)
|
val = round(float(payload) * 1024/100)
|
||||||
@@ -160,9 +160,9 @@ class Mqtt(metaclass=Singleton):
|
|||||||
'the range 0..100,'
|
'the range 0..100,'
|
||||||
f' got: {payload}')
|
f' got: {payload}')
|
||||||
else:
|
else:
|
||||||
await self._modbus_cmd(message,
|
self._modbus_cmd(message,
|
||||||
Modbus.WRITE_SINGLE_REG,
|
Modbus.WRITE_SINGLE_REG,
|
||||||
0, 0x202c, val)
|
0, 0x202c, val)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ class Mqtt(metaclass=Singleton):
|
|||||||
else:
|
else:
|
||||||
logger_mqtt.warning(f'Node_id: {node_id} not found')
|
logger_mqtt.warning(f'Node_id: {node_id} not found')
|
||||||
|
|
||||||
async def _modbus_cmd(self, message, func, params=0, addr=0, val=0):
|
def _modbus_cmd(self, message, func, params=0, addr=0, val=0):
|
||||||
payload = message.payload.decode("UTF-8")
|
payload = message.payload.decode("UTF-8")
|
||||||
for fnc in self.each_inverter(message, "send_modbus_cmd"):
|
for fnc in self.each_inverter(message, "send_modbus_cmd"):
|
||||||
res = payload.split(',')
|
res = payload.split(',')
|
||||||
|
|||||||
Reference in New Issue
Block a user