remove single discovery message

This commit is contained in:
hjelev
2023-02-09 20:59:41 +02:00
parent 9f6b4a43cf
commit db5f7af831
2 changed files with 0 additions and 16 deletions

View File

@@ -12,9 +12,6 @@ mqtt_topic_prefix = "rpi-MQTT-monitor"
# Uncomment the line bellow to send just one CSV message containing all values (this method don't support HA discovery_messages) # Uncomment the line bellow to send just one CSV message containing all values (this method don't support HA discovery_messages)
# group_messages = True # group_messages = True
# Disable dicovery_messages after the first execution of the script (they are not needed unless you delete the device from HA)
single_discovery_message = True
# If this is set, then the script will send MQTT discovery messages meaning a config less setup in HA. Only works # If this is set, then the script will send MQTT discovery messages meaning a config less setup in HA. Only works
# when group_messages is not used # when group_messages is not used

View File

@@ -305,16 +305,6 @@ def bulk_publish_to_mqtt(cpu_load=0, cpu_temp=0, used_space=0, voltage=0, sys_cl
client.disconnect() client.disconnect()
def single_discovery_message():
file_path = os.path.dirname(os.path.abspath(__file__))
for line in fileinput.input(file_path + "/config.py", inplace=True):
if line.strip().replace(' ','') == 'discovery_messages=True':
print('# Auto Disabled\ndiscovery_messages = False')
else:
print(line, end='')
if __name__ == '__main__': if __name__ == '__main__':
# set all monitored values to False in case they are turned off in the config # set all monitored values to False in case they are turned off in the config
cpu_load = cpu_temp = used_space = voltage = sys_clock_speed = swap = memory = uptime_days = wifi_signal = wifi_signal_dbm = False cpu_load = cpu_temp = used_space = voltage = sys_clock_speed = swap = memory = uptime_days = wifi_signal = wifi_signal_dbm = False
@@ -351,6 +341,3 @@ if __name__ == '__main__':
bulk_publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm) bulk_publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm)
else: else:
publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm) publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm)
if hasattr(config, 'single_discovery_message') and config.single_discovery_message and config.discovery_messages:
single_discovery_message()