Jump to content

SCRIPT: EnTur.vb - Få inn data fra EnTur


Recommended Posts

Ah, pokker. Glemte entries, rart debuggeren ikke tok det...

 

Sub Main(parm As Object)
    Dim stop1 As String = "NSR:StopPlace:59854"
    Dim stop2 As String = "NSR:StopPlace:27753"
    Dim entries as Integer = 5

    Dim jsonQuery As String = "{trip(from:{place: """ & stop1 & """} to: {place: """ & stop2 & """} modes: [bus] numTripPatterns: " & entries & ") { tripPatterns { startTime endTime duration walkDistance legs {mode distance line {id publicCode name } }}}}"
    Dim result As String = RunQuery(jsonQuery)
    hs.WriteLog("EnTur", result)
 End Sub

 

Link to post
Share on other sites
  • Replies 131
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Dette scriptet lar deg hente inn trafikkinformasjon fra EnTur.     Finne reiseruter, IDer for "StopPlace" og "Quay" Å bruke scriptet er ikke så vanskelig. Det vanskelige er å finne IDen

Se der ja, det løste æøå problemet.

OK, jeg fant bug'en.   ... og selvfølgelig er det slik at når jeg har funnet den så burde jeg ha tenkt på den med en gang.   Det mangler en linje i RunQuery-funksjonen. Den skal altså s

Posted Images

1 minutt siden, Moskus skrev:

Ah, pokker. Glemte entries, rart debuggeren ikke tok det...

 


Sub Main(parm As Object)
    Dim stop1 As String = "NSR:StopPlace:59854"
    Dim stop2 As String = "NSR:StopPlace:27753"
    Dim entries as Integer = 5

    Dim jsonQuery As String = "{trip(from:{place: """ & stop1 & """} to: {place: """ & stop2 & """} modes: [bus] numTripPatterns: " & entries & ") { tripPatterns { startTime endTime duration walkDistance legs {mode distance line {id publicCode name } }}}}"
    Dim result As String = RunQuery(jsonQuery)
    hs.WriteLog("EnTur", result)
 End Sub

 

får denne i loggen nå:

  Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnTur.vb :Målet forårsaket et unntak under aktivering.->Does entry point Main exist in script? ved System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) ved System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) ved System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ved Scheduler.clsRunVBNetScript.ExecuteScript()
jan-14 10.11.05   Event Running script and waiting: C:/Program Files (x86)/HomeSeer HS3/scripts/EnTur.vb("Main","345,NSR:StopPlace:57094,NSR:Quay:97801,5")
jan-14 10.11.05   Event Event Trigger "Ute Busstider"
jan-14 10.11.05   Event Event Ute Busstider triggered by the event page 'Run' button.
Link to post
Share on other sites

Når jeg bytter ut CallsFromStopplace med Main og parametere som blankt, får jeg:
Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnTur_test6.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Scheduler.clsRunVBNetScript.ExecuteScript()

 

Har forsøkt å fjerne referansen til Newtonsoft.JSon.dll i scripting-references, og da klager loggen på
Namespace or type specified in the Imports 'Newtonsoft.Json.Linq' doesn't contain any public member or cannot be found.

 

Forsøkte å endre tusenskille og kommategn, men eneste jeg oppnådde med det var å tulle til energy databasen.

 

Link to post
Share on other sites
7 minutes ago, Moskus said:

Ah, pokker. Glemte entries, rart debuggeren ikke tok det...

 


Sub Main(parm As Object)
    Dim stop1 As String = "NSR:StopPlace:59854"
    Dim stop2 As String = "NSR:StopPlace:27753"
    Dim entries as Integer = 5

    Dim jsonQuery As String = "{trip(from:{place: """ & stop1 & """} to: {place: """ & stop2 & """} modes: [bus] numTripPatterns: " & entries & ") { tripPatterns { startTime endTime duration walkDistance legs {mode distance line {id publicCode name } }}}}"
    Dim result As String = RunQuery(jsonQuery)
    hs.WriteLog("EnTur", result)
 End Sub

 

Får samme som Roger:

Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnTur_test7.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Scheduler.clsRunVBNetScript.ExecuteScript()

Link to post
Share on other sites
Akkurat nå, Kensko skrev:

Mange varianter av Newtonsoft.Json.dll i HomeSeer plugins mappene. Kan det være at vi har en feil versjon? 

Nei, det spiller ingen rolle. Pluginene definerer selv hvilken versjon de skal bruke og hvor den ligger.

Link to post
Share on other sites

OK, jeg fant bug'en. :) 

... og selvfølgelig er det slik at når jeg har funnet den så burde jeg ha tenkt på den med en gang.

 

Det mangler en linje i RunQuery-funksjonen. Den skal altså se slik ut:

 

Private Function RunQuery(ByVal jsonQuery As String) As String
    Dim url As String = "https://api.entur.io/journey-planner/v2/graphql"

    Using client As New System.Net.WebClient
        Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
        client.Headers.Add("ET-Client-Name", "Moskus-InfoplakatForHomeseer")
        client.Headers.Add("User-Agent", "EnTur-script by Moskus")
        client.Headers.Add("Content-Type", "application/graphql")
        client.Encoding = System.Text.Encoding.UTF8
        client.BaseAddress = url

        Return client.UploadString(url, "POST", jsonQuery)
    End Using
End Function

... som tvinger WebClient til å bruke TLS12.

 

Hele scriptet skal altså være slik:

 

Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.Collections.Generic

'Moskus 2019
'Besøk https://en-tur.no for å finne stop-ider og quay-ider

Sub CallsFromStopplace(parm As Object)
    Dim input() As String = parm.ToString.Split(",")
    Dim deviceRef As Integer = input(0).Trim
    Dim stop1 As String = input(1).Trim
    Dim quay As String = ""
    Dim entries As Integer = 5
    If input.GetLength(0) > 2 Then quay = input(2).Trim
    If input.GetLength(0) = 4 Then entries = input(3).Trim

    Dim list As List(Of EstimatedCall) = GetCallsFromStopPlace(stop1, quay, entries)
    Dim out As String = ""

    For Each c As EstimatedCall In list
        out &= c.ToString & "<br>"
    Next
    Dim minutesToNextDeparture As Integer = list(0).expectedArrivalTime.Subtract(Now).TotalMinutes

    hs.SetDeviceString(deviceRef, out, False)
    hs.SetDeviceValueByRef(deviceRef, minutesToNextDeparture, True)


End Sub

Sub TripsBetweenStops(parm As Object)
    Dim input() As String = parm.ToString.Split(",")
    Dim deviceRef As Integer = input(0).Trim
    Dim stop1 As String = input(1).Trim
    Dim stop2 As String = input(2).Trim
    Dim entries As Integer = 5
    If input.GetLength(0) = 4 Then entries = input(3).Trim


    Dim list As List(Of Trippattern) = GetTripBetweenStops(stop1, stop2, entries)
    Dim out As String = ""

    For Each c As Trippattern In list
        out &= c.ToString & "<br>"
    Next
    Dim minutesToNextDeparture As Integer = list(0).startTime.Subtract(Now).TotalMinutes

    hs.SetDeviceString(deviceRef, out, False)
    hs.SetDeviceValueByRef(deviceRef, minutesToNextDeparture, True)

End Sub

Private Function RunQuery(ByVal jsonQuery As String) As String
    Dim url As String = "https://api.entur.io/journey-planner/v2/graphql"

    Using client As New System.Net.WebClient
        Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
        client.Headers.Add("ET-Client-Name", "Moskus-InfoplakatForHomeseer")
        client.Headers.Add("User-Agent", "EnTur-script by Moskus")
        client.Headers.Add("Content-Type", "application/graphql")
        client.Encoding = System.Text.Encoding.UTF8
        client.BaseAddress = url

        Return client.UploadString(url, "POST", jsonQuery)
    End Using
End Function

Private Function GetCallsFromStopPlace(ByVal _stop As String, Optional ByVal _quay As String = "", Optional ByVal entries As Integer = 5) As List(Of EstimatedCall)
    Dim jsonQuery As String = "{stopPlace(id: """ & _stop & """) {id name estimatedCalls(startTime: """ & Now.ToString("yyyy-MM-ddTHH:mm:sszzz") & """, timeRange: 72100, numberOfDepartures: " & (entries * 2 + 2) & "){ realtime aimedArrivalTime expectedArrivalTime destinationDisplay {frontText} quay {id} serviceJourney {journeyPattern {line {id name transportMode}}}}}}"

    Dim result As String = RunQuery(jsonQuery)
    Dim enTurJson As EnTur = Newtonsoft.Json.JsonConvert.DeserializeObject(Of EnTur)(result)

    Dim lst As New List(Of EstimatedCall)
    Dim count As Integer = 0
    For Each e As EstimatedCall In enTurJson.data.stopPlace.estimatedCalls
        If _quay <> "" Then
            If e.quay.id = _quay Then
                lst.Add(e)
                count += 1
            End If
        Else
            lst.Add(e)
            count += 1
        End If
        If count = entries Then Exit For
    Next
    Return lst
End Function

Private Function GetTripBetweenStops(ByVal stop1 As String, ByVal stop2 As String, Optional ByVal entries As Integer = 5) As List(Of Trippattern)
    Dim jsonQuery As String = "{trip(from:{place: """ & stop1 & """} to: {place: """ & stop2 & """} modes: [bus] numTripPatterns: " & entries & ") { tripPatterns { startTime endTime duration walkDistance legs {mode distance line {id publicCode name } }}}}"

    Dim result As String = RunQuery(jsonQuery)
    Dim enTurJson As EnTur = JsonConvert.DeserializeObject(Of EnTur)(result)

    Return enTurJson.data.trip.tripPatterns
End Function

Sub Main(parm As Object)

End Sub

Public Class EnTur
    Private _data As Data
    Public Property data() As Data
        Get
            Return _data
        End Get
        Set(ByVal value As Data)
            _data = value
        End Set
    End Property
End Class

Public Class Data
    Private _stopPlace As Stopplace
    Public Property stopPlace() As Stopplace
        Get
            Return _stopPlace
        End Get
        Set(ByVal value As Stopplace)
            _stopPlace = value
        End Set
    End Property
    Private _trip As Trip
    Public Property trip() As Trip
        Get
            Return _trip
        End Get
        Set(ByVal value As Trip)
            _trip = value
        End Set
    End Property

End Class

Public Class Stopplace
    Private _id As String
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal value As String)
            _id = value
        End Set
    End Property
    Private _name As String
    Public Property name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
    Private _estimatedCalls As List(Of EstimatedCall)
    Public Property estimatedCalls() As List(Of EstimatedCall)
        Get
            Return _estimatedCalls
        End Get
        Set(ByVal value As List(Of EstimatedCall))
            _estimatedCalls = value
        End Set
    End Property
End Class

Public Class EstimatedCall
    Private _realtime As Boolean
    Public Property realtime() As Boolean
        Get
            Return _realtime
        End Get
        Set(ByVal value As Boolean)
            _realtime = value
        End Set
    End Property
    Private _aimedArrivalTime As Date
    Public Property aimedArrivalTime() As Date
        Get
            Return _aimedArrivalTime
        End Get
        Set(ByVal value As Date)
            _aimedArrivalTime = value
        End Set
    End Property
    Private _aimedDepartureTime As Date
    Public Property aimedDepartureTime() As Date
        Get
            Return _aimedDepartureTime
        End Get
        Set(ByVal value As Date)
            _aimedDepartureTime = value
        End Set
    End Property
    Private _expectedArrivalTime As Date
    Public Property expectedArrivalTime() As Date
        Get
            Return _expectedArrivalTime
        End Get
        Set(ByVal value As Date)
            _expectedArrivalTime = value
        End Set
    End Property
    Private _expectedDepartureTime As Date
    Public Property expectedDepartureTime() As Date
        Get
            Return _expectedDepartureTime
        End Get
        Set(ByVal value As Date)
            _expectedDepartureTime = value
        End Set
    End Property
    Private _actualArrivalTime As Object
    Public Property actualArrivalTime() As Object
        Get
            Return _actualArrivalTime
        End Get
        Set(ByVal value As Object)
            _actualArrivalTime = value
        End Set
    End Property
    Private _actualDepartureTime As Object
    Public Property actualDepartureTime() As Object
        Get
            Return _actualDepartureTime
        End Get
        Set(ByVal value As Object)
            _actualDepartureTime = value
        End Set
    End Property
    Private __date As String
    Public Property _date() As String
        Get
            Return __date
        End Get
        Set(ByVal value As String)
            __date = value
        End Set
    End Property
    Private _forBoarding As Boolean
    Public Property forBoarding() As Boolean
        Get
            Return _forBoarding
        End Get
        Set(ByVal value As Boolean)
            _forBoarding = value
        End Set
    End Property
    Private _forAlighting As Boolean
    Public Property forAlighting() As Boolean
        Get
            Return _forAlighting
        End Get
        Set(ByVal value As Boolean)
            _forAlighting = value
        End Set
    End Property
    Private _destinationDisplay As Destinationdisplay
    Public Property destinationDisplay() As Destinationdisplay
        Get
            Return _destinationDisplay
        End Get
        Set(ByVal value As Destinationdisplay)
            _destinationDisplay = value
        End Set
    End Property
    Private _quay As Quay
    Public Property quay() As Quay
        Get
            Return _quay
        End Get
        Set(ByVal value As Quay)
            _quay = value
        End Set
    End Property
    Private _serviceJourney As Servicejourney
    Public Property serviceJourney() As Servicejourney
        Get
            Return _serviceJourney
        End Get
        Set(ByVal value As Servicejourney)
            _serviceJourney = value
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return Me.expectedArrivalTime.ToString("HH:mm") & " (" & Me.aimedArrivalTime.ToString("HH:mm") & ")" & ": " & Me.serviceJourney.journeyPattern.line.name & " " & Me.destinationDisplay.frontText
    End Function

    Public Shared Sub ToFile(ByVal calls As List(Of EstimatedCall), ByVal filename As String)
        If calls.Count = 0 Then Exit Sub

        Dim sb As New Text.StringBuilder
        'FEILER
        'calls.ForEach(Sub(x) sb.AppendLine(x.ToString))
        My.Computer.FileSystem.WriteAllText(Environment.CurrentDirectory & "\" & filename, sb.ToString, False)
    End Sub
End Class

Public Class Destinationdisplay
    Private _frontText As String
    Public Property frontText() As String
        Get
            Return _frontText
        End Get
        Set(ByVal value As String)
            _frontText = value
        End Set
    End Property
End Class

Public Class Quay
    Private _id As String
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal value As String)
            _id = value
        End Set
    End Property
    Private _name As String
    Public Property name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
End Class

Public Class Servicejourney
    Private _journeyPattern As Journeypattern
    Public Property journeyPattern() As Journeypattern
        Get
            Return _journeyPattern
        End Get
        Set(ByVal value As Journeypattern)
            _journeyPattern = value
        End Set
    End Property
End Class

Public Class Journeypattern
    Private _line As Line
    Public Property line() As Line
        Get
            Return _line
        End Get
        Set(ByVal value As Line)
            _line = value
        End Set
    End Property
End Class

Public Class Line
    Private _id As String
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal value As String)
            _id = value
        End Set
    End Property
    Private _name As String
    Public Property name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
    Private _transportMode As String
    Public Property transportMode() As String
        Get
            Return _transportMode
        End Get
        Set(ByVal value As String)
            _transportMode = value
        End Set
    End Property
    Private _publicCode As String
    Public Property publicCode() As String
        Get
            Return _publicCode
        End Get
        Set(ByVal value As String)
            _publicCode = value
        End Set
    End Property
End Class


Public Class Trip
    Private _tripPatterns As List(Of Trippattern)
    Public Property tripPatterns() As List(Of Trippattern)
        Get
            Return _tripPatterns
        End Get
        Set(ByVal value As List(Of Trippattern))
            _tripPatterns = value
        End Set
    End Property
End Class

Public Class Trippattern
    Private _startTime As Date
    Public Property startTime() As Date
        Get
            Return _startTime
        End Get
        Set(ByVal value As Date)
            _startTime = value
        End Set
    End Property
    Private _endTime As Date
    Public Property endTime() As Date
        Get
            Return _endTime
        End Get
        Set(ByVal value As Date)
            _endTime = value
        End Set
    End Property
    Private _duration As Integer
    Public Property duration() As Integer
        Get
            Return _duration
        End Get
        Set(ByVal value As Integer)
            _duration = value
        End Set
    End Property
    Private _walkDistance As Double
    Public Property walkDistance() As Double
        Get
            Return _walkDistance
        End Get
        Set(ByVal value As Double)
            _walkDistance = value
        End Set
    End Property
    Private _legs As List(Of Leg)
    Public Property legs() As List(Of Leg)
        Get
            Return _legs
        End Get
        Set(ByVal value As List(Of Leg))
            _legs = value
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return Me.startTime.ToString("HH:mm") & " → " & Me.endTime.ToString("HH:mm") & ":  Rute " & Me.legs(0).line.name
    End Function

    Public Shared Sub ToFile(ByVal calls As List(Of Trippattern), ByVal filename As String)
        If calls.Count = 0 Then Exit Sub

        Dim sb As New Text.StringBuilder
        'FEILER
        ' calls.ForEach(Sub(x) sb.AppendLine(x.ToString))
        My.Computer.FileSystem.WriteAllText(Environment.CurrentDirectory & "\" & filename, sb.ToString, False)
    End Sub
End Class

Public Class Leg
    Private _mode As String
    Public Property mode() As String
        Get
            Return _mode
        End Get
        Set(ByVal value As String)
            _mode = value
        End Set
    End Property
    Private _distance As Single
    Public Property distance() As Single
        Get
            Return _distance
        End Get
        Set(ByVal value As Single)
            _distance = value
        End Set
    End Property
    Private _line As Line
    Public Property line() As Line
        Get
            Return _line
        End Get
        Set(ByVal value As Line)
            _line = value
        End Set
    End Property
End Class

 

... eller bruk denne:

EnTur.vb

  • Thanks 2
Link to post
Share on other sites
13 minutter siden, Kensko skrev:

Betyr det at min HomeSeer server fortsatt bruker TLS 1.0/1.1? Eller er det webleseren som du HomeSeer via som gjør dette?

Det betyr ikke mer enn at WebClient defaulter til TSL 1.0/1.1, men den kan tvinges til å bruke 1.2.

Jeg fant en fornuftig forklaring på det første gang jeg møtte problemet, men har glemt det nå...

Link to post
Share on other sites
19 minutter siden, GeneralVirus skrev:

Fungerer helt fint nå igjen. Rart at det funket for meg før, men plutselig sluttet.

Ja, det betyr at en del webservere har fått oppgradert sikkerheten i mellomtiden. ;)

Link to post
Share on other sites

hmm, så bra for dere, mennår jeg kjører det samme scripet får jeg fremdeles feilmelding, tror jeg er ganna:

jan-14 16.33.31   Error 3 Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnTur.vb :Målet forårsaket et unntak under aktivering.->Does entry point CallsFromStopplace exist in script? ved System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) ved System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) ved System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ved Scheduler.clsRunVBNetScript.ExecuteScript()
jan-14 16.33.30   Event Running script and waiting: C:/Program Files (x86)/HomeSeer HS3/scripts/EnTur.vb("CallsFromStopplace","345,NSR:StopPlace:57094,NSR:Quay:97801,5")
jan-14 16.33.30   Event

Event Trigger "Ute Busstider"

 

 

Spoiler

 

 

Link to post
Share on other sites
17 minutter siden, Moskus skrev:

.... Men fungerer Main-rutinene some vi hard postet før?

Ja, ser ihvertfall ikke noen feilmelding i loggen ved oppkall av Main istedenfor den andre rutinen.
Så der er en forskjell! ?

Link to post
Share on other sites
4 minutter siden, Rogerbl skrev:

Ja, ser ihvertfall ikke noen feilmelding i loggen ved oppkall av Main istedenfor den andre rutinen.
Så der er en forskjell! ?

Her er resultat fra siste Main rutine jeg fik fra deg:

{"data":{"trip":{"tripPatterns":[{"startTime":"2020-01-14T17:21:00+0100","endTime":"2020-01-14T17:28:00+0100","duration":420,"walkDistance":0.0,"legs":[{"mode":"bus","distance":2550.9434618963073,"line":{"id":"KOL:Line:1006_245","publicCode":"5","name":"5"}}]},{"startTime":"2020-01-14T17:29:00+0100","endTime":"2020-01-14T17:36:00+0100","duration":420,"walkDistance":0.0,"legs":[{"mode":"bus","distance":2550.9434618963073,"line":{"id":"KOL:Line:1006_245","publicCode":"5","name":"5"}}]},{"startTime":"2020-01-14T17:36:00+0100","endTime":"2020-01-14T17:43:00+0100","duration":420,"walkDistance":0.0,"legs":[{"mode":"bus","distance":2550.9434618963073,"line":{"id":"KOL:Line:1006_245","publicCode":"5","name":"5"}}]},{"startTime":"2020-01-14T17:44:00+0100","endTime":"2020-01-14T17:51:00+0100","duration":420,"walkDistance":0.0,"legs":[{"mode":"bus","distance":2550.9434618963073,"line":{"id":"KOL:Line:1006_245","publicCode":"5","name":"5"}}]},{"startTime":"2020-01-14T17:51:00+0100","endTime":"2020-01-14T17:58:00+0100","duration":420,"walkDistance":0.0,"legs":[{"mode":"bus","distance":2550.9434618963073,"line":{"id":"KOL:Line:1006_245","publicCode":"5","name":"5"}}]}]}}}

Link to post
Share on other sites

Så bra! :) 

 

... kan du prøve dette:

    Sub Main(parm As Object)
        Dim list As List(Of EstimatedCall) = GetCallsFromStopPlace("NSR:StopPlace:27753", "NSR:Quay:47785")
        Dim out As String = ""

        For Each c As EstimatedCall In list
            out &= c.ToString & "<br>"
        Next

        hs.WriteLog("EnTur", out)
    End Sub

 

 

Link to post
Share on other sites
6 minutter siden, Moskus skrev:

Sub Main(parm As Object) Dim list As List(Of EstimatedCall) = GetCallsFromStopPlace("NSR:StopPlace:27753", "NSR:Quay:47785") Dim out As String = "" For Each c As EstimatedCall In list out &= c.ToString & "<br>" Next hs.WriteLog("EnTur", out) End Sub

Det likte ikke Hs3; her er feilmeldingen:

Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnTur.vb :Målet forårsaket et unntak under aktivering.->Does entry point Main exist in script? ved System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) ved System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) ved System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ved Scheduler.clsRunVBNetScript.ExecuteScript()

Link to post
Share on other sites

Tips ang. sortering:

Les radene inn i en tabell, sorter denne og skriv ut den sorterte tabellen til dev string'en. ?
Det er mer oversiktlig med sortering.

Og i HSTouch ser man kun starten på dev stringen..  det var litt synd. Man får ikke sett alt, kanskje en ide å

sende en pushover melding til  telefonen sånn at man får sett alle mulige avganger?

Link to post
Share on other sites
33 minutter siden, Rogerbl skrev:

Det likte ikke Hs3

Oookay, det er snålt Prøv dette, da:

Endre

GetCallsFromStopPlace("NSR:StopPlace:27753", "NSR:Quay:47785")

til:

GetCallsFromStopPlace("NSR:StopPlace:27753")

 

 

27 minutter siden, Rogerbl skrev:

Tips ang. sortering:

Les radene inn i en tabell, sorter denne og skriv ut den sorterte tabellen til dev string'en. ?
Det er mer oversiktlig med sortering.

Sortering av hva?

Det er vel sortert slik det skal?

 

Å laste over i en tabell for å sortere den er vel å gå over bekken etter vann.

 

 

27 minutter siden, Rogerbl skrev:

Og i HSTouch ser man kun starten på dev stringen..

I HStouch ser man hele strengen, det er jo ikke et problem. :) 

Du må evt. utvide selve labelen.

 

 

Link to post
Share on other sites
3 minutter siden, Moskus skrev:

Oookay, det er snålt Prøv dette, da:

Endre


GetCallsFromStopPlace("NSR:StopPlace:27753", "NSR:Quay:47785")

til:


GetCallsFromStopPlace("NSR:StopPlace:27753")

 

 

Sortering av hva?

Det er vel sortert slik det skal?

 

Å laste over i en tabell for å sortere den er vel å gå over bekken etter vann.

 

 

I HStouch ser man hele strengen, det er jo ikke et problem. :) 

Du må evt. utvide selve labelen.

 

 

vel, her hos meg er avgangstidene usortert. ?

Link to post
Share on other sites

Her er et modifisert vb script(pushoverhs.vb) som jeg bruker til å sende meg selv pushover meldinger med devicestring verdier. Det kan brukes til å sende

bussruter til din smarttelefon. F.eks en gang pr dag.

Parametrene er  Subjekt | hs.devID | prioritet | lyd

f.eks Bussrute Alta - Eiby | 567 | 1 | 1

Hvis du har installert Pushover plugin'en for HomeSeer vil du da motta en melding med bussrutene.

Du må selvsagt kjøre Moskus sitt Entur.vb script først så devicene får verdier.

Sjekk ut det orginale pushover.vb scriptet for mer info.

 

pushover.vb

pushoverhs.vb

push.jpg

Edited by Rogerbl
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By jonkristian
      Hei folkens.
       
      Jeg har laget ett lovelace-card for entur komponentet.
       

       
      Gjenstår å få inn norsk oversettelse av momentjs ellers er jeg veldig åpen for flere ønsker.
       
      Kom gjerne med forslag til forbedringer, her eller på github f.eks. i form av en PR
       
    • By Moskus
      Sub Main(ByVal parameters As Object) 'Moskus 2020 Dim devID As Integer = parameters.ToString Dim useHTMLtable As Boolean = True Dim url As String = "https://www.vg.no/spesial/2020/corona-viruset/data/norway-table-overview/" Dim source As String = "" Try Using client = New System.Net.WebClient Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12 client.Encoding = System.Text.Encoding.UTF8 source = client.DownloadString(url) End Using Catch ex As Exception hs.WriteLog("CoronaScript", "Net Feil: " & ex.Message) End Try If source = "" Then hs.WriteLog("CoronaScript", "Got no response from url: " & url) Exit Sub End If Dim json = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(source) Dim output As String = "" Try Dim confirmed As Integer = json("totals")("confirmed") If useHTMLtable Then output &= "<table border=0 cellspacing=0 cellpadding=0>" output &= "<tr><td><b>Totalt</b></td><td align='right'>" & json("totals")("confirmed") & "</td><td align='right'>" & json("totals")("dead") & "</td><td align='right'>" & json("totals")("recovered") & "</td></tr>" For i As Integer = 0 To json("cases").Count - 1 output &= "<tr><td>" & json("cases")(i)("name") & "</td><td align='right'>" & json("cases")(i)("confirmed") & "</td><td align='right'>" & json("cases")(i)("dead") & "</td><td align='right'>" & json("cases")(i)("recovered") & "</td></tr>" Next output &= "</table>" Else output &= "<b>Totalt: " & json("totals")("confirmed") & " / " & json("totals")("dead") & " / " & json("totals")("recovered") & "</b><br>" For i As Integer = 0 To json("cases").Count - 1 output &= "• " & json("cases")(i)("name") & ": " & json("cases")(i)("confirmed") & " / " & json("cases")(i)("dead") & " / " & json("cases")(i)("recovered") & "<br>" Next End If hs.SetDeviceString(devID, output, False) hs.SetDeviceValueByRef(devID, confirmed, True) Catch ex As Exception hs.WriteLog("CoronaScript", "Net Feil: " & ex.Message) End Try End Sub  
      Trigger: Kjøres hvert 5. minutt
      Parameter: DeviceIDen til en virtuell device som skal holde verdien.
      Du kan endre variabelen "useHTMLtable" til False hvis du vil ha det i HStouch, for HStouch viser ikke pene HTML-tabeller...
       

       
       
       
      Oppdatert med data fra RapidAPI siden jeg ble lei av at VG er så dårlig på å oppdatere tallene sine:
      Sub Main(ByVal parameters As Object) 'Moskus 2020 Dim devID As Integer = parameters.ToString Dim url As String = "https://covid-193.p.rapidapi.com/statistics?country=Norway" Dim source As String = "" Try Using client = New System.Net.WebClient 'TLS1.2 and encoding (UTF8) Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12 client.Encoding = System.Text.Encoding.UTF8 'Headers client.Headers.Set("x-rapidapi-host", "covid-193.p.rapidapi.com") client.Headers.Set("x-rapidapi-key", "DIN_RAPIDAPI_KEY_HER") 'GET the url source = client.DownloadString(url) End Using Catch ex As Exception hs.WriteLog("CoronaScript", "Net Feil: " & ex.Message) End Try If source = "" Then hs.WriteLog("CoronaScript", "Got no response from url: " & url) Exit Sub End If Try Dim json = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(source) Dim confirmed As Integer = json("response")(0)("cases")("total") Dim output As String = "" output &= "<b>Aktive: " & json("response")(0)("cases")("active") & " (" & json("response")(0)("cases")("new") & ") " & "</b><br>" output &= "Totalt: " & json("response")(0)("cases")("total") & "<br>" output &= "Dødsfall: " & json("response")(0)("deaths")("total") & " (" & IIf(json("response")(0)("deaths")("new").ToString = "", "0", json("response")(0)("deaths")("new")) & ") " & "<br>" output &= "Testede: " & json("response")(0)("tests")("total") & "<br>" output &= "<i>Sist oppdatert: " & json("response")(0)("time") & "</i><br>" hs.SetDeviceString(devID, output, False) hs.SetDeviceValueByRef(devID, confirmed, True) Catch ex As Exception hs.WriteLog("CoronaScript Error", "Parsefeil: " & ex.Message) End Try End Sub  
      Kjøres nå hver time, jeg vet ikke begrensningene hos RapidAPI.

       
       
    • By Moskus
      Public Sub Main(ByVal input As Object) 'Moskus 2020 Dim device As Scheduler.Classes.DeviceClass Dim DE As Scheduler.Classes.clsDeviceEnumeration Dim counter As Integer = 0 Dim counterBelow100 As Integer Dim filter As String = "batter" 'tar da både "battery" og "batteri" hs.WriteLog("Battery", "Looking for battery devices...") DE = hs.GetDeviceEnumerator() Do While Not DE.Finished device = DE.GetNext If device.Device_Type_String(hs).ToLower.Contains(filter) OrElse device.DeviceType_Get(hs).Device_Type_Description.ToLower.Contains(filter) OrElse device.Name(hs).Contains(filter) Then Dim devName As String = device.Location2(hs) & ", " & device.Location(hs) & ", " & device.Name(hs) Dim devValue As Double = hs.DeviceValueEx(device.Ref(hs)) If devValue < 100 Then hs.WriteLog("Battery", "Device: " & devName & ", battery: " & devValue) counterBelow100 += 1 End If counter += 1 End If Loop hs.WriteLog("Battery", "Done! Found " & counter & " devices, " & counterBelow100 & " have levels below 100%.") End Sub  
      Bare lagre som "GetBatteryLevels.vb" og kjør det. Det skrives til loggen.
    • By Moskus
      Det er det samme maset hvert år: "Hvorfor må vi alltid ha disse kjedelige juletrelysene? Klart jeg kan bruke RGBW-lys, men de er så... statiske.". Vi har alle vært der.
       
      Vel, Twinkly er svaret. Det er juletrelys som kan styres via en app, man kan legge til animasjoner, og man kan til og med lage egne og "tegne" fargene på treet i sanntid. Og nå kan man også selvfølgelig styre treet fra HomeSeer.
       
      Lagre scriptet under som Twinkly.vb i /scripts-mappen, endre IPen (nest øverste linje), og lag et event der du kjører "Setup"-funksjonen.
      'Moskus 2019 Const IP As String = "192.168.0.166" Dim debug As Boolean = False Public Sub Main(ByVal something As Object) End Sub Public Sub ButtonPress(ByVal input As Object) Dim deviceRef As Integer = input(0) Dim cmd As String = input(1) If DoCmd(cmd) Then hs.SetDeviceString(deviceRef, cmd, True) End Sub Public Function DoCmd(ByVal command As String) As Boolean 'SetMode("rt") 'SetMode("demo") 'SetMode("movie") 'SetMode("effect") 'SetMode("off") If debug Then hs.WriteLog("Twinkly", "Starting DoCmd()") Dim code As String = GetRandomCode() If debug Then hs.WriteLog("Twinkly", "Code: " & code) Dim auth As TwinklyAuthentication = Login(code, forceNew:=True) If debug Then hs.WriteLog("Twinkly", "Authentication_token: " & auth.authentication_token) Dim success As Boolean = Verify() If debug Then hs.WriteLog("Twinkly", "Verified: " & success) SetMode(command) Return True End Function Public Sub Setup(ByVal not_used As String) Dim new_ref As Integer = hs.NewDeviceRef("Twinkly") Dim dv As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(new_ref) dv.Location(hs) = "Twinkly" dv.Location2(hs) = "Twinkly" dv.Can_Dim(hs) = False dv.DeviceType_Set(hs) = New HomeSeerAPI.DeviceTypeInfo dv.Status_Support(hs) = True dv.Can_Dim(hs) = False dv.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.SHOW_VALUES) 'This is &H100 dv.MISC_Clear(hs, HomeSeerAPI.Enums.dvMISC.STATUS_ONLY) 'This is &H10 hs.SaveEventsDevices() AddDeviceButtons(new_ref) hs.WriteLog("Twinkly", "Initiation done!") End Sub Public Sub AddDeviceButtons(ByVal device_ref As String) Dim devID As Integer = CInt(device_ref) hs.DeviceScriptButton_DeleteAll(devID) hs.DeviceProperty_dvMISC(device_ref, HomeSeerAPI.Enums.eDeviceProperty.MISC_Set, HomeSeerAPI.Enums.dvMISC.SHOW_VALUES) Try hs.WriteLog("Twinkly", "Added button 1: " & hs.DeviceScriptButton_AddButton(devID, "Movie", 1, "Twinkly.vb", "ButtonPress", "Movie", 1, 1, 1)) hs.WriteLog("Twinkly", "Added button 2: " & hs.DeviceScriptButton_AddButton(devID, "Effect", 2, "Twinkly.vb", "ButtonPress", "Effect", 1, 2, 1)) hs.WriteLog("Twinkly", "Added button 3: " & hs.DeviceScriptButton_AddButton(devID, "Demo", 3, "Twinkly.vb", "ButtonPress", "Demo", 1, 3, 1)) hs.WriteLog("Twinkly", "Added button 4: " & hs.DeviceScriptButton_AddButton(devID, "RT", 4, "Twinkly.vb", "ButtonPress", "RT", 2, 1, 1)) hs.WriteLog("Twinkly", "Added button 5: " & hs.DeviceScriptButton_AddButton(devID, "Off", 0, "Twinkly.vb", "ButtonPress", "Off", 2, 2, 1)) Catch ex As Exception hs.WriteLog("Twinkly", "Error adding buttons: " & ex.Message) End Try End Sub Public Sub SetMovieConfig(ByVal frameDelay As Integer, ByVal numberOfLEDs As Integer, ByVal framesNumber As Integer, ByVal loopType As Integer) Dim data As New System.Collections.Generic.Dictionary(Of String, Integer) data.Add("frame_delay", frameDelay) data.Add("leds_number", numberOfLEDs) data.Add("frames_number", framesNumber) Dim output As String = RunAPI("led/movie/config", Newtonsoft.Json.JsonConvert.SerializeObject(data)) If debug Then hs.WriteLog("Twinkly", "SetMovieConfig: " & output) End Sub Public Sub GetMovieConfig() ' {"frame_delay":66,"leds_number":175,"loop_type":0,"frames_number":212,"sync":{"mode":"none","slave_id":"","master_id":""},"code":1000} Dim output As String = RunAPI("led/movie/config") If debug Then hs.WriteLog("Twinkly", "GetMovieConfig: " & output) End Sub Public Sub GetMovieFull() If debug Then hs.WriteLog("Twinkly", "GetMovieFull: ") Dim output As Byte() = RunAPIraw("led/movie/all") If debug Then hs.WriteLog("Twinkly", ConvertByteArrayToString(output) & " ... done!") End Sub Public Sub SetMovieFull(ByVal octetString As String) Dim movie() As Byte = ConvertStringToByteArray(octetString) If debug Then hs.WriteLog("Twinkly", "SetMovieFull: ") Dim ret = RunAPIraw("led/movie/full", movie) If debug Then hs.WriteLog("Twinkly", System.Text.Encoding.ASCII.GetString(ret) & " ... done!") End Sub ''' <summary> ''' Sets the display ''' </summary> ''' <param name="mode">rt, movie, demo, restart, effect, off</param> Public Sub SetMode(ByVal mode As String) If debug Then hs.WriteLog("Twinkly", "Setting mode to '" & mode & "'") Dim data As New System.Collections.Generic.Dictionary(Of String, String) data.Add("mode", mode.ToLower()) Dim output As String = RunAPI("led/mode", Newtonsoft.Json.JsonConvert.SerializeObject(data)) Dim success As Boolean = output.Contains("1000") If debug Then hs.WriteLog("Twinkly", "Mode set: " & IIf(success, " was a success!", " failed. :(")) If Not success And debug Then hs.WriteLog("Twinkly", "Output: " & output) End Sub Public Function GetAuthentication() As TwinklyAuthentication Dim auth As TwinklyAuthentication = New TwinklyAuthentication Dim authString As String = hs.GetINISetting("Twinkly", "Authentication", "", "Twinkly.ini") Try If authString <> "" Then auth = Newtonsoft.Json.JsonConvert.DeserializeObject(Of TwinklyAuthentication)(authString) End If Catch ex As Exception End Try Return auth End Function Public Function Verify() As Boolean Dim auth As TwinklyAuthentication = GetAuthentication() Dim data As New System.Collections.Generic.Dictionary(Of String, String) data.Add("challenge-response", auth.challengeresponse) Dim output As String = RunAPI("verify", Newtonsoft.Json.JsonConvert.SerializeObject(data)) Return output.Contains("1000") End Function Public Function Login(ByVal challenge As String, Optional ByVal forceNew As Boolean = False) As TwinklyAuthentication Dim auth As TwinklyAuthentication = Nothing Dim authString As String = "" authString = hs.GetINISetting("Twinkly", "Authentication", "", "Twinkly.ini") Try If authString <> "" Then auth = Newtonsoft.Json.JsonConvert.DeserializeObject(Of TwinklyAuthentication)(authString) Catch ex As Exception End Try If auth Is Nothing OrElse forceNew Then Dim data As New System.Collections.Generic.Dictionary(Of String, String) data.Add("challenge", challenge) Dim output As String = RunAPI("login", Newtonsoft.Json.JsonConvert.SerializeObject(data)) hs.SaveINISetting("Twinkly", "Authentication", output, "Twinkly.ini") auth = Newtonsoft.Json.JsonConvert.DeserializeObject(Of TwinklyAuthentication)(output) End If Return auth End Function Private Function RunAPI(ByVal urlFunction As String, Optional ByVal query As String = "") As String Dim source As String = "" Dim url As String = "http://" & IP & "/xled/v1/" & urlFunction Dim auth As TwinklyAuthentication = GetAuthentication() Using client As New System.Net.WebClient client.Headers.Add("Content-Type", "application/json") If auth.authentication_token <> "" Then client.Headers.Add("X-Auth-Token", auth.authentication_token) End If If query <> "" Then source = client.UploadString(url, "POST", query) Else source = client.DownloadString(url) End If End Using Return source End Function Private Function RunAPIraw(ByVal urlFunction As String, Optional ByVal bytes() As Byte = Nothing) As Byte() Dim auth As TwinklyAuthentication = GetAuthentication() Dim source As Byte() = {} Dim url As String = "http://" & IP & "/xled/v1/" & urlFunction Using client As New System.Net.WebClient Net.ServicePointManager.DefaultConnectionLimit = 9999 client.Headers.Add("Content-Type", "application/octet-stream") If auth.authentication_token <> "" Then client.Headers.Add("X-Auth-Token", auth.authentication_token) End If If bytes IsNot Nothing Then source = client.UploadData(New Uri(url), bytes) Else source = client.DownloadData(url) End If End Using Return source End Function Public Function GetRandomCode(Optional ByVal forceNew As Boolean = False) As String Dim code As String = hs.GetINISetting("Twinkly", "Code", "", "Twinkly.ini") If code = "" OrElse forceNew Then code = GetRandomString(32) hs.SaveINISetting("Twinkly", "Code", code, "Twinkly.ini") End If Return code End Function Private Function GetRandomString(ByVal length As Integer) Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Dim r As New Random Dim sb As New Text.StringBuilder For i As Integer = 0 To length - 1 Dim idx As Integer = r.Next(0, 35) sb.Append(s.Substring(idx, 1)) Next Return sb.ToString() End Function Public Function ConvertStringToByteArray(ByVal input As String) As Byte() Dim lst As New System.Collections.Generic.List(Of Byte) For i As Integer = 0 To input.Length - 1 Step 2 Dim temp As String = input.Substring(i, 2) Dim val As Integer = Convert.ToInt32(temp, 16) lst.Add(Convert.ToByte(val)) Next Return lst.ToArray() End Function Public Function ConvertByteArrayToString(ByVal bytes() As Byte) As String Dim ret As String = "" For Each b As Byte In bytes ret &= Convert.ToChar(b).ToString() Next Return ret End Function Public Class TwinklyAuthentication Private _authentication_token As String Public Property authentication_token() As String Get Return _authentication_token End Get Set(ByVal value As String) _authentication_token = value End Set End Property Private _authentication_token_expires_in As Integer Public Property authentication_token_expires_in() As Integer Get Return _authentication_token_expires_in End Get Set(ByVal value As Integer) _authentication_token_expires_in = value End Set End Property Private _challengeresponse As String Public Property challengeresponse() As String Get Return _challengeresponse End Get Set(ByVal value As String) _challengeresponse = value End Set End Property Private _code As Integer Public Property code() As Integer Get Return _code End Get Set(ByVal value As Integer) _code = value End Set End Property End Class
    • By clio75
      Hva skal hentes denne uka er et gjentagende SPM hjemme hos oss. 
      Så jeg fant APPEN "Min renovasjon.". Men en app er jo ikke løsningen på noe. For man vil jo ha denne informasjonen inn i homeseer. 
       
      MinRenovasjon.vb
      Sub Main(ByVal parameters As Object) 'Clio75 All Credits to Moskus@hjemmeautomasjon.no 'Inspired and based on Moskus scrip NewsReader.vb Dim DevID As Integer = parameters.ToString.Split("|")(0) Dim KommuneNr As String = parameters.ToString.Split("|")(1) Dim Gatekode As String = parameters.ToString.Split("|")(2) Dim GateNavn As String = parameters.ToString.Split("|")(3) Dim GateNr As String = parameters.ToString.Split("|")(4) 'Sette sammen URL: Dim kommuneURL as string = "kommunenr=" & KommuneNr Dim GateKodeURL as string = "gatekode=" & Gatekode Dim GateNavnURL as string = "gatenavn=" & GateNavn Dim GateNrURL as string = "husnr=" & GateNr Dim url As String = "https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?" & kommuneURL & "&" & GateNavnURL & "&" & GateKodeURL & "&" & GateNrURL 'hs.WriteLog("Soppel Error", "url " & url) Dim source As String = "" Try Using client As New System.Net.WebClient 'Sette Headers client.headers.set("Kommunenr", KommuneNr ) client.headers.set("RenovasjonAppKey", "AE13DEEC-804F-4615-A74E-B4FAC11F0A30") Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12 client.Encoding = System.Text.Encoding.UTF8 source = client.DownloadString(url) End Using Catch ex As Exception hs.WriteLog("Soppel Error", "Net Feil: " & ex.Message) End Try If source = "" Then hs.WriteLog("soppel Error", "Got no response from url: " & url) Exit Sub End If Try 'Dim json as Newtonsoft.Json.string = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(source) Dim json as Object = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(source) Dim numMembers As Integer = json.Count -1 Dim DeviceText As String = "" For i As Integer = 0 To numMembers Dim output As String = "" Dim output2 As String = "" output = json(i)("FraksjonId") output2 = json(i)("Tommedatoer")(0) & " Neste :" Try output2 &= json(i)("Tommedatoer")(1) Catch ex As Exception output2 &= " -- " End Try Select Case Output Case "1" output = Replace(output, "1", "<b>Restavfall : </b><br>") Case "2" output = Replace(output, "2", "<b>Papiravfall : </b><br>") Case "3" output = Replace(output, "3", "<b>Matavfall : </b> <br>") Case "4" output = Replace(output, "4", "<b>Glass/Metall : </b><br>") Case "5" output = Replace(output, "5", "<b>Drikkekartonger </b><br>") Case "6" output = Replace(output, "6", "<b>Grovavfall : </b><br>") Case "7" output = Replace(output, "7", "<b>Plastavfall : </b><br>") End Select DeviceText &= "" & output & " " & output2 & "<br>" Next hs.SetDeviceString(DevID, DeviceText , True) Catch ex As Exception hs.WriteLog("Soppel Error", "Net Feil: " & ex.Message) End Try End Sub Så en event : 
      Parameters : 
      DevieRef | Kommunenummer | Gatenummer | GataNavn | Husnummer
       
      Ser jeg forsatt har manuell trigger i screenshot, men en gang i døgnet burde vel holde i de fleste tilfeller. 

       
      SOM ga meg denne : 
       

       
      Instalering : 
      VeiNummer: 
      For å finne vegnummeret kan du gå inn på https://www.vegvesen.no/vegkart zoom deg inn på vegen din og nærmest mulig huset ditt klikker du på veien, Så finner du de 5 sifferene du trenger(Rødt). 
      Kommune Nummeret var de fire første her i Blått : 0710 

       
      HomeSeer trenger en referanse til Newtonsoft.Json.Dll, det kan du sette opp ved å lese under "Installasjon" i denne tråden: https://www.hjemmeautomasjon.no/forums/topic/4338-script-enturvb-få-inn-data-fra-entur/
       
      Takk Til: 
      Dette hadde jeg ikke klart alene.
       @Moskus skal ha en stor takk for sine delinger av script. Tatt utgangspunktet i hans NewsReader.VB
       @Marhil  Takk for tipset om Min renovasjons app eller hvordan jeg fant Gatenummer
      Og alle de andre som deler kode og eksempler åpnet på nett
       


×
×
  • Create New...