fix multiline bugs
This commit is contained in:
@@ -203,8 +203,7 @@ class Infos:
|
|||||||
if 'val_tpl' in ha:
|
if 'val_tpl' in ha:
|
||||||
attr['val_tpl'] = ha['val_tpl']
|
attr['val_tpl'] = ha['val_tpl']
|
||||||
elif 'fmt' in ha:
|
elif 'fmt' in ha:
|
||||||
attr['val_tpl'] = '{{value_json' + f"['{row['name'][-1]}']"
|
attr['val_tpl'] = '{{value_json' + f"['{row['name'][-1]}'] {ha['fmt']}" + '}}' # eg. 'val_tpl': "{{ value_json['Output_Power']|float }} # noqa: E501
|
||||||
" {ha['fmt']}" + '}}' # eg. 'val_tpl': "{{ value_json['Output_Power']|float }} # noqa: E501
|
|
||||||
else:
|
else:
|
||||||
self.inc_counter('Internal_Error')
|
self.inc_counter('Internal_Error')
|
||||||
logging.error(f"Infos.__info_defs: the row for {key} do"
|
logging.error(f"Infos.__info_defs: the row for {key} do"
|
||||||
|
|||||||
@@ -76,10 +76,8 @@ class Inverter(AsyncStream):
|
|||||||
for data_json, component, node_id, id in cls.db_stat.ha_confs(
|
for data_json, component, node_id, id in cls.db_stat.ha_confs(
|
||||||
cls.entity_prfx, cls.proxy_node_id,
|
cls.entity_prfx, cls.proxy_node_id,
|
||||||
cls.proxy_unique_id, True):
|
cls.proxy_unique_id, True):
|
||||||
logger_mqtt.debug(f'''MQTT Register: cmp:'{component}' node_id:'
|
logger_mqtt.debug(f"MQTT Register: cmp:'{component}' node_id:'{node_id}' {data_json}") # noqa: E501
|
||||||
{node_id}' {data_json}''')
|
await cls.mqtt.publish(f'{cls.discovery_prfx}{component}/{node_id}{id}/config', data_json) # noqa: E501
|
||||||
await cls.mqtt.publish(f'''{cls.discovery_prfx}{component}
|
|
||||||
/{node_id}{id}/config''', data_json)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def __async_publ_mqtt_proxy_stat(cls, key) -> None:
|
async def __async_publ_mqtt_proxy_stat(cls, key) -> None:
|
||||||
@@ -185,8 +183,7 @@ class Inverter(AsyncStream):
|
|||||||
data_json = json.dumps(db[key])
|
data_json = json.dumps(db[key])
|
||||||
node_id = self.node_id
|
node_id = self.node_id
|
||||||
logger_mqtt.debug(f'{key}: {data_json}')
|
logger_mqtt.debug(f'{key}: {data_json}')
|
||||||
await self.mqtt.publish(f'''{self.entity_prfx}{node_id}
|
await self.mqtt.publish(f'{self.entity_prfx}{node_id}{key}', data_json) # noqa: E501
|
||||||
{key}''', data_json)
|
|
||||||
self.new_data[key] = False
|
self.new_data[key] = False
|
||||||
|
|
||||||
async def __register_home_assistant(self) -> None:
|
async def __register_home_assistant(self) -> None:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import struct
|
import struct
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import datetime
|
from datetime import datetime
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
if __name__ == "app.src.messages":
|
if __name__ == "app.src.messages":
|
||||||
@@ -131,16 +131,14 @@ class Message(metaclass=IterRegistry):
|
|||||||
inv = inverters[serial_no]
|
inv = inverters[serial_no]
|
||||||
self.node_id = inv['node_id']
|
self.node_id = inv['node_id']
|
||||||
self.sug_area = inv['suggested_area']
|
self.sug_area = inv['suggested_area']
|
||||||
logger.debug(f'''SerialNo {serial_no} allowed!
|
logger.debug(f'SerialNo {serial_no} allowed! area:{self.sug_area}') # noqa: E501
|
||||||
area:{self.sug_area}''')
|
|
||||||
else:
|
else:
|
||||||
self.node_id = ''
|
self.node_id = ''
|
||||||
self.sug_area = ''
|
self.sug_area = ''
|
||||||
if 'allow_all' not in inverters or not inverters['allow_all']:
|
if 'allow_all' not in inverters or not inverters['allow_all']:
|
||||||
self.inc_counter('Unknown_SNR')
|
self.inc_counter('Unknown_SNR')
|
||||||
self.unique_id = None
|
self.unique_id = None
|
||||||
logger.warning(f'''ignore message from unknow inverter!
|
logger.warning(f'ignore message from unknow inverter! (SerialNo: {serial_no})') # noqa: E501
|
||||||
(SerialNo: {serial_no})''')
|
|
||||||
return
|
return
|
||||||
logger.debug(f'SerialNo {serial_no} not known but accepted!')
|
logger.debug(f'SerialNo {serial_no} not known but accepted!')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user