mirror of
				https://github.com/Tediore/battery2mqtt.git
				synced 2025-11-04 04:46:35 +01:00 
			
		
		
		
	Minor tweak
This commit is contained in:
		@@ -53,6 +53,7 @@ while True:
 | 
				
			|||||||
                payload[name] = "condition not found"
 | 
					                payload[name] = "condition not found"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if BATTERY_HEALTH == '1':
 | 
					        if BATTERY_HEALTH == '1':
 | 
				
			||||||
 | 
					            unit = ' %' if SHOW_UNITS == '1' else ''
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                for name in ['energy_full_design', 'energy_full']:
 | 
					                for name in ['energy_full_design', 'energy_full']:
 | 
				
			||||||
                    with open(path + dir + '/' + name, 'r') as file:
 | 
					                    with open(path + dir + '/' + name, 'r') as file:
 | 
				
			||||||
@@ -77,7 +78,10 @@ while True:
 | 
				
			|||||||
            except:
 | 
					            except:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    client.connect(MQTT_HOST)
 | 
					    try:
 | 
				
			||||||
    client.publish("battery2mqtt/" + MQTT_TOPIC + '/' + dir, json.dumps(payload), qos=MQTT_QOS, retain=False)
 | 
					        client.connect(MQTT_HOST)
 | 
				
			||||||
 | 
					        client.publish("battery2mqtt/" + MQTT_TOPIC + '/' + dir, json.dumps(payload), qos=MQTT_QOS, retain=False)
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        print('Message send failure.')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sleep(INTERVAL)
 | 
					    sleep(INTERVAL)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user