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
Comment