Announcement

Collapse
No announcement yet.

Scipt to pull data from the new WU API

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

    Scipt to pull data from the new WU API

    Here is the script I am using to pull data from the new WU API. This only works if you are also sending WU data and they have given you a new key for the new API.
    I don't expect that this will work exactly as is for anyone else, but it does give you a starting place. Sorry that it is not commented better.

    Code:
    Imports System.Web.Script.Serialization
    
    Const Fname As String  = "WeatherForecast.vb"          ' this file name
    Const Lcolor As String = "#ffaa56"                     ' log color for normal
    
    Dim json As New JavaScriptSerializer
    
    Sub Main(ByVal Parms As Object)
    
        Try
            Dim DataRaw As String = hs.geturl ("https://api.weather.com","/v3/wx/forecast/daily/5day?geocode=your_latitude,your_longitude&units=e&language=en-US&format=json&apiKey=your_key",FALSE ,"80")
    
         if left(DataRaw,5) = "ERROR" then
            hs.WriteLogDetail(Fname,DataRaw, "#FF0000", 2,Fname & ":Main",1)
         else
    
            Dim jData As WU = json.Deserialize(Of WU)(DataRaw)
    
            UpdateNlog("w100",0,jData.dayOfWeek(0),0)
            UpdateNlog("w110",jData.temperatureMin(0),"",0)
            UpdateNlog("w140",jData.daypart(0).iconCode(1),jData.daypart(0).narrative(1),0)
    
            if IsNothing(jData.temperatureMax(0)) then              ' WU sends null when the day forcast has already passed
               'UpdateNlog("w120",-99,"",1)
            else
               UpdateNlog("w120",jData.temperatureMax(0),"",0)
            end if
    
            if IsNothing(jData.daypart(0).iconCode(0)) then         ' Use the night icon if the day one is no longer being sent
               UpdateNlog("w130",jData.daypart(0).iconCode(1),jData.daypart(0).narrative(1),0)
               UpdateNlog("w105",2,"",0)                                                      ' night forecast
            else
               UpdateNlog("w130",jData.daypart(0).iconCode(0),jData.daypart(0).narrative(0),0)
               UpdateNlog("w105",1,"",0)                                                      ' day forecast
            end if
    
            UpdateNlog("w101",0,jData.dayOfWeek(1),0)
            UpdateNlog("w111",jData.temperatureMin(1),"",0)
            UpdateNlog("w121",jData.temperatureMax(1),"",0)
            UpdateNlog("w131",jData.daypart(0).iconCode(2),jData.daypart(0).narrative(2),0)
            UpdateNlog("w141",jData.daypart(0).iconCode(3),jData.daypart(0).narrative(3),0)
    
            UpdateNlog("w102",0,jData.dayOfWeek(2),0)
            UpdateNlog("w112",jData.temperatureMin(2),"",0)
            UpdateNlog("w122",jData.temperatureMax(2),"",0)
            UpdateNlog("w132",jData.daypart(0).iconCode(4),jData.daypart(0).narrative(4),0)
            UpdateNlog("w142",jData.daypart(0).iconCode(5),jData.daypart(0).narrative(5),0)
    
            UpdateNlog("w103",0,jData.dayOfWeek(3),0)
            UpdateNlog("w113",jData.temperatureMin(3),"",0)
            UpdateNlog("w123",jData.temperatureMax(3),"",0)
            UpdateNlog("w133",jData.daypart(0).iconCode(6),jData.daypart(0).narrative(6),0)
            UpdateNlog("w143",jData.daypart(0).iconCode(7),jData.daypart(0).narrative(7),0)
    
            UpdateNlog("w104",0,jData.dayOfWeek(4),0)
            UpdateNlog("w114",jData.temperatureMin(4),"",0)
            UpdateNlog("w124",jData.temperatureMax(4),"",0)
            UpdateNlog("w134",jData.daypart(0).iconCode(8),jData.daypart(0).narrative(8),0)
            UpdateNlog("w144",jData.daypart(0).iconCode(9),jData.daypart(0).narrative(9),0)
    
         end if
    
    Catch Ex As Exception
        hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 2,Fname & ":Main",1)
        End Try
    
    End Sub
    
        Public Class Daypart
            Public Property cloudCover As Integer?()
            Public Property dayOrNight As String()
            Public Property daypartName As String()
            Public Property iconCode As Integer?()
            Public Property iconCodeExtend As Integer?()
            Public Property narrative As String()
            Public Property precipChance As Integer?()
            Public Property precipType As String()
            Public Property qpf As Double?()
            Public Property qpfSnow As Double?()
            Public Property qualifierCode As Object()
            Public Property qualifierPhrase As Object()
            Public Property relativeHumidity As Integer?()
            Public Property snowRange As String()
            Public Property temperature As Integer?()
            Public Property temperatureHeatIndex As Integer?()
            Public Property temperatureWindChill As Integer?()
            Public Property thunderCategory As String()
            Public Property thunderIndex As Integer?()
            Public Property uvDescription As String()
            Public Property uvIndex As Integer?()
            Public Property windDirection As Integer?()
            Public Property windDirectionCardinal As String()
            Public Property windPhrase As String()
            Public Property windSpeed As Integer?()
            Public Property wxPhraseLong As String()
            Public Property wxPhraseShort As String()
        End Class
    
        Public Class WU
            Public Property dayOfWeek As String()
            Public Property expirationTimeUtc As Integer()
            Public Property moonPhase As String()
            Public Property moonPhaseCode As String()
            Public Property moonPhaseDay As Integer?()
            Public Property moonriseTimeLocal As Object()
            Public Property moonriseTimeUtc As Integer?()
            Public Property moonsetTimeLocal As Object()
            Public Property moonsetTimeUtc As Integer?()
            Public Property narrative As String()
            Public Property qpf As Double?()
            Public Property qpfSnow As Double?()
            Public Property sunriseTimeLocal As DateTime()
            Public Property sunriseTimeUtc As Integer?()
            Public Property sunsetTimeLocal As DateTime()
            Public Property sunsetTimeUtc As Integer?()
            Public Property temperatureMax As Integer?()
            Public Property temperatureMin As Integer?()
            Public Property validTimeLocal As DateTime()
            Public Property validTimeUtc As Integer?()
            Public Property daypart As Daypart()
        End Class
    
    Sub UpdateNlog (HDcode As String, Dvalue As Double, Dstr as String, Always as Integer) ' this routine updates a device and logs it if
                                                                           ' it changed and if logging is turned on for the device or if always is set
      Try
        dim Dref    = hs.GetDeviceRef(HDcode)                                   ' get the reference to the device based on the house/device code
        dim dv      = hs.GetDeviceByRef(Dref)                                   ' get device settings
        dim Du      = hs.GetDeviceByRef(Dref)                                   ' get device data
        dim Dstring = hs.DeviceVSP_GetStatus(Dref, Dvalue, 1)                   ' get the string
    
        hs.SetDeviceValueByRef (Dref,Dvalue,TRUE)                               ' update the device value
        if Dstr > "" then
           hs.SetDeviceString (Dref,Dstr,true)                                  ' update the device string if provided
           Dstring = Dstr                                                       ' for the log
        end if
    
        if (dv.MISC_Check(hs, Enums.dvMISC.NO_LOG) = 0) or (Always = 1) then    ' should it be logged?
           hs.WriteLogDetail(Fname,Du.Location(hs) & " " & Du.name(hs) & " set to: " & Dstring, Lcolor, 9,Fname,1)
        end if
    
    
    Catch Ex As Exception
          hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 1,Fname & ":UpdateNlog",9)
    End Try
    
    end sub
    You will have to create the devices that the script expects.
    Here's one example. (Only the first few icons shown)




    #2
    Great, thanks for posting. Was planning on writing one myself as it sounds like it will take Jeff a while to update WeatherXML plugin, so it's nice not to have to do that!
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      One of the things I'm looking for is forecast precipitation amounts. I should be able to populate a device for that like this, correct?:

      Code:
       UpdateNlog("w999",0,jData.qpf(x),0)
      where x is 0 through 5 for the different days?

      Thanks again!
      HS 4.2.8.0: 2134 Devices 1252 Events
      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

      Comment


        #4
        Actually, I suspect that you would want:
        UpdateNlog("w999",jData.qpf(x),"",0)

        Comment


          #5
          Originally posted by joegr View Post
          Actually, I suspect that you would want:
          UpdateNlog("w999",jData.qpf(x)."",0)
          Ok, thanks!
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            Thanks for posting.

            Comment


              #7
              Thank you for posting .. would it be possible to provide some basic guidance in terms of use. Admittedly i am a newbie but it would be very helpful if I can get this running while HomeSeer WU plugin is getting updated. Thank you in advance for any assistance.

              Comment


                #8
                Originally posted by cdahl View Post
                Thank you for posting .. would it be possible to provide some basic guidance in terms of use. Admittedly i am a newbie but it would be very helpful if I can get this running while HomeSeer WU plugin is getting updated. Thank you in advance for any assistance.
                Sure, I can try. I know it's poorly commented. What in particular did you want to start with?

                Comment


                  #9
                  I am looking at this script, to pull data from WU into HS3. I am not very good at scripts, but understand a little. First, will it be possible to retrieve current data like temperature, windspeed and rainfall (which I am going to send to WU from my PWS). I would think they are all the Public Property variables in the script. Not that interested in forecast at this stage, just all the data my PWS is sending to WU.
                  If thats possible, I have a few questions (to start)
                  I will need to create virtual devices for all the data I want to retrieve. I set the house code as per your example.
                  If I only wanted the variables under Public Property, what house/device code would they be ? I think the script only pulls in the forecast or am I wrong ?

                  Comment


                    #10
                    The script I made only pulls forecast data. I get current condition data directly from my weather station.
                    You would have to use the observations URL to get current data, then you would have to set up different classes for the json decode.
                    /v3/wx/forecast/daily/5day?geocode=your_latitude,your_longitude&units=e&language=e n-US&format=json&apiKey=your_key
                    would change to
                    /v2/pws/observations/current?stationId=your_station_id&format=json&units=e&apiKey =your_key
                    then the "public property" statements would have to change to:
                    Code:
                        Public Class Imperial
                            Public Property temp As Integer
                            Public Property heatIndex As Integer
                            Public Property dewpt As Integer
                            Public Property windChill As Integer
                            Public Property windSpeed As Integer
                            Public Property windGust As Integer
                            Public Property pressure As Double
                            Public Property precipRate As Double
                            Public Property precipTotal As Double
                            Public Property elev As Integer
                        End Class
                    
                        Public Class Observation
                            Public Property stationID As String
                            Public Property obsTimeUtc As DateTime
                            Public Property obsTimeLocal As String
                            Public Property neighborhood As String
                            Public Property softwareType As String
                            Public Property country As String
                            Public Property solarRadiation As Object
                            Public Property lon As Double
                            Public Property realtimeFrequency As Object
                            Public Property epoch As Integer
                            Public Property lat As Double
                            Public Property uv As Object
                            Public Property winddir As Integer
                            Public Property humidity As Integer
                            Public Property qcStatus As Integer
                            Public Property imperial As Imperial
                        End Class
                    
                        Public Class WUC
                            Public Property observations As Observation()
                        End Class

                    The HDcode is the HomeSeer House and Device code that you assign to the virtual device that you want to use, under the device configuration tab on the "Code:" row. You pick any code you want. You use that same code in the script to put the correct json value in that device.

                    Add:
                    Code:
                    Dim jcData As WUC = json.Deserialize(Of WU)(DataRaw)
                    If you pick HDcode of "t2" for your current temperature device, then add

                    Code:
                    UpdateNlog("t2",0,jcData.observation.imperial.temp,0)
                    This may not be exactly right (I haven't tried it), but it should get you close enough to work it out

                    Comment


                      #11
                      Ok, thanks for that. I think I understand. I will change the script, and I hope my weatherstation will arrive before the weekend, then I can set it up, start broadcasting to WU and then test the script

                      could I for example to retrieve humidity also add

                      Code:
                        
                       UpdateNlog("t222",0,jcData.observation.imperial.humidity,0)
                      and the same way for other values in Public Class Observation ?

                      Comment


                        #12
                        Yes, that should be correct.

                        Comment


                          #13
                          I am getting this error running the script

                          Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'observation' is not a member of 'scriptcode85.VBWrapper.WUC'.
                          Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Type 'JavaScriptSerializer' is not defined.
                          Sep-25 19:12:13 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Web.Script.Serialization' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
                          Sep-25 19:12:13 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

                          Code:
                          Imports System.Web.Script.Serialization
                          
                          Const Fname As String  = "WeatherObserved.vb"          ' this file name
                          Const Lcolor As String = "#ffaa56"                     ' log color for normal
                          
                          Dim json As New JavaScriptSerializer
                          
                          Sub Main(ByVal Parms As Object)
                          
                              Try
                                  Dim DataRaw As String = hs.geturl ("https://api.weather.com","//v2/pws/observations/current?stationId=xxx&format=json&units=e&apiKey =xxx",FALSE ,"80")
                          
                               if left(DataRaw,5) = "ERROR" then
                                  hs.WriteLogDetail(Fname,DataRaw, "#FF0000", 2,Fname & ":Main",1)
                               else
                          
                                  Dim jcData As WUC = json.Deserialize(Of WU)(DataRaw)
                          
                                 UpdateNlog("O112",0,jcData.observation.imperial.temp,0)
                                 UpdateNlog("O113",0,jcData.observation.imperial.heatIndex,0)
                                 UpdateNlog("O114",0,jcData.observation.imperial.dewpt,0)
                                 UpdateNlog("O115",0,jcData.observation.imperial.windChill,0)
                                 UpdateNlog("O116",0,jcData.observation.imperial.windSpeed,0)
                                 UpdateNlog("O117",0,jcData.observation.imperial.windGust,0)
                                 UpdateNlog("O123",0,jcData.observation.imperial.winddir,0)
                                 UpdateNlog("O118",0,jcData.observation.imperial.pressure,0)
                                 UpdateNlog("O119",0,jcData.observation.imperial.precipRate,0)
                                 UpdateNlog("O120",0,jcData.observation.imperial.precipTotal,0)
                                 UpdateNlog("O121",0,jcData.observation.imperial.elev,0)
                                 UpdateNlog("O122",0,jcData.observation.imperial.humidity,0)
                                 UpdateNlog("O124",0,jcData.observation.imperial.uv,0)
                          
                          
                          
                               end if
                          
                          Catch Ex As Exception
                              hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 2,Fname & ":Main",1)
                              End Try
                          
                          End Sub
                          
                          Public Class Imperial
                                  Public Property temp As Integer
                                  Public Property heatIndex As Integer
                                  Public Property dewpt As Integer
                                  Public Property windChill As Integer
                                  Public Property windSpeed As Integer
                                  Public Property windGust As Integer
                                  Public Property pressure As Double
                                  Public Property precipRate As Double
                                  Public Property precipTotal As Double
                                  Public Property elev As Integer
                              End Class
                          
                              Public Class Observation
                                  Public Property stationID As String
                                  Public Property obsTimeUtc As DateTime
                                  Public Property obsTimeLocal As String
                                  Public Property neighborhood As String
                                  Public Property softwareType As String
                                  Public Property country As String
                                  Public Property solarRadiation As Object
                                  Public Property lon As Double
                                  Public Property realtimeFrequency As Object
                                  Public Property epoch As Integer
                                  Public Property lat As Double
                                  Public Property uv As Object
                                  Public Property winddir As Integer
                                  Public Property humidity As Integer
                                  Public Property qcStatus As Integer
                                  Public Property imperial As Imperial
                              End Class
                          
                              Public Class WUC
                                  Public Property observations As Observation()
                              End Class  
                          
                          Sub UpdateNlog (HDcode As String, Dvalue As Double, Dstr as String, Always as Integer) ' this routine updates a device and logs it if
                                                                                                 ' it changed and if logging is turned on for the device or if always is set
                            Try
                              dim Dref    = hs.GetDeviceRef(HDcode)                                   ' get the reference to the device based on the house/device code
                              dim dv      = hs.GetDeviceByRef(Dref)                                   ' get device settings
                              dim Du      = hs.GetDeviceByRef(Dref)                                   ' get device data
                              dim Dstring = hs.DeviceVSP_GetStatus(Dref, Dvalue, 1)                   ' get the string
                          
                              hs.SetDeviceValueByRef (Dref,Dvalue,TRUE)                               ' update the device value
                              if Dstr > "" then
                                 hs.SetDeviceString (Dref,Dstr,true)                                  ' update the device string if provided
                                 Dstring = Dstr                                                       ' for the log
                              end if
                          
                              if (dv.MISC_Check(hs, Enums.dvMISC.NO_LOG) = 0) or (Always = 1) then    ' should it be logged?
                                 hs.WriteLogDetail(Fname,Du.Location(hs) & " " & Du.name(hs) & " set to: " & Dstring, Lcolor, 9,Fname,1)
                              end if
                          
                          
                          Catch Ex As Exception
                                hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 1,Fname & ":UpdateNlog",9)
                          End Try
                          
                          end sub

                          Comment


                            #14
                            Okay. You were really close. Make these changes and you should be good (I only tested for temperature).

                            Code:
                                    Dim DataRaw As String = hs.geturl ("https://api.weather.com","/v2/pws/observations/current?stationId=xxx&format=json&units=e&apiKey=xxx",FALSE ,"80")
                            Code:
                                    Dim jcData As WUC = json.Deserialize(Of WUC)(DataRaw)
                            Code:
                                   UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
                            Repeat the above change for the other 12 update lines, observation changed to observations(0)
                            Also change to remove 0, at the front and add ,"" at the end to put the value in the device value instead of in the device string.

                            (Sorry for steering you wrong...)
                            Let me know if this works or if there are any other problems.

                            Comment


                              #15
                              There is still a problem, but less so now
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'uv' is not a member of 'scriptcode88.VBWrapper.Imperial'.
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'humidity' is not a member of 'scriptcode88.VBWrapper.Imperial'.
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: 'winddir' is not a member of 'scriptcode88.VBWrapper.Imperial'.
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Type 'JavaScriptSerializer' is not defined.
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Web.Script.Serialization' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
                              Sep-25 20:41:22 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\WeatherObserved.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
                              I guess the commands for UV, humidity and winddir could have a different spelling maybe ?

                              Not sure about the other errors

                              Here is the script now

                              Code:
                              Imports System.Web.Script.Serialization
                              
                              Const Fname As String  = "WeatherObserved.vb"          ' this file name
                              Const Lcolor As String = "#ffaa56"                     ' log color for normal
                              
                              Dim json As New JavaScriptSerializer
                              
                              Sub Main(ByVal Parms As Object)
                              
                                  Try
                                      Dim DataRaw As String = hs.geturl ("https://api.weather.com","/v2/pws/observations/current?stationId=xxx&format=json&units=e&apiKey=xxx",FALSE ,"80")
                              
                                   if left(DataRaw,5) = "ERROR" then
                                      hs.WriteLogDetail(Fname,DataRaw, "#FF0000", 2,Fname & ":Main",1)
                                   else
                              
                                      Dim jcData As WUC = json.Deserialize(Of WUC)(DataRaw)
                              
                                     UpdateNlog("O112",jcData.observations(0).imperial.temp,"",0)
                                     UpdateNlog("O113",jcData.observations(0).imperial.heatIndex,"",0)
                                     UpdateNlog("O114",jcData.observations(0).imperial.dewpt,"",0)
                                     UpdateNlog("O115",jcData.observations(0).imperial.windChill,"",0)
                                     UpdateNlog("O116",jcData.observations(0).imperial.windSpeed,"",0)
                                     UpdateNlog("O117",jcData.observations(0).imperial.windGust,"",0)
                                     UpdateNlog("O123",jcData.observations(0).imperial.winddir,"",0)
                                     UpdateNlog("O118",jcData.observations(0).imperial.pressure,"",0)
                                     UpdateNlog("O119",jcData.observations(0).imperial.precipRate,"",0)
                                     UpdateNlog("O120",jcData.observations(0).imperial.precipTotal,"",0)
                                     UpdateNlog("O121",jcData.observations(0).imperial.elev,"",0)
                                     UpdateNlog("O122",jcData.observations(0).imperial.humidity,"",0)
                                     UpdateNlog("O124",jcData.observations(0).imperial.uv,"",0)
                              
                              
                              
                                   end if
                              
                              Catch Ex As Exception
                                  hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 2,Fname & ":Main",1)
                                  End Try
                              
                              End Sub
                              
                              Public Class Imperial
                                      Public Property temp As Integer
                                      Public Property heatIndex As Integer
                                      Public Property dewpt As Integer
                                      Public Property windChill As Integer
                                      Public Property windSpeed As Integer
                                      Public Property windGust As Integer
                                      Public Property pressure As Double
                                      Public Property precipRate As Double
                                      Public Property precipTotal As Double
                                      Public Property elev As Integer
                                  End Class
                              
                                  Public Class Observation
                                      Public Property stationID As String
                                      Public Property obsTimeUtc As DateTime
                                      Public Property obsTimeLocal As String
                                      Public Property neighborhood As String
                                      Public Property softwareType As String
                                      Public Property country As String
                                      Public Property solarRadiation As Object
                                      Public Property lon As Double
                                      Public Property realtimeFrequency As Object
                                      Public Property epoch As Integer
                                      Public Property lat As Double
                                      Public Property uv As Object
                                      Public Property winddir As Integer
                                      Public Property humidity As Integer
                                      Public Property qcStatus As Integer
                                      Public Property imperial As Imperial
                                  End Class
                              
                                  Public Class WUC
                                      Public Property observations As Observation()
                                  End Class   
                              
                              Sub UpdateNlog (HDcode As String, Dvalue As Double, Dstr as String, Always as Integer) ' this routine updates a device and logs it if
                                                                                                     ' it changed and if logging is turned on for the device or if always is set
                                Try
                                  dim Dref    = hs.GetDeviceRef(HDcode)                                   ' get the reference to the device based on the house/device code
                                  dim dv      = hs.GetDeviceByRef(Dref)                                   ' get device settings
                                  dim Du      = hs.GetDeviceByRef(Dref)                                   ' get device data
                                  dim Dstring = hs.DeviceVSP_GetStatus(Dref, Dvalue, 1)                   ' get the string
                              
                                  hs.SetDeviceValueByRef (Dref,Dvalue,TRUE)                               ' update the device value
                                  if Dstr > "" then
                                     hs.SetDeviceString (Dref,Dstr,true)                                  ' update the device string if provided
                                     Dstring = Dstr                                                       ' for the log
                                  end if
                              
                                  if (dv.MISC_Check(hs, Enums.dvMISC.NO_LOG) = 0) or (Always = 1) then    ' should it be logged?
                                     hs.WriteLogDetail(Fname,Du.Location(hs) & " " & Du.name(hs) & " set to: " & Dstring, Lcolor, 9,Fname,1)
                                  end if
                              
                              
                              Catch Ex As Exception
                                    hs.WriteLogDetail(Fname,Ex.Message, "#FF0000", 1,Fname & ":UpdateNlog",9)
                              End Try
                              
                              end sub

                              Comment

                              Working...
                              X