Announcement

Collapse
No announcement yet.

IPUpdate script changes - need a little help

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

    IPUpdate script changes - need a little help

    Hi,

    I would like to modify the IPUpdate script to store the date/time of the last IP address change in the script's WAN IP Address device 'last change' field displayed in HS' status view. I tried to figure it out, but can't get figure out the HS function. I'd appreciate if someone could provide the script code that's required.

    I would also like to to detect a change in IP so I can trigger event(s). I tried device value change action and that didn't work. It looks like the device value never changes just the description displayed in the HS status view. What trigger can be used to cause an event to run?

    This is a very cool script. Thanks, Jon!

    Thanks!

    #2
    Hi Adam,

    Find the line:

    hs.setDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress)

    Replace it with the following two lines:

    hs.setDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress,true)
    hs.SetDeviceValue (UDevCode,DateTime.Now.ToString("dd:MM:HH:mm:ss").Replace(": ",""))

    You should now be able to trigger on device value change and see the date when it changed on the virtual device.
    Jon

    Comment


      #3
      Thanks Jon.

      'Device Value Change', Value is 'Any Value' with Value = '0' ??

      Is it possible to include the new IP address in the alert via some sort of variable reference?

      Comment


        #4
        Yes, it should trigger on that fine.

        I'm not sure what you mean about a variable reference?
        Jon

        Comment


          #5
          I'd like the HS alert to be WAN 'IP address has changed to a.b.c.d' where a.b.c.d is the actual IP address. Is there a way to reference the device value in an HS action user-defined text field?
          Attached Files

          Comment


            #6
            Homeseer has a replacement variable for device status:
            Code:
            $$DV:(address)
            , however that would not give you any meaningful data. You may suggest that the device value could be the numeric value of the IP address. Unfortunately that is not possible as a device value is integer based and a (up to) 12 digit number is too big.

            There is no replacement variable (that I know of) for the device string which would be useful.

            All you can do is ask the Growl plugin author to provide a suitable interface such as displaying a defined global variable.
            Jon

            Comment


              #7
              I know this is an old thread but trying to get the IP script to update last change time HS2 and date in a device. I added the following lines but get this error.

              hs.setDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress,true)
              hs.SetDeviceValue (UDevCode,DateTime.Now.ToString("dd:MM:HH:mm:ss").Replace(": ",""))

              Jon00_IPUpdate Error within Subroutine Main at block 6 (Conversion from string "08:02:09:11:23" to type 'Integer' is not valid.)


              HS4 Environment
              Proxmox win11 / HS4
              Netiom-Xap board
              Plug-In's
              rnbWeather 4.4.2.0
              mcsMQTT V6.15.1.0
              mcsXap V3.0.0.72
              Zigbee Plus V1.0.0.0
              Zigbee V4.0.11.0

              There is no place Like 127.0.0.1

              Comment


                #8
                Try this:

                hs.SetDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress,true)
                hs.SetDeviceValue (UDevCode,CInt(DateTime.Now.ToString("HHmmss")))
                Jon

                Comment


                  #9
                  Thank You it worked!!!!
                  HS4 Environment
                  Proxmox win11 / HS4
                  Netiom-Xap board
                  Plug-In's
                  rnbWeather 4.4.2.0
                  mcsMQTT V6.15.1.0
                  mcsXap V3.0.0.72
                  Zigbee Plus V1.0.0.0
                  Zigbee V4.0.11.0

                  There is no place Like 127.0.0.1

                  Comment


                    #10
                    Question is there a way to just have it update the time if there is a IP update and not every time the script runs?
                    HS4 Environment
                    Proxmox win11 / HS4
                    Netiom-Xap board
                    Plug-In's
                    rnbWeather 4.4.2.0
                    mcsMQTT V6.15.1.0
                    mcsXap V3.0.0.72
                    Zigbee Plus V1.0.0.0
                    Zigbee V4.0.11.0

                    There is no place Like 127.0.0.1

                    Comment


                      #11
                      You can change the line:

                      PHP Code:
                      If Len(IPAddress) <> 0 Then 
                      To

                      PHP Code:
                      If Len(IPAddress) <> And hs.GetINISetting ("Data","IPAddress""" ,"Jon00IPUpdate.ini") <> IPAddress Then 
                      Jon

                      Comment


                        #12
                        for some reason it still updating the Last change time for the device wether there is a change or not . here is a snip of the code.

                        '----------------------------------------------------------------------------------------------------------------------------
                        'Updated by Paul to show time last changed value in device.
                        '----------------------------------------------------------------------------------------------------------------------------
                        ' If Len(IPAddress) <> 0 Then
                        If Len(IPAddress) <> 0 And hs.GetINISetting ("Data","IPAddress", "" ,"Jon00IPUpdate.ini") <> IPAddress Then
                        hs.SaveINISetting ("Data","IPAddress", IPAddress ,"IPUpdate.ini")
                        hs.SetDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress,true)
                        hs.SetDeviceValue (UDevCode,CInt(DateTime.Now.ToString("HHmmss")))
                        End If

                        If ForceUpdate ="1" then ExistingIP="0.0.0.0"
                        Catch ex As Exception
                        HS4 Environment
                        Proxmox win11 / HS4
                        Netiom-Xap board
                        Plug-In's
                        rnbWeather 4.4.2.0
                        mcsMQTT V6.15.1.0
                        mcsXap V3.0.0.72
                        Zigbee Plus V1.0.0.0
                        Zigbee V4.0.11.0

                        There is no place Like 127.0.0.1

                        Comment


                          #13
                          Looks like you have changed the name of the ini file from Jon00IPUpdate.ini to IPUpdate.ini (one of the reasons I now encrypt my downloads)
                          Jon

                          Comment


                            #14
                            I just saw that and was testing it got it now. Here is what I ended up with

                            '----------------------------------------------------------------------------------------------------------------------------
                            'Updated by Paul to show time last changed value in device.
                            '----------------------------------------------------------------------------------------------------------------------------
                            If Len(IPAddress) <> 0 And hs.GetINISetting ("Data","IPAddress", "" ,"IPUpdate.ini") <> IPAddress Then
                            hs.SaveINISetting ("Data","IPAddress", IPAddress ,"IPUpdate.ini")
                            hs.SetDeviceString (UDevCode, "<img src='\images\ipupdate\ip.gif'> WAN IP Address: " & IPAddress,true)
                            hs.SetDeviceValue (UDevCode,CInt(DateTime.Now.ToString("HHmmss")))
                            End If
                            HS4 Environment
                            Proxmox win11 / HS4
                            Netiom-Xap board
                            Plug-In's
                            rnbWeather 4.4.2.0
                            mcsMQTT V6.15.1.0
                            mcsXap V3.0.0.72
                            Zigbee Plus V1.0.0.0
                            Zigbee V4.0.11.0

                            There is no place Like 127.0.0.1

                            Comment

                            Working...
                            X