Announcement

Collapse
No announcement yet.

Jon00 Homeseer/Echo Skill Helper for Homeseer 3 & Homeseer 4

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jon00
    replied
    You script was totally broken when you tried to break it into different subroutines.

    Anyway, they were not necessary.

    Hopefully you can work with this:

    Code:
        Function Main(ByVal Parm As String) As String
    
            hs.WaitSecs(3) ' Wait 3 seconds to allow the event to trigger and set the virtual device 'AlarmStatus'
    
    
            If hs.DeviceValueByName("AlarmStatus") = 0 Then Return "Goodnight" ' The alarm conditions are not true
    
            '
            ' these are the virtual devices to be updated by the script
            '5281    Windows
            '8829   Doors
    
            'Use the reference ID of the door or window sensor devices in the arrays below
    
            Dim array_windows() As String = {"4557", "4548", "4550", "4543", "4556", "4549", "4564", "4553", "4555", "4554", "4551", "4545", "4544", "4559", "4560", "4561", "4562", "4563"}
    
            Dim array_doors() As String = {"4565", "4542", "4558", "4566", "4532", "4531", "4552", "4523", "4522", "4528", "4527"}
    
            Dim windows_count As Integer = 0
            Dim window_name As String = ""
            Dim wstr As String = ""
            Dim doors_count As Integer = 0
            Dim door_name As String = ""
            Dim dstr As String = ""
            Dim dv As Object
    
            'WINDOWS
    
            Try
                windows_count = 0
                window_name = ""
                wstr = ""
                For Each devw As String In array_windows
                    'hs.writelog("Array", "Window " & window_name & " | Value " & hs.DeviceValue(devw))
                    If hs.DeviceValue(devw) = 1 Then
                        windows_count = windows_count + 1
                        dv = hs.GetDeviceByRef(devw)
                        window_name = dv.Name(hs)
                        wstr = wstr & window_name & ", <br>"
                        hs.WriteLog("DoorWindow", window_name & " Open")
                        'hs.writelog("DoorWindow", array_windows)
                    End If
                Next
                If windows_count > 0 Then
                    hs.SetDeviceValueByRef(5281, 100, True)
                    hs.SetDeviceString(5281, wstr, True)
                Else
                    hs.SetDeviceValueByRef(5281, 0, True)
                    hs.SetDeviceString(5281, "All Windows Closed", True)
                End If
    
                hs.WriteLog("DoorWindow", "Window Count: " & windows_count)
    
            Catch ex As Exception
                hs.WriteLog("DoorWindow", "Error: " & ex.Message)
            End Try
    
            'DOORS
    
            Try
                doors_count = 0
                door_name = ""
                dstr = ""
                For Each devd As String In array_doors
                    'hs.writelog("Array", "Door " & door_name & " | Value " & hs.DeviceValue(devd))
                    If hs.DeviceValue(devd) = 1 Then
                        dv = hs.GetDeviceByRef(devd)
                        door_name = dv.Name(hs)
                        doors_count = doors_count + 1
                        dstr = dstr & door_name & ", <br>"
                        hs.WriteLog("DoorWindow", door_name & " Open")
                    End If
                Next
                If doors_count > 0 Then
                    hs.SetDeviceValueByRef(8829, 100, True)
                    hs.SetDeviceString(8829, dstr, True)
                Else
                    hs.SetDeviceValueByRef(8829, 0, True)
                    hs.SetDeviceString(8829, "All Doors Closed", True)
                End If
    
                hs.WriteLog("DoorWindow", "Door Count: " & doors_count)
    
            Catch ex As Exception
                hs.WriteLog("DoorWindow", "Error: " & ex.Message)
            End Try
    
            If windows_count > 0 Then
                Return "Alarm is not set. The " & hs.DeviceString(5281).Replace("<br>", "") & " Windows are open. Do you want to bypass them or wait until they are all closed before setting the alarm?"
            ElseIf doors_count > 0 Then
                Return "Alarm is not set. The " & hs.DeviceString(8829).Replace("<br>", "") & " Doors are open. Do you want to bypass them or wait until they are all closed before setting the alarm?"
            ElseIf windows_count > 0 And doors_count > 0 Then
                Return "Alarm is not set. The " & hs.DeviceString(5281).Replace("<br>", "") & " Windows and " & hs.DeviceString(8829).Replace("<br>", "") & " Doors are open. Do you want to bypass them or wait until they are all closed before setting the alarm?"
            Else
                Return "Goodnight"
            End If
    
        End Function

    Leave a comment:


  • The Profit
    replied
    Does anyone know if it is possible to have Alexa read a device string in her response?

    I'm thinking that I will have an EasyTrigger group with all of my Alarm Sensors that updates a VD "AlarmStatus" to Open or Closed as they occur throughout the day. Then when I tell Alexa Goodnight, if AlarmStatus is false(Doors/Windows are open), the script will populate two VDs (Windows & Doors). I would then like Alexa to say "Alarm is not set. The (have Alexa read list of open doors/windows) are open. Do you want to bypass them or wait until they are all closed before setting the alarm?"

    Then if I say "Wait" the response trigger will run another event to set a VD "AlarmWait" to On.

    Once all of the Doors/Windows are closed, I have the below event:

    [AutoAlarm after all Doors/Windows closed]
    If Envisalink Partion 1 changes and becomes Ready
    And If AlarmWait is On
    Then set Envisalink Partiion 1 to Alarm Stay
    Then set AlarmWait to Off

    Below is the script for the Primary Alexa Trigger. I need help with how to code the response at the end to read the strings for the Door & Window devices.

    Code:
    Function Main(ByVal Parm As String)
            Dim Response As String = ""
            hs.WaitSecs(3) ' Wait 3 seconds to allow the event to trigger and set the virtual device 'AlarmStatus'
            If hs.DeviceValueByName("AlarmStatus") = 0 Then ' The alarm conditions are not true
        '
        ' these are the virtual devices to be updated by the script
        '5281    Windows
        '8829   Doors
    
        'Use the reference ID of the door or window sensor devices in the arrays below
    
        dim array_windows() as string = {"4557", "4548", "4550", "4543", "4556", "4549", "4564", "4553", "4555", "4554", "4551", "4545", "4544","4559", "4560", "4561",     "4562", "4563"}
    
        dim array_doors() as string = {"4565", "4542", "4558", "4566", "4532", "4531", "4552", "4523", "4522", "4528", "4527"}
    
        dim windows_count as integer = 0
        dim window_name as string = ""
        dim wstr as string = ""
    
        dim doors_count as integer = 0
        dim door_name as String = ""
        dim dstr as string = ""
    
        Dim dv as Object
    
        'Using 2 subs, one for doors and the other for windows
    
        'WINDOWS
        sub windows(ByVal Parms as Object)
        Try
        windows_count = 0
        window_name = ""
        wstr = ""
        for each devw as string in array_windows
            'hs.writelog("Array", "Window " & window_name & " | Value " & hs.DeviceValue(devw))
        if hs.DeviceValue(devw) = 1 then
                    windows_count = windows_count + 1
            dv = hs.GetDeviceByRef(devw)
            window_name =  dv.Name(hs)
                   wstr = wstr & window_name & ",<br>"
        hs.writelog("DoorWindow", window_name & " Open")
        'hs.writelog("DoorWindow", array_windows)
            end if
    next
        If windows_count > 0 then
            hs.SetDeviceValueByRef(5281,100,true)
            hs.SetDeviceString(5281, wstr,true)
        Else
            hs.SetDeviceValueByRef(5281,0,true)
            hs.SetDeviceString(5281, "All Windows Closed",true)
        End If
    
        hs.writelog("DoorWindow", "Window Count: " & windows_count)
    
        Catch ex As Exception
        hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
    End Try
    
    End Sub
    
        'DOORS
        sub doors(ByVal Parms as Object)
        Try
        doors_count = 0
        door_name = ""
        dstr = ""
        for each devd as string in array_doors
                'hs.writelog("Array", "Door " & door_name & " | Value " & hs.DeviceValue(devd))
        if hs.DeviceValue(devd) = 1 then
            dv = hs.GetDeviceByRef(devd)
            door_name =  dv.Name(hs)
            doors_count = doors_count + 1
            dstr = dstr & door_name & ",<br>"
        hs.writelog("DoorWindow", door_name & " Open")
            end if
    next
        If doors_count > 0 then
            hs.SetDeviceValueByRef(8829,100,true)
            hs.SetDeviceString(8829, dstr,true)
        Else
            hs.SetDeviceValueByRef(8829,0,true)
            hs.SetDeviceString(8829, "All Doors Closed",true)
        End If
    
        hs.writelog("DoorWindow", "Door Count: " & doors_count)
    
        Catch ex As Exception
        hs.WriteLog ("DoorWindow", "Error: " & ex.Message)
    End Try
    
    End Sub
    
                Response = "Alarm is not set. The (have Alexa read list of open doors/windows) are open. Do you want to bypass them or wait until they are all closed before setting the alarm?"
            Else
                Response = "Goodnight"
            End If
            Return Response
        End Function​​

    Leave a comment:


  • Fischi
    replied
    Originally posted by jon00 View Post
    The helper relies on the Alexa Homeseer Home Automation skill working correctly. You would need to test that first.

    Check out the installation and usage here: https://docs.homeseer.com/products/a...ll-integration
    Thanks Jon,
    I‘ve it running OK now : I‘ve deactivated and rectivated my skill and entered the user/pw and the vendor id anew.

    The upgrade from Hs3 to Hs 4 was very easy, all events, devices, scripts, plugins and settings are taken over.

    Leave a comment:


  • jon00
    replied
    The helper relies on the Alexa Homeseer Home Automation skill working correctly. You would need to test that first.

    Check out the installation and usage here: https://docs.homeseer.com/products/a...ll-integration

    Leave a comment:


  • Fischi
    replied
    Originally posted by langenet View Post
    Just checking... did you change the primary system to HS4 within myhs?
    Yes, I did.

    Leave a comment:


  • langenet
    replied
    Just checking... did you change the primary system to HS4 within myhs?

    Leave a comment:


  • Fischi
    replied
    Hi,
    I‘ve just made an upgrade from Hs3 to Hs4 and Alexa doesn‘t work anymore.
    I have changed the user/password of myhs to the new credentials but no luck with Alexa and the helper.
    What‘s going wrong ?

    Regards,
    Fischi

    Leave a comment:


  • jon00
    replied
    No, Jon00Alexa.vben is run by the skill; not from an event.

    As I said, if you get a skill up and working, I'm happy to assist then.

    Leave a comment:


  • rvmts59fr
    replied
    Originally posted by jon00 View Post

    You would get errors. The script is not meant to be run from a event.

    As this has dependence on the skill, I'm not going to do anything more with this error. If you get your own skill working and tested, I'm happy to get back to this issue.
    So the jon00alexa.html page setup display is dependant from the skill ?
    That is what you mean ?
    If I create an US account to work with the skill I won't get the error ?

    Leave a comment:


  • jon00
    replied
    Originally posted by donstephens View Post

    Thanks. I have been to impatient.
    I think most here are guilty of RTFM

    I've added your copy trigger feature request. I've sent you a PM with a version to try.

    Please let me know how it goes.

    Leave a comment:


  • jon00
    replied
    Originally posted by rvmts59fr View Post

    No.
    The log show only:
    Creating ASP.NET application host...
    ASP.NET application host created

    And the Jon00Alexa.html doesn't appear, I only have the message error :

    System.InvalidCastException: La conversion de la chaîne "Error" en type 'Integer' n'est pas valide. ---> System.FormatException: Le format de la chaîne d'entrée est incorrect.
    à Microsoft.VisualBasic.CompilerServices.Conversions.ParseDoub le(String Value, NumberFormatInfo NumberFormat) à Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger (String Value) ---
    Fin de la trace de la pile d'exception interne --- à Microsoft.VisualBasic.CompilerServices.Symbols.Container.Inv okeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
    à Microsoft.VisualBasic.CompilerServices.NewLateBinding.Object LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
    à Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGe t(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) à
    scriptcode10.VBWrapper.Main(Object MyData)​


    But if I manually run the script jon00Alexa.vben, I see this kind of error in the log:

    Error in Main Block 8: (La conversion de la chaine "error" en type 'Integer' n'est pas valide. )
    Error in Main Block 1: (La conversion de la chaine "error" en type 'Integer' n'est pas valide. )
    Error in Main Block 0: (L'index se trouve en dehors des limites du tableau. )
    You would get errors. The script is not meant to be run from a event.

    As this has dependence on the skill, I'm not going to do anything more with this error. If you get your own skill working and tested, I'm happy to get back to this issue.

    Leave a comment:


  • donstephens
    replied
    Originally posted by jon00 View Post

    If you hover the mouse over the entry fields on the setup pages, it gives full information about their use.
    Thanks. I have been to impatient.

    Leave a comment:


  • rvmts59fr
    replied
    Originally posted by jon00 View Post
    Does the error also show something like 'Error in Main Block X' ....
    No.
    The log show only:
    Creating ASP.NET application host...
    ASP.NET application host created

    And the Jon00Alexa.html doesn't appear, I only have the message error :

    System.InvalidCastException: La conversion de la chaîne "Error" en type 'Integer' n'est pas valide. ---> System.FormatException: Le format de la chaîne d'entrée est incorrect.
    à Microsoft.VisualBasic.CompilerServices.Conversions.ParseDoub le(String Value, NumberFormatInfo NumberFormat) à Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger (String Value) ---
    Fin de la trace de la pile d'exception interne --- à Microsoft.VisualBasic.CompilerServices.Symbols.Container.Inv okeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
    à Microsoft.VisualBasic.CompilerServices.NewLateBinding.Object LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
    à Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGe t(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) à
    scriptcode10.VBWrapper.Main(Object MyData)​


    But if I manually run the script jon00Alexa.vben, I see this kind of error in the log:

    Error in Main Block 8: (La conversion de la chaine "error" en type 'Integer' n'est pas valide. )
    Error in Main Block 1: (La conversion de la chaine "error" en type 'Integer' n'est pas valide. )
    Error in Main Block 0: (L'index se trouve en dehors des limites du tableau. )

    Leave a comment:


  • jon00
    replied
    Originally posted by donstephens View Post

    It does? In that case, problem 1 solved.
    If you hover the mouse over the entry fields on the setup pages, it gives full information about their use.

    Leave a comment:


  • donstephens
    replied
    Originally posted by jon00 View Post

    In that case, why are you adding Alexa devices in the first place? If the Alexa filter is left blank, then it automatically goes to all devices?
    It does? In that case, problem 1 solved.

    Leave a comment:

Working...
X