Created
May 11, 2021 22:39
-
-
Save neuberfran/3e5f9c2f0e2ffd8cd686ef9412c91741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gpgaragestate = db.collection("device-configs").document("garagem") | |
gpiogaragestateb.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW) | |
gpgaragestate.addSnapshotListener { snapshot, e -> | |
if (e != null) { | |
Log.w(LOG.toString(), "Listen failed.", e) | |
return@addSnapshotListener | |
} | |
var vlrgaragesta=snapshot?.toObject(FireFranB::class.java)?.value?.get("openPercent") | |
var vlrgaragestab=snapshot?.toObject(FireFranB::class.java)?.garagestate | |
Log.w(TAG, "Listen 94336 94336 94336" + vlrgaragesta) | |
Log.w(TAG, "Listen 94336_2 94336_2 94336_2" + vlrgaragestab) | |
if (vlrgaragesta == 100 && !vlrgaragestab!!) { | |
gpiogaragestateb?.setValue(true) | |
Log.w(TAG, "Listen 94337 94337 94337." + vlrgaragesta) | |
Log.w(TAG, "Listen 94337_2 94337_2 94337_2" + vlrgaragestab) | |
}else if (vlrgaragesta == 0 && vlrgaragestab!!) { | |
gpiogaragestateb?.setValue(false) | |
Log.w(TAG, "Listen 94338 94338 94338" + vlrgaragesta) | |
Log.w(TAG, "Listen 94338_2 94338_2 94338_2" + vlrgaragestab) | |
}else if (vlrgaragesta == 100 && vlrgaragestab!!){ | |
Log.w(TAG, "Listen 95003 95003 95003" + vlrgaragesta) | |
Log.w(TAG, "Listen 95000_3 95000_3 95000_3" + vlrgaragestab) | |
gpgaragestate.update(mapOf("value.openPercent" to 0)) | |
}else if (vlrgaragesta == 0 && !vlrgaragestab!!){ | |
Log.w(TAG, "Listen 950013 950013 950013" + vlrgaragesta) | |
Log.w(TAG, "Listen 95001_3 95001_3 95001_3" + vlrgaragestab) | |
gpgaragestate.update(mapOf("value.openPercent" to 100)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment