forked from sthope/battery2mqtt
Remove extraneous code
This commit is contained in:
parent
b34842c24d
commit
0fa94903a6
@ -26,8 +26,6 @@ if LOG_LEVEL.lower() not in ['debug', 'info', 'warning', 'error']:
|
|||||||
else:
|
else:
|
||||||
logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)s: %(message)s')
|
logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)s: %(message)s')
|
||||||
|
|
||||||
client = mqtt.Client(MQTT_CLIENT)
|
|
||||||
|
|
||||||
monitored_conditions = MONITORED_CONDITIONS.split(',')
|
monitored_conditions = MONITORED_CONDITIONS.split(',')
|
||||||
path = "/sys/class/power_supply/"
|
path = "/sys/class/power_supply/"
|
||||||
dirs = os.listdir(path)
|
dirs = os.listdir(path)
|
||||||
@ -41,6 +39,7 @@ def mqtt_connect():
|
|||||||
# Connect to MQTT broker, set LWT, and start loop
|
# Connect to MQTT broker, set LWT, and start loop
|
||||||
global mqtt_connected
|
global mqtt_connected
|
||||||
try:
|
try:
|
||||||
|
client = mqtt.Client(MQTT_CLIENT)
|
||||||
client.username_pw_set(MQTT_USER, MQTT_PASSWORD)
|
client.username_pw_set(MQTT_USER, MQTT_PASSWORD)
|
||||||
client.will_set("battery2mqtt/" + MQTT_TOPIC + '/status', 'offline', 0, True)
|
client.will_set("battery2mqtt/" + MQTT_TOPIC + '/status', 'offline', 0, True)
|
||||||
client.connect(MQTT_HOST, MQTT_PORT)
|
client.connect(MQTT_HOST, MQTT_PORT)
|
||||||
@ -68,7 +67,6 @@ def check_conditions():
|
|||||||
def get_info():
|
def get_info():
|
||||||
# Get requested conditions and generate/send MQTT payload
|
# Get requested conditions and generate/send MQTT payload
|
||||||
global payload
|
global payload
|
||||||
global prev_payload
|
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if AC_ADAPTER:
|
if AC_ADAPTER:
|
||||||
if dir.startswith('AC'):
|
if dir.startswith('AC'):
|
||||||
@ -139,4 +137,4 @@ mqtt_connect()
|
|||||||
|
|
||||||
while mqtt_connected:
|
while mqtt_connected:
|
||||||
get_info()
|
get_info()
|
||||||
sleep(INTERVAL)
|
sleep(INTERVAL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user