remove single discovery message
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -303,16 +303,6 @@ def bulk_publish_to_mqtt(cpu_load=0, cpu_temp=0, used_space=0, voltage=0, sys_cl
|
|||||||
|
|
||||||
# disconnect from mqtt server
|
# disconnect from mqtt server
|
||||||
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__':
|
||||||
@@ -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()
|
|
||||||
Reference in New Issue
Block a user