I have an event which triggers when any window is open and it starts to rain. It triggers a TTS that a window is open and it has started to rain. I now want to expand this so the event will tell me which window(s) is open. I think I have seen something like this on the forum a few months ago but didnt bookmark it and now cannot find it any more.
Announcement
Collapse
No announcement yet.
Trying to create event which tells me which window is open
Collapse
X
-
I use a script to write my window status to a virtual device to display which window (or door into another virtual device) is opened. I guess that could be the basis for what I want to develop
Code:'Define Windows/Doors Array dim array_windows() as string = {"Bedroom Right Window","Bedroom Left Window","Cloakroom window","Study Window","Gym Window","EnSuite Window"} dim array_doors() as string = {"Garage Door","Porch Door","Garage Inside Door","Kitchen Back Door","Patio Door","Bedroom Door"} dim windows_count as integer = 0 dim doors_count as integer = 0 dim door_name as String = "" dim dstr as string = "" dim window_name as string = "" dim wstr as string = "" sub windows(ByVal Parms as Object) Try windows_count = 0 window_name = "" wstr = "" for each devw as string in array_windows if hs.DeviceValueByName(devw) = 255 or hs.DeviceValueByName(devw) = 100 then windows_count = windows_count + 1 window_name = devw wstr = wstr & window_name & " Opened" & "<br>" Else If hs.DeviceValueByName(devw) = 0 then 'No windows open end if next If windows_count > 0 then hs.SetDeviceValueByRef(439,100,true) hs.SetDeviceString(439, wstr,true) Else hs.SetDeviceValueByRef(439,0,true) hs.SetDeviceString(439, "All Windows Closed",true) End If hs.writelog("Array", "Window Count: " & windows_count) Catch ex As Exception hs.WriteLog ("Array", "Error: " & ex.Message) End Try End Sub sub doors(ByVal Parms as Object) Try doors_count = 0 door_name = "" dstr = "" for each devd as string in array_doors if hs.DeviceValueByName(devd) = 255 or hs.DeviceValueByName(devd) = 100 or hs.DeviceValueByName(devd) = 22 then doors_count = doors_count + 1 door_name = devd dstr = dstr & door_name & " Opened" & "<br>" Else If hs.DeviceValueByName(devd) = 0 then 'No doors open end if next If doors_count > 0 then hs.SetDeviceValueByRef(438,100,true) 'was 170 hs.SetDeviceString(438, dstr,true) 'was 170 Else hs.SetDeviceValueByRef(438,0,true) hs.SetDeviceString(438, "All Doors Closed",true) End If Catch ex As Exception hs.WriteLog ("Array", "Error: " & ex.Message) End Try hs.writelog("Script","multistatustest") End Sub
- 1 like
-
I'm sure something like this would work:
Code:Sub Main(ByVal Parms As Object) Dim array_windows() As String = {"Bedroom Right Window", "Bedroom Left Window", "Cloakroom window", "Study Window", "Gym Window", "EnSuite Window"} For Each devw As String In array_windows If hs.DeviceValueByName(devw) = 100 Or hs.DeviceValueByName(devw) = 255 Then hs.speak(devw & " is open") Next End Sub
Comment
-
Theoretically it probably would. But I want to route it to one of my tablets via tasker TTS. Ill have a look on the tasker part of the forum, and see if there is a script command, I think I vaguely remember there is a way. Before your response I started thinking of maybe adding it all up in a string variable, but that would need to be available outside of the script. I could then use tasker tts - variable to speak it. I think I would need to create a golbal variable, i think they are available outside of the script. I was probably overthinking this.
So I think I'll try your approach first, if needed with the tasker speak command in the script
Comment
-
Originally posted by mikee123 View PostI have an event which triggers when any window is open and it starts to rain. It triggers a TTS that a window is open and it has started to rain. I now want to expand this so the event will tell me which window(s) is open. I think I have seen something like this on the forum a few months ago but didnt bookmark it and now cannot find it any more.
Comment
Comment