diff --git a/app/src/infos.py b/app/src/infos.py index 4e3c7af..85c99e5 100644 --- a/app/src/infos.py +++ b/app/src/infos.py @@ -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" diff --git a/app/src/inverter.py b/app/src/inverter.py index f578202..0d645d4 100644 --- a/app/src/inverter.py +++ b/app/src/inverter.py @@ -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: diff --git a/app/src/messages.py b/app/src/messages.py index 8e69bf4..b80da16 100644 --- a/app/src/messages.py +++ b/app/src/messages.py @@ -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!')