forked from sthope/battery2mqtt
Minor tweak
This commit is contained in:
parent
543599eef6
commit
6fcece939f
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user