Announcement

Collapse
No announcement yet.

Kodi - How to Send basic (pause/play/etc) info to Homeseer?

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

  • Kodi - How to Send basic (pause/play/etc) info to Homeseer?

    I only need very basic info from Kodi. All I do is turn on/dim, or turn off lights when a show starts/end/paused.

    In Vera I simply have a virtual device that the Kodi addon sends the state of the kodi player, and vera logic watches and acts accordingly.

    I know there is a HS plugin but, I'm not feeling basic needs are worth $30-40.

    Anyone have an easy way to do this?

    thx for the help.

  • #2
    Originally posted by Ltek View Post
    I only need very basic info from Kodi. All I do is turn on/dim, or turn off lights when a show starts/end/paused.

    In Vera I simply have a virtual device that the Kodi addon sends the state of the kodi player, and vera logic watches and acts accordingly.

    I know there is a HS plugin but, I'm not feeling basic needs are worth $30-40.

    Anyone have an easy way to do this?

    thx for the help.
    I've done it with a script, it's not the easiest to send data from OSMC however you can ask information from HS to OSMC on a regular basis. This script won't exactly meet your needs and is a lazy method to parse JSON but it is a script I was using to poll OSMC to determine whether it was playing and if it was was it playing video or audio.

    Code:
    Imports System.Net
    Imports System.Text.RegularExpressions
    
    Dim IPAddress As String = "192.168.1.234" '234
    Dim DVRef As Integer = 3427
    
    Sub Main(ByVal Parm As Object)
    
        Try
            Dim wCl As WebClient = New WebClient()
    
            Dim reData As String = wCl.DownloadString("http://" & IPAddress & "/jsonrpc?request={""jsonrpc"": ""2.0"", ""method"": ""Player.GetActivePlayers"", ""id"": 1}")
            'hs.writelog("OSMC", "Received Data: " & reData)
    
            Dim jReply As String = jsonParser(reData, "type")
    
            If jReply <> Nothing Then
                Select Case jReply.ToLower
                    Case "video" : SetDevice(1)
                    Case "music" : SetDevice(2)
                    Case Else : SetDevice(0)
                End Select
            Else : SetDevice(0)
            End If
    
            wcl.Dispose()
    
        Catch ex As Exception
            hs.writelog("OSMC", "Exception:  " & ex.message)
            SetDevice(9999)
        End Try
    
    End Sub
    
    Sub SendNotification(ByVal NotifText As String)
    
        Try
            Dim Title As String = "HomeSeer"
            Dim ShowTime As Integer = 15000
    
            hs.writelog("OSMC", "SendNotification: Text: " & NotifText)
            Dim NotificationR As String = hs.replacevariables(NotifText)
    
            Dim wCl As WebClient = New WebClient()
            Dim reData As String = wCl.DownloadString("http://" & IPAddress & "/jsonrpc?request={""jsonrpc"": ""2.0"", ""method"": ""GUI.ShowNotification"", ""id"": 1, ""params"":{""title"":""" & Title & """,""message"":""" & NotificationR & """,""displaytime"":" & ShowTime & "}}""")
    
            'hs.writelog("OSMC", "Data: " & reData)
    
        Catch ex As Exception : hs.writelog("OSMC", "SendNotification Exception:  " & ex.message)
        End Try
    
    End Sub
    
    Function jsonParser(ByVal responseCode As String, ByVal responseRequired As String) As String
    
        Dim responseArgs() As String = Regex.Replace(responseCode, "[[\{}""]]*", "").Split(",")
    
        Dim responseCheck As String = Nothing
        Dim argumentCheck() As String = Nothing
    
        If (responseRequired IsNot Nothing) Then
            For Each argument As String In responseArgs
                If (argument.StartsWith("result") OrElse argument.StartsWith(responseRequired)) Then
                    argumentCheck = argument.Split(":")
                    For argCount As Integer = 0 To argumentCheck.Length - 1
                        responseCheck = argumentCheck(argCount).ToString()
                        If (responseCheck = responseRequired) Then Return (argumentCheck(argCount + 1)).ToString()
                    Next
                End If
            Next
        End If
    
        Return Nothing
    
    End Function
    
    Sub SetDevice(ByVal DeviceState As Integer)
            If hs.devicevalue(DVRef) <> DeviceState Then
                Select Case DeviceState
                    Case 0, 1, 2, 9999 : hs.setdevicevaluebyref(DVRef, DeviceState, True)
                End Select
            End If
    End Sub
    My Plugins:

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

    Comment


    • #3
      try this

      the easy and free way is with the media manager plugin. it works well enough and it is free. I use kinect to play, pause and stop kodi

      Comment


      • #4
        Originally posted by wadesready View Post
        the easy and free way is with the media manager plugin. it works well enough and it is free. I use kinect to play, pause and stop kodi
        Thanks, I'll look into it. Didn't know about it

        Sent from my SAMSUNG-SM-G935A using Tapatalk

        Comment


        • #5
          I wrote a kodi addon to send play pause status changes to hs3. Zip and instructions are here: https://forums.homeseer.com/showthread.php?p=1282348

          Comment


          • #6
            Originally posted by wadesready View Post
            the easy and free way is with the media manager plugin. it works well enough and it is free. I use kinect to play, pause and stop kodi


            I am going to have to check that out.


            Sent from my iPhone using Tapatalk

            Comment

            Working...
            X