Announcement

Collapse
No announcement yet.

Getting the system.core error with script

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

  • CharlieScott
    replied
    Thanks for all the info guys. I had been looking for a decent Darksky replacement for some time now. ClimaCell and Aeris were on my list. Will apply this info to check out Climacell first.

    Leave a comment:


  • jayman13
    replied
    Originally posted by zwolfpack View Post

    Cool, looks interesting. I've been checking out OpenWeatherMap, visualcrossing.com, weatherbit.io. I'll take a look at this one as well!
    I used this one mainly as it included precipitation probability, seems like a lot don’t.

    Leave a comment:


  • jayman13
    replied
    Originally posted by tenholde View Post

    Might have to do with what version of the. Net framework HS is targeting. HS provides very little support to the scripting environment as they feel everything can now be done with events.

    I'm close to having CSharp support in tenScripting and am looking for testers
    Great! I’d be happy to test

    Leave a comment:


  • zwolfpack
    replied
    Originally posted by jayman13 View Post

    ... which will replace now Apple's DarkSky api.
    Cool, looks interesting. I've been checking out OpenWeatherMap, visualcrossing.com, weatherbit.io. I'll take a look at this one as well!

    Leave a comment:


  • tenholde
    replied
    Originally posted by jayman13 View Post

    Yeah, weird. It works with tenScripting using string interpolation with the $ in visual studio. I had migrated this script from C# to vb.net. I guess homeseer doesn't allow string interpolation but tenScripting does?
    Might have to do with what version of the. Net framework HS is targeting. HS provides very little support to the scripting environment as they feel everything can now be done with events.

    I'm close to having CSharp support in tenScripting and am looking for testers

    Leave a comment:


  • jayman13
    replied
    Originally posted by tenholde View Post
    If you were testing using tenScripting, I'm surprised the $ errors weren't caught. Also, the Class and Class End statements should have been stripped out of your script if you used the tenScripting Export function. Let me know if there is an apparent tenScripting problem.
    Yeah, weird. It works with tenScripting using string interpolation with the $ in visual studio. I had migrated this script from C# to vb.net. I guess homeseer doesn't allow string interpolation but tenScripting does?

    Leave a comment:


  • jayman13
    replied
    Originally posted by zwolfpack View Post
    It looks like the errors I was seeing "Reference to a non-shared member requires an object reference." can be eliminated by removing the line near the start

    Code:
    Public Class ClimaCellConnect
    and it's associated 'End Class'.

    Those errors weren't due to the JSON dereferencing after all, rather the class declaration was isolating the definition of the 'hs' object so it wasn't available inside the declared class.

    With those two lines and the "$" characters removed I get a clean compile.
    Thanks for looking at it, got it up and working now which will replace now Apple's DarkSky api.

    Leave a comment:


  • tenholde
    replied
    If you were testing using tenScripting, I'm surprised the $ errors weren't caught. Also, the Class and Class End statements should have been stripped out of your script if you used the tenScripting Export function. Let me know if there is an apparent tenScripting problem.

    Leave a comment:


  • zwolfpack
    replied
    It looks like the errors I was seeing "Reference to a non-shared member requires an object reference." can be eliminated by removing the line near the start

    Code:
    Public Class ClimaCellConnect
    and it's associated 'End Class'.

    Those errors weren't due to the JSON dereferencing after all, rather the class declaration was isolating the definition of the 'hs' object so it wasn't available inside the declared class.

    With those two lines and the "$" characters removed I get a clean compile.

    Leave a comment:


  • jayman13
    replied
    Thanks, don’t know how I missed the $ symbol. On your second point, how should I be referencing the json? Are you saying I should make it a variable first?

    Leave a comment:


  • zwolfpack
    replied
    Your actual error is "Character is not valid.", due to the "$" characters on this line and four subsequent instances.

    Code:
    hs.SetDeviceString(1423, $"{weatherData(0).precipitation_probability.value.ToStrin g() }% chance", True)
    Once these are corrected you may get a bunch of "Reference to a non-shared member requires an object reference." errors, apparently due to the way you're trying to dereference the JSON, starting at the line

    Code:
    hs.SetDeviceValueByRef(1426, weatherData(0).temp(1).max.value, True)
    The 'System.Core' message (its actually a warning, not an error), is a bogus message generated on every script compilation. Since it's only a warning, it's only displayed when there are subsequent compilation errors. The wrapper that HST uses includes the line 'Imports System.Core' which apparently is invalid in the context that the compiler is called.

    Leave a comment:


  • jayman13
    started a topic Getting the system.core error with script

    Getting the system.core error with script

    Compiling script C:\PROGRAM FILES (X86)\HOMESEER HS3\scripts\ClimaCellConnect.vb: Character is not valid.
    Jun-20 4:55:19 PM Error Compiling script C:\PROGRAM FILES (X86)\HOMESEER HS3\scripts\ClimaCellConnect.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've posted the script below. It works fine in visual studio using tenholder's program. I've had other scripts work fine with system.net namespace. Is it the system.collections.generic namespace? Any insight would be appreciated.



    Imports System.Web.Script.Serialization
    Imports System.Net
    Imports System.Collections.Generic

    Public Class ClimaCellConnect

    Public Sub Main(ByVal Parms As String)

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
    Dim json As New JavaScriptSerializer
    Dim climaUrlPage = "lat=41.8255421&lon=-88.2921317&unit_system=us&end_time=" +
    "&fields%5B%5D=temp&fields%5B%5D=feels_like&fields%5B%5D =pre cipitation_probability&fields%5B%5D=precipitation_accumulati on&fields%5B%5D=sunrise&fields%5B%5D=sunset" +
    "&fields%5B%5D=weather_code&apikey="
    'Dim lat = "lat=41.8255421&" '21
    'Dim longitude = "lon=--88.2921317" '17
    Dim climaUrl = "https://api.climacell.co/v3/weather/forecast/daily?"
    Dim secret_key = "SwVvgMAjaNA******************"
    Dim request As HttpWebRequest = CType(HttpWebRequest.Create(climaUrl + climaUrlPage + secret_key), HttpWebRequest)
    request.Proxy = Nothing
    request.UserAgent = "Test"
    request.ContentType = "application/json"

    Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)
    Dim response_stream As System.IO.Stream = response.GetResponseStream

    Dim stream_reader As New System.IO.StreamReader(response_stream)
    Dim Data As String = stream_reader.ReadToEnd
    stream_reader.Close()

    'Dim dsData As List(Of WeatherInfo)
    Dim weatherInfo = json.Deserialize(Of List(Of WeatherInfo))(Data)
    'Dim weatherInfo = JsonConvert.DeserializeObject(Of List(Of WeatherInfo))(Data)
    'JsonConvert.DeserializeObject<List<WeatherInfo>>(stringJson )
    SetHomeseerDevices(weatherInfo)


    End Sub

    Public Sub SetHomeseerDevices(ByVal weatherData As List(Of WeatherInfo))

    hs.SetDeviceValueByRef(1426, weatherData(0).temp(1).max.value, True)
    hs.SetDeviceString(1426, weatherData(0).temp(1).max.value.ToString(), True)

    hs.SetDeviceValueByRef(1429, weatherData(1).temp(1).max.value, True)
    hs.SetDeviceString(1429, weatherData(1).temp(1).max.value.ToString(), True)

    hs.SetDeviceValueByRef(1427, weatherData(0).temp(0).min.value, True)
    hs.SetDeviceString(1427, weatherData(0).temp(0).min.value.ToString(), True)

    hs.SetDeviceValueByRef(1430, weatherData(1).temp(0).min.value, True)
    hs.SetDeviceString(1430, weatherData(1).temp(0).min.value.ToString(), True)

    hs.SetDeviceValueByRef(1423, weatherData(0).precipitation_probability.value, True)
    hs.SetDeviceString(1423, $"{weatherData(0).precipitation_probability.value.ToStrin g() }% chance", True)

    hs.SetDeviceValueByRef(1428, weatherData(1).precipitation_probability.value, True)
    hs.SetDeviceString(1428, $"{weatherData(1).precipitation_probability.value.ToStrin g() }% chance", True)


    hs.SetDeviceValueByRef(1425, weatherData(0).precipitation_accumulation.value, True)
    hs.SetDeviceString(1425, $"{weatherData(0).precipitation_accumulation.value.ToStri ng( )} inches", True)

    hs.SetDeviceString(1432, $"{weatherData(0).weather_code.value}", True)
    hs.SetDeviceString(1433, $"{weatherData(1).weather_code.value}", True)

    End Sub

    End Class

    Public Class Min

    Public Property value As Double

    Public Property units As String
    End Class

    Public Class Max

    Public Property value As Double

    Public Property units As String
    End Class

    Public Class Temp

    Public Property observation_time As DateTime

    Public Property min As Min

    Public Property max As Max
    End Class

    Public Class PrecipitationAccumulation

    Public Property value As Double

    Public Property units As String
    End Class

    Public Class PrecipitationProbability

    Public Property value As Integer

    Public Property units As String
    End Class

    Public Class FeelsLike

    Public Property observation_time As DateTime

    Public Property min As Dictionary(Of Object, Object)

    Public Property max As Dictionary(Of Object, Object)
    End Class

    Public Class Sunrise

    Public Property value As DateTime
    End Class

    Public Class Sunset

    Public Property value As DateTime
    End Class

    Public Class WeatherCode

    Public Property value As String
    End Class

    Public Class ObservationTime

    Public Property value As DateTime
    End Class

    Public Class WeatherInfo

    Public Property temp As List(Of Temp)

    Public Property precipitation_accumulation As PrecipitationAccumulation

    Public Property precipitation_probability As PrecipitationProbability

    Public Property feels_like As List(Of FeelsLike)

    Public Property sunrise As Sunrise

    Public Property sunset As Sunset

    Public Property weather_code As WeatherCode

    Public Property observation_time As ObservationTime

    Public Property lat As Double

    Public Property lon As Double

    End Class


Working...
X