RoyOltmans / aqualin-mqtt-deamon

Lightweight aqualin BLE mqtt deamon controller
9 stars 4 forks source link

Valve state of Aqualin is never retrieved #6

Closed georgeavd closed 10 months ago

georgeavd commented 3 years ago

The valve state is never retrieved from the Aqualin due to to many 'deviceblelock' instructions.

First after commenting (or deleting) the lines as below the valve state is correctly presented in the MQTT-message:


....
def runvalvecheck():
    global deviceblelock
    for i, devicemac in enumerate(devicemaclist):
        if trace:
            print "runvalvecheck start -  deviceblelock: " + str(deviceblelock)
        if deviceblelock == False:
#            deviceblelock = True
#            device = btle.Peripheral(str(devicemac))
            intsolenoidstate = getsolenoidvalve(devicemac)
            print "Solenoide state is: " + str(intsolenoidstate)
            if intsolenoidstate <= 0:
                strvalvestate = 'off'
            else:
                strvalvestate = 'on'
            client.publish(mqttbasepath + str(devicemac) + '/valvestate', strvalvestate)  # publish
            if trace:
                print "Valve state is " + strvalvestate + " for device " + str(devicemac)
            time.sleep(int(waittime))
#            device.disconnect()
#            deviceblelock = False
            if trace:
                print "runvalvecheck end -  deviceblelock: " + str(deviceblelock)
        else:
            time.sleep(5)
 ....
warthog9 commented 2 years ago

I'll confirm this basically getsolenoidvalve() also tries to open/connect to the device except runvalvecheck() has already done so. Removing the connection logic from runvalvecheck() and leaving that to the former resolves this.