fix multiline bugs

This commit is contained in:
Stefan Allius
2023-11-02 23:50:49 +01:00
parent a002408a98
commit 7f91994934
3 changed files with 7 additions and 13 deletions

View File

@@ -203,8 +203,7 @@ class Infos:
if 'val_tpl' in ha:
attr['val_tpl'] = ha['val_tpl']
elif 'fmt' in ha:
attr['val_tpl'] = '{{value_json' + f"['{row['name'][-1]}']"
" {ha['fmt']}" + '}}' # eg. 'val_tpl': "{{ value_json['Output_Power']|float }} # noqa: E501
attr['val_tpl'] = '{{value_json' + f"['{row['name'][-1]}'] {ha['fmt']}" + '}}' # eg. 'val_tpl': "{{ value_json['Output_Power']|float }} # noqa: E501
else:
self.inc_counter('Internal_Error')
logging.error(f"Infos.__info_defs: the row for {key} do"

View File

@@ -76,10 +76,8 @@ class Inverter(AsyncStream):
for data_json, component, node_id, id in cls.db_stat.ha_confs(
cls.entity_prfx, cls.proxy_node_id,
cls.proxy_unique_id, True):
logger_mqtt.debug(f'''MQTT Register: cmp:'{component}' node_id:'
{node_id}' {data_json}''')
await cls.mqtt.publish(f'''{cls.discovery_prfx}{component}
/{node_id}{id}/config''', data_json)
logger_mqtt.debug(f"MQTT Register: cmp:'{component}' node_id:'{node_id}' {data_json}") # noqa: E501
await cls.mqtt.publish(f'{cls.discovery_prfx}{component}/{node_id}{id}/config', data_json) # noqa: E501
@classmethod
async def __async_publ_mqtt_proxy_stat(cls, key) -> None:
@@ -185,8 +183,7 @@ class Inverter(AsyncStream):
data_json = json.dumps(db[key])
node_id = self.node_id
logger_mqtt.debug(f'{key}: {data_json}')
await self.mqtt.publish(f'''{self.entity_prfx}{node_id}
{key}''', data_json)
await self.mqtt.publish(f'{self.entity_prfx}{node_id}{key}', data_json) # noqa: E501
self.new_data[key] = False
async def __register_home_assistant(self) -> None:

View File

@@ -1,7 +1,7 @@
import struct
import logging
import time
import datetime
from datetime import datetime
import weakref
if __name__ == "app.src.messages":
@@ -131,16 +131,14 @@ class Message(metaclass=IterRegistry):
inv = inverters[serial_no]
self.node_id = inv['node_id']
self.sug_area = inv['suggested_area']
logger.debug(f'''SerialNo {serial_no} allowed!
area:{self.sug_area}''')
logger.debug(f'SerialNo {serial_no} allowed! area:{self.sug_area}') # noqa: E501
else:
self.node_id = ''
self.sug_area = ''
if 'allow_all' not in inverters or not inverters['allow_all']:
self.inc_counter('Unknown_SNR')
self.unique_id = None
logger.warning(f'''ignore message from unknow inverter!
(SerialNo: {serial_no})''')
logger.warning(f'ignore message from unknow inverter! (SerialNo: {serial_no})') # noqa: E501
return
logger.debug(f'SerialNo {serial_no} not known but accepted!')