Page 2 of 2
Re: XBMC Script
Posted: Thu Mar 21, 2013 11:59 am
by AshaiRey
Ja het moet de extentie .vb hebben.
En wat betreft hstouch.. Kleine stapjes graag want ik werk in het donker zo gezegt.
Ik moet eerst leren kruipen voordat ik kan gaan proberen te rennen

Re: XBMC Script
Posted: Thu Mar 21, 2013 2:31 pm
by AshaiRey
Kees, Phaeton,
Ik heb jullie een PM gestuurd met het verzoek om de code te testen en het resultaat goed of slecht (incl. meldingen) terug te koppelen zodat ik er mee verder kan.
Voor de overige lezers.
Ik zal hier de code posten zodra deze ook werkt dit om te voorkomen dat er teleurstellingen ontstaan als je de hier geplaatste, niet werkende code zou gebruiken.

Re: XBMC Script
Posted: Thu Mar 21, 2013 2:41 pm
by keeslamper
Komt goed Bram, heb het ontvangen! Probeer vandaag te testen en terug te koppelen!
Re: XBMC Script
Posted: Tue Mar 26, 2013 9:48 pm
by keeslamper
Bram,
Ben even nieuwsgierig of je nog verder gekomen bent :$
Groet,
Kees
Re: XBMC Script
Posted: Wed Mar 27, 2013 10:04 am
by AshaiRey
Hoi Kees,
Ik moest even wat testen afwachten in een specifieke configuratie. Het is toch uiterst lastig werken zo als je geen XBMC zelf heb draaien.
Ik heb hier een framewerkje om mee verder te werken. Er zitten 4 commando's in die je als voorbeeld kan gebruiken om andere commando's erbij te frutselen. Ik heb express geen 'sexy' programeer technieken gebruikt om het zo laag drempelig mogelijk te houden. In de header staat een link naar hoe de commando's eruit moeten zien en een link die al veel voorbeelden heeft.
Tip: Als je debugging aan houd dan kan je de json commando uit het log kopieren en in notepad zetten met daaronder de regel hoe hij moet worden zodat je precies kan zien waar de verschillen zitten.
Voorlopig heb ik even weinig tijd om hier verder aan te werken dus wie dit leest voel je vrij om het uit te breiden en hier te posten.
(Ps, kan hier geen txt bestanden aan attachen)
Code: Select all
' XBMCmd.vb
' by A.A. van Zoelen
'
' Purpose : HomeSeer conrole script for XMBC v12.1
' Version : 0.13
'
' Makes use of XBMC JSON-RPC API v6 (Frodo)
' http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6
' More XBMC API info at
' http://wiki.xbmc.org/index.php?title=JSON-RPC_API
'
' Remark : Still in heavy testing/debug/discovery fase!
' Usage at your own risk!
'
' Available commands this far:
'----------------------------------------------------------------
' PLAYPAUSE Pauses or unpause playback and
' returns the new state
' Parameters : PlayerId (when omitted it will be 0)
' RESTART Restart the XBMC system
' Parameters : None
' SHOWNOTIFICATION Display a message on the XBMC system
' Parameters : Title;Message;DisplayTime
' XPING Check if the XBMC system is available
' Parameters : None
Imports system.IO
Imports system.Text
Imports system.Net
'=================================================
'=================================================
' Fill in your settings
Dim IP As String = "192.168.1.56"
Dim PORT As String = "8081"
Dim REPORTDEVICE As String = ""
Dim DEBUG As Boolean = True
'=================================================
'=================================================
' No need to change things below this line
'Make this variable global
Dim strBaseURL As String = ""
Sub Main(ByVal Params As Object)
'Base string for the URL
strBaseURL = "http://" & IP
If (Len(PORT) > 0) Then strBaseURL = strBaseURL & ":" & PORT
strBaseURL = strBaseURL & "/jsonrpc?request={""jsonrpc"":""2.0"",""method"":"
If DEBUG = True Then hs.writelog("<b>XBMCcmd</b>", strBaseURL)
If DEBUG = True Then hs.writelog("<b>XBMCcmd</b>", "HS.Ping status of " & IP & " is " & hs.ping(IP))
Dim strReply As String = ""
Dim blnStatus As Boolean = False
'Parse command
Dim strAction as String = UCASE(Trim(hs.StringItem(Params, 1, ";") ) )
'Check if the system is available
If hs.ping(IP) = 1 Then
' Please note that the ping protocol can't ping ports
' If you want to check if XBMC itself is running then
' use the XPING command
hs.writelog("<b>XBMCcmd</b>","<b>No reply from " & IP & "<br>(without portnumber because Ping can not test on portnumbers)</b>")
Exit Sub
End If
If DEBUG = True Then hs.writelog("XBMCcmd","Passed HS.Ping")
'Do Commands
If strAction = "PLAYPAUSE" Then
strReply = PlayPause(hs.StringItem(Params, 2, ";"))
blnStatus = True
End If
If strAction = "RESTART" Then strReply = DoRestart() : blnStatus = True
If strAction = "SHOWNOTIFICATION" Then
strReply = ShowNotification(hs.StringItem(Params, 2, ";"), hs.StringItem(Params, 3, ";"), hs.StringItem(Params, 4, ";"))
blnStatus = True
End If
If strAction = "XPING" Then strReply = DoPing() : blnStatus = True
If blnStatus = False Then hs.writelog("XBMC", "Unknow action:" & strAction)
If strReply <> "" Then
If DEBUG = True Then hs.writelog("XBMC", strAction & " : " & strReply)
If REPORTDEVICE <> "" Then
hs.setdevicestring(REPORTDEVICE, strReply)
End If
End If
If DEBUG = True Then hs.writelog("XBMCcmd","Script ready")
End Sub
'=======================
'== AVAILABLE ACTIONS ==
'=======================
' RESTART Restart the XBMC system
' Parameters : None
Function DoRestart() As String
Dim strURL As STring = ""
strURL = strBaseURL & """System.Reboot""}"
If DEBUG = True Then hs.writelog("XBMC", "JSON URL : " & strURL)
Return hs.urlaction(strURL,"GET","","")
End Function
'==========================================================
' SHOWNOTIFICATION Display a message on the XBMC system
' Parameters : Title;Message;DisplayTime
Function ShowNotification(ByVal strTitle As String, ByVal strMessage As String, ByVal intDisplayTime As Integer) As String
Dim strURL As STring = ""
'action
strURL = strBaseURL + """GUI.ShowNotification"","
'Parameters
strURL = strURL + """params"":{""title"":" & chr(34) & strTitle & chr(34) & ",""message"":" & chr(34) & strMessage & chr(34) & ",""displaytime"":" & intDisplayTime & "}}"
If DEBUG = True Then hs.writelog("XBMC", "JSON URL : " & strURL)
Return hs.urlaction(strURL,"GET","","")
End Function
'==========================================================
' PLAYPAUSE Pauses or unpause playback and
' returns the new state
' Parameters : PlayerId
Function PlayPause(ByVal strPlayerId As String) As String
Dim strURL As STring = ""
If strPlayerId = "" Then strPlayerId = "0"
'action
strURL = strBaseURL + """Player.PlayPause"","
'Parameters
strURL = strURL + """params"":{""playerid"":" & strPlayerId & "},""id"": 1}"
If DEBUG = True Then hs.writelog("XBMC", "JSON URL : " & strURL)
Return hs.urlaction(strURL,"GET","","")
End Function
'==========================================================
' XPING Check if the system is available
' Parameters : None
Function DoPing() As String
Dim strURL As STring = ""
strURL = strBaseURL + """JSONRPC.Ping"", ""id"": ""1""}"
If DEBUG = True Then hs.writelog("XBMC", "JSON URL : " & strURL)
Return hs.urlaction(strURL,"GET","","")
End Function
'==========================================================
Re: XBMC Script
Posted: Wed Mar 27, 2013 8:41 pm
by keeslamper
Helemaal top Bram,
Ik ga wel is prutsen. Heb zelf ook niet veel tijd, maar misschien is er iemand die heel handig is en wel een klein beetje tijd heeft

Re: XBMC Script
Posted: Thu Mar 28, 2013 9:54 am
by AshaiRey
Ik blijf dit uiteraard wel volgen.
Op het moment ben ik met VR bezig. Na zo'n 2 jaar experimenteren, testen en weer laten bezinken heb ik denk ik nu iets uitgevogelt dat zou moeten werken. (Doet het ook voor 95% nu) . Ben daar nu druk mee.

Re: XBMC Script
Posted: Sun Mar 31, 2013 12:25 pm
by RdP
Guys,
Houd deze thread ook in de gaten.....
http://board.homeseer.com/showthread.php?t=159185
Gr,
Rien
Re: XBMC Script
Posted: Sun Mar 31, 2013 12:38 pm
by keeslamper
Dat ziet er ook goed uit! Deze week is testen.
Kees
Re: XBMC Script
Posted: Sun Apr 07, 2013 12:46 pm
by keeslamper
Ik gebruik het script vanaf Homeseer forum, werkt prima!