Announcement

Collapse
No announcement yet.

Dark Sky API

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

  • #16
    @teladog01

    I'm getting errors in the log (below). I added both System.Web.Script.Serialization and System.Web.Extensions.dll to ScriptingReferences (settings.ini) but that didnt help

    Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\DarkSky.vb: Type 'JavaScriptSerializer' is not defined.

    Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\DarkSky.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.

    Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\DarkSky.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.
    btw, one small suggestion

    using Device Addresses is somewhat legacy, I suggest using 'Reference ID', it allows for defining all of these at the beginning of the script: easier to use/change, makes it self documenting, and visually easier to understand. Just my 2 cents
    Last edited by Ltek; November 23rd, 2017, 11:06 AM.

    Comment


    • #17
      No one can help?

      Comment


      • #18
        Originally posted by Ltek View Post
        No one can help?
        I use this in my script but I only import System.Web.Dll and System.Web.Extensions.dll, the serialiser is in System.Web.Extensions.dll - I'd suggest trying that and see how you get on.
        My Plugins:

        Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
        Yeelight 3P | Nanoleaf 3P

        Comment


        • #19
          Originally posted by Ltek View Post
          @teladog01

          I'm getting errors in the log (below). I added both System.Web.Script.Serialization and System.Web.Extensions.dll to ScriptingReferences (settings.ini) but that didnt help
          Hi there. Sorry to hear you're getting errors running the script. I remember when I first started working on it that I got some similar errors. I don't remember specifics since it's been quite a while ago, but I know that I resolved it by adding the dependencies to the settings.ini as you noted. FWIW, here is my settings.ini entry:

          Code:
          ScriptingReferences=System.Web.Script.Serialization;System.Web.Extensions.dll
          If that doesn't work on your system, I'm not sure what to say. I'm running HS3 on Windows Server 2012 R2. Are you on Windows or Linux?

          Comment


          • #20
            I know this is an old thread, but adding on to above here is my script. Still a work in progress.

            Imports System.Web.Script.Serialization

            Public Sub Main(ByVal Parms As String)

            Dim secret_key As String = "YOURAPIHERE"
            Dim json As New JavaScriptSerializer
            Dim LT As String = "DarkSky Script"
            Dim LatLong As String = "45.8255421,-90.2921317"'getJSON('https://api.darksky.net/forecast/[key]/[latitude],[longitude]', function(forecast) {});


            'LatLong = Convert.ToDecimal(hs.GetINISetting("Settings", "gLatitude", "41.8255421")) & "," & Convert.ToDecimal(hs.GetINISetting("Settings", "gLongitude", "-88.2921317") * -1)
            Dim DataRaw As String
            DataRaw = hs.GetURL("https://api.darksky.net/", "forecast/" & secret_key & "/" & LatLong, True, 80
            Dim dsData As rdata = json.Deserialize(Of rdata)(DataRaw)
            Dim weathertime = dsData.currently.time
            Dim icon = dsData.minutely.Icon
            Dim minutedata = dsData.minutely.data(5).time


            'todays forcast
            hs.SetDeviceString(1432, dsData.daily.data(0).summary, True)

            'tomorrow's forecast
            hs.SetDeviceString(1433, dsData.daily.data(1).summary, True)

            'todays precipitation probability
            hs.SetDeviceValueByRef(1423, dsData.daily.data(0).precipProbability * 100, True)
            hs.SetDeviceString(1423, dsData.daily.data(0).precipProbability * 100 & "% chance", True)

            'tomorrow's precipitation probability
            hs.SetDeviceValueByRef(1428, dsData.daily.data(1).precipProbability * 100, True)
            hs.SetDeviceString(1428, dsData.daily.data(1).precipProbability * 100 & "% chance", True)

            'temperature
            hs.SetDeviceValueByRef(1412, dsData.hourly.data(0).temperature, True)
            hs.SetDeviceString(1412, dsData.hourly.data(0).temperature & " �F", True)

            'apparent temperature
            hs.SetDeviceValueByRef(405, dsData.hourly.data(0).apparentTemperature, True)
            hs.SetDeviceString(405, dsData.hourly.data(0).apparentTemperature & " �F", True)

            'today's temperature high
            hs.SetDeviceValueByRef(1426, dsData.daily.data(0).temperatureHigh, True)
            hs.SetDeviceString(1426, dsData.daily.data(0).temperatureHigh & " �F", True)

            'today's temperature low
            hs.SetDeviceValueByRef(1427, dsData.daily.data(0).temperatureLow, True)
            hs.SetDeviceString(1427, dsData.daily.data(0).temperatureLow & " �F", True)

            'today's precipitation amount
            'hs.SetDeviceValueByRef(1427, dsData.daily.data(0).temperatureLow, True)
            'hs.SetDeviceString(1427, dsData.daily.data(0).temperatureLow & " �F", True)

            'tomorrow's high
            hs.SetDeviceValueByRef(1429, dsData.daily.data(1).temperatureHigh, True)
            hs.SetDeviceString(1429, dsData.daily.data(1).temperatureHigh & " �F", True)

            'tomorrow's low
            hs.SetDeviceValueByRef(1430, dsData.daily.data(1).temperatureLow, True)
            hs.SetDeviceString(1430, dsData.daily.data(1).temperatureLow & " �F", True)


            End Sub



            Public Class rdata
            Public Property latitude As Double
            Public Property longitude As Double

            Public Property currently As currentdata
            Public Property minutely As minutedata
            Public Property hourly As hourlydata
            Public Property daily As dailydata
            Public Property alerts As Alert()
            End Class

            Public Class currentdata
            Public Property time As String
            Public Property summary As String
            Public Property icon As String
            Public Property nearestStormDistance As Double
            Public Property nearestStormBearing As Double
            Public Property precipIntensity As Double
            Public Property precipProbability As Double
            Public Property temperature As Decimal
            Public Property apparentTemperature As Decimal
            Public Property dewPoint As Decimal
            Public Property humidity As Decimal
            Public Property windSpeed As Decimal
            Public Property windBearing As Decimal
            Public Property visibility As Decimal
            Public Property cloudCover As Decimal
            Public Property pressure As Decimal
            Public Property ozone As Decimal
            End Class
            Public Class minutedata

            Public Property Summary As String
            Public Property Icon As String
            Public Property data As Dataminute()
            End Class
            Public Class Dataminute
            Public Property time As Double
            Public Property precipIntensity As Double
            Public Property precipProbability As Double
            End Class
            Public Class hourlydata


            Public Property Summary As String
            Public Property Icon As String
            Public Property data As Datahour()
            '
            End Class
            Public Class Datahour
            Public Property time As Double
            Public Property summary As String
            Public Property icon As String
            Public Property precipIntensity As Double
            Public Property precipProbability As Double
            Public Property precipType As String
            Public Property temperature As Double
            Public Property apparentTemperature As Double
            Public Property dewPoint As Double
            Public Property humidity As Double
            Public Property pressure As Double
            Public Property windSpeed As Double
            Public Property windGust As Double
            Public Property windBearing As Double
            Public Property cloudCover As Double
            Public Property uvIndex As Double
            Public Property visibility As Double
            Public Property ozone As Double


            End Class
            Public Class dailydata


            Public Property Summary As String
            Public Property Icon As String
            Public Property data As datadaily()
            '
            End Class
            Public Class datadaily
            Public Property time As Double
            Public Property summary As String
            Public Property icon As String
            Public Property sunriseTime As Double
            Public Property sunsetTime As Double
            Public Property moonPhase As Double
            Public Property precipIntensity As Double
            Public Property precipIntensityMax As Double
            Public Property precipIntensityMaxTime As Integer
            Public Property precipProbability As Double
            Public Property precipType As String
            Public Property temperatureHigh As Double
            Public Property temperatureHighTime As Integer
            Public Property temperatureLow As Double
            Public Property temperatureLowTime As Integer
            Public Property apparentTemperatureHigh As Double
            Public Property apparentTemperatureHighTime As Integer
            Public Property apparentTemperatureLow As Double
            Public Property apparentTemperatureLowTime As Integer
            Public Property dewPoint As Double
            Public Property humidity As Double
            Public Property pressure As Double
            Public Property windSpeed As Double
            Public Property windGust As Double
            Public Property windGustTime As Integer
            Public Property windBearing As Integer
            Public Property cloudCover As Double
            Public Property uvIndex As Integer
            Public Property uvIndexTime As Integer
            Public Property visibility As Double
            Public Property ozone As Double
            Public Property temperatureMin As Double
            Public Property temperatureMinTime As Integer
            Public Property temperatureMax As Double
            Public Property temperatureMaxTime As Integer
            Public Property apparentTemperatureMin As Double
            Public Property apparentTemperatureMinTime As Integer
            Public Property apparentTemperatureMax As Double
            Public Property apparentTemperatureMaxTime As Integer


            End Class
            Public Class Alert
            Public Property title As String
            Public Property regions As String()
            Public Property severity As String
            Public Property time As Double
            Public Property expires As Double
            Public Property description As String
            Public Property uri As String
            End Class
            Public Class Flags
            Public Property sources As String()
            'Public Property Nearest-station As Double
            Public Property units As String
            End Class



            Comment

            Working...
            X