Android Question Tuya ZigBee Human Presence Sensor ZY-M100 Review

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings to the beloved bxa community. I was wondering if anyone has developed an app that connects at least two sensors and makes the phone vibrate when there's a "presence"... I tried this, but I don't know; in the end, it didn't work.

ejemplo:
#Region  Project Attributes
    #ApplicationLabel: SensorPresenciaM100
    #VersionCode: 1
    #VersionName: 1.0
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Dim TimerCheck As Timer
    Dim Sensors As List
    Dim phone As Phone
    Dim HttpJobs As Map
End Sub

Sub Globals
    Dim ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("mainlayout")
    ListView1.Initialize("")
    
    Sensors.Initialize
    ' Agrega aquí tus IPs de sensores:
    Sensors.AddAll(Array("192.168.1.101"))
    
    For Each ip As String In Sensors
        ListView1.AddSingleLine2("Sensor " & ip, ip)
    Next
    
    TimerCheck.Initialize("TimerCheck", 2000)
    TimerCheck.Enabled = True
    HttpJobs.Initialize
End Sub

Sub TimerCheck_Tick
    For Each ip As String In Sensors
        Dim j As HttpJob
        j.Initialize("Presencia", Me)
        j.Download("http://" & ip & "/status")
        HttpJobs.Put(j, ip)
    Next
End Sub

Sub JobDone(Job As HttpJob)
    Dim ip As String = HttpJobs.Get(Job)
    If Job.Success Then
        Dim respuesta As String = Job.GetString.Trim.ToUpperCase
        If respuesta.Contains("PRESENT") Then
'            phone.Vibrate(1000)
            ToastMessageShow("Presencia detectada por " & ip, False)
        End If
    Else
        Log("Error con " & ip)
    End If
    Job.Release
    HttpJobs.Remove(Job)
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
'    StartActivity(SensorConfig.Create(Value))
End Sub
 
Top