我对这个应用程序有一些问题。我需要的是,如果我检测到数据库(FIREBASE)的变化,特别是在'sala'和'ventilacion'节点中,函数会做它必须做的。如果数据库没有任何变化,它也不会做任何事情。我正在使用python和pyresebase库。这是密码。非常感谢你的帮助。在
import pyrebase
import serial
import time
config = {
#firebase configurations
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
def ReconfiguracionFabrica():
ser.write('AT')
time.sleep(0.2)
ser.write('AT+RENEW')
time.sleep(0.3)
def ConfiguracionMaster():
time.sleep(0.5)
ser.write('AT+IMME1')
time.sleep(0.350)
ser.write('AT+ROLE1')
time.sleep(0.2)
ser=serial.Serial(port="/dev/ttyAMA0", baudrate=9600, timeout=1)
ReconfiguracionFabrica()
time.sleep(0.1)
ConfiguracionMaster()
time.sleep(0.1)
print "********** INICIO *************"
ser.flushInput()
contador=0
prender= ''
ventilacion1= ''
checkeo= ''
while True:
#if db.child("sala").: # It is the line where would be the conditional that allows me to detect any change only in the sala's node.
salidaLed1 = db.child("sala").get()
ser.write('AT')
time.sleep(0.1)
ser.write('AT+CON508CB16A7014')
time.sleep(0.1)
if salidaLed1.val()== True:
prender=";"
if salidaLed1.val()== False:
prender=","
ser.write('luz: %s \n' %(prender))
print ('luz: %s \n' %(prender))
time.sleep(1)
ser.read(checkeo)
if checkeo== 'j':
ReconfiguracionFabrica()
time.sleep(0.1)
ConfiguracionMaster()
我知道这篇文章已经有2年了,但希望这篇文章能有所帮助。尝试使用firebase_管理模块。在
使用以下命令-pip install firebase admin
我也有一个要求,我需要检查对Firebase数据库所做的更改。我提到了here
下面是一个基于您的问题的示例代码,您可以参考并尝试它。在
设置示例数据并验证其可读性。
这个阶段要完成一次!在
创建第一个执行更新的脚本:
使用流处理程序创建第二个脚本
^{3美元运行流处理程序脚本:
启动后
def stream_handler
的响应输出(初始数据):运行更新程序脚本:
监视流处理程序脚本的输出
在第一次更新数据之后,
def stream_handler
的响应输出:用Python:3.4.2测试
相关问题 更多 >
编程相关推荐