Announcement

Collapse
No announcement yet.

ipitman and homeland script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ipitman and homeland script

    can't post reply in scripts library, questions should be posted in the discussion area.

    ev.rec_mins does not appear to be part of the event class. try deleting the line "ev.rec_mins = strMinutes " and replacing it with "ev.rec_secs = strMinutes"

    ' if strMinutes > 0 then

    ' ev_count = hs.EventCount

    ' for i=1 to ev_count
    ' Set ev=hs.GetEvent(i)

    ' if ev.name = "Homeland Security Level" then
    ' if ev.rec_mins <> strMinutes then
    ' ev.rec_mins = strMinutes
    ' ev.rec_secs = 0
    ' AlertChange(strAlert)
    ' end if
    ' end if
    ' next

    ' End If

    #2
    Also best not to use GetEvent (You should be seeing a warning in your event log "GetEvent is not reliable for event enumeration. Please use the new GetEventEnumerator method.").

    Instead use something like:

    set en = hs.GetEventEnumerator

    Do While not en.Finished

    set ev = en.GetNext
    if ev.name = "Homeland Security Level" Then
    ev.rec_secs = 60 * strMinutes
    AlertChange(strAlert)
    End If

    Loop


    Regards,
    John

    Comment


      #3
      Thanks guys, I will try the suggestions tonight when I get home.

      Lrry.
      -Larry

      A member of "The HA Pioneer Group", MyWebSite

      Plugins:
      VWS, AB8SS, lrpSpeak, Calendar, Arduino, Harmony, BlueIris, Sprinklers, ZipBackup...

      Hardware:
      Intel NUC8i7BEH1 running Windows 10 Pro headless, HS3 Pro, Plex running on Synology dual High Availability DS-1815+ NAS (24Tb each), Synology Surveillance Station running on DS-416 Slim (8Tb), Samsung SmartThings, Google Home, Alexa, Hubitat Elevation, ZNET, Ubiquiti UniFi Network, Davis Vantage Pro II Weather Station. Whole house speaker system using a couple of AB8SS switches. Vantage Pro II Weather Station, Rain8Net Sprinklers, Hubitat Elevation, Google Home, Alexa, DSC Security System, Ubiquiti UniFi Network.

      Comment


        #4
        Help with more coding

        Ok, JimBob that seems to be working fine. Thanks

        Maybe you can also help me with this idea:

        '****----------- test code ------------------------------

        ' get the last change time for the device "Homeland Security Level"
        'last_change = hs.DeviceLastChange("x15")

        'If last_change < "Today ????" then
        'hs.speak strToSpeak,True
        'End If

        '****------------------------------------------------------

        The goal here is to only speak the phrase if the LastChange time was less than Today or less than a couple of hours ago or some flavor like that. Any help will be appreciated.

        Thanks
        Larry.
        -Larry

        A member of "The HA Pioneer Group", MyWebSite

        Plugins:
        VWS, AB8SS, lrpSpeak, Calendar, Arduino, Harmony, BlueIris, Sprinklers, ZipBackup...

        Hardware:
        Intel NUC8i7BEH1 running Windows 10 Pro headless, HS3 Pro, Plex running on Synology dual High Availability DS-1815+ NAS (24Tb each), Synology Surveillance Station running on DS-416 Slim (8Tb), Samsung SmartThings, Google Home, Alexa, Hubitat Elevation, ZNET, Ubiquiti UniFi Network, Davis Vantage Pro II Weather Station. Whole house speaker system using a couple of AB8SS switches. Vantage Pro II Weather Station, Rain8Net Sprinklers, Hubitat Elevation, Google Home, Alexa, DSC Security System, Ubiquiti UniFi Network.

        Comment


          #5
          Something like this

          Larry,

          I actually do something very similar already.

          Here's a sampler looking at if the device has changed in the last 4 hours:

          You will obviously need to cater for times spanning the midnight boundary, comparing the current datetime and datetime returned from DeviceLastChange. You can extract the date and time components of the datetime into separate date and time values using the DatePart function (an example of getting the hour is commented out)

          HWDtime = hs.DeviceLastChange(HWRcode)

          'HWHour = Datepart("h", HWDtime)

          CurrDtime = Now

          Timediffy = DateDiff("h", HWDtime, CurrDtime)
          ' DateDiff can return in deifferent intervals depending on first parameter
          'hs.WriteLog "Diff in hrs is ", Timediffy

          If Timediffy < 4 Then
          ' Device changed less than four hours ago
          ' Action Here
          End If

          It's a bit crude at the moment since it is only looking at the difference in the hours, the test will pass if the device has changed in the last 4 hours 59 mins, so may better to check < 3. You best check on this, but I think the DateDiff would return 4 if the two times were say 12:01 and 16:59.

          I tend to riddle my scripts with hs.WriteLog entries so I can see the values as the script fires. You can then comment them out after you've finished debugging.

          Anyway, your starter for 10!

          Good luck,
          John

          Comment


            #6
            Awsome, I will try your example.. Thanks for your expertise, this board is great for giving me an education, and my smart home just keeps getting smarter.

            Thanks
            Larry.
            -Larry

            A member of "The HA Pioneer Group", MyWebSite

            Plugins:
            VWS, AB8SS, lrpSpeak, Calendar, Arduino, Harmony, BlueIris, Sprinklers, ZipBackup...

            Hardware:
            Intel NUC8i7BEH1 running Windows 10 Pro headless, HS3 Pro, Plex running on Synology dual High Availability DS-1815+ NAS (24Tb each), Synology Surveillance Station running on DS-416 Slim (8Tb), Samsung SmartThings, Google Home, Alexa, Hubitat Elevation, ZNET, Ubiquiti UniFi Network, Davis Vantage Pro II Weather Station. Whole house speaker system using a couple of AB8SS switches. Vantage Pro II Weather Station, Rain8Net Sprinklers, Hubitat Elevation, Google Home, Alexa, DSC Security System, Ubiquiti UniFi Network.

            Comment

            Working...
            X