Results 1 to 6 of 6

Thread: Send notifications to boxee box - JSON RPC

Hybrid View

  1. #1

    Default Send notifications to boxee box - JSON RPC

    Hello devs, I'm sure someone with the minimal skill I lack can help me out with some python json bash scripting help.
    I'm trying to get my callerid script to send a notification to my boxee box connected tv. I've got the script working using mgetty and notify-send on a couple of my computers.

    here is my cidscript.sh which gets triggered by mgetty
    Code:
    #!/bin/sh
    
    # send message to computer
    ssh -o ConnectTimeout=10 mrplow@192.168.1.10 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
    sleep 0.2
    ssh -o ConnectTimeout=10 christine@192.168.1.3 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
    sleep 0.2
    ssh -o ConnectTimeout=10 mrplow@192.168.1.120 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
    sleep 0.2
    su mrplow -c "DISPLAY=:0.0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
    sleep 5
    
    # update logs
    echo `date +"%F %a %r"`"|$CALLER_ID|$CALLER_NAME" >> /home/mrplow/answering_machine/logs/incoming-calls.log
    scp -o ConnectTimeout=10 /home/mrplow/answering_machine/logs/incoming-calls.log christine@192.168.1.3:/home/christine/Desktop/incoming-calls.log
    
    sleep 0.2
    
    exit 1

    so onto the boxee box...

    I think json rpc is going to be the only way to get this to work without making an actual app. the webgui doesn't seem to support any notifications
    I've managed to telnet into the boxee box on raw port 9090
    then paired my device using the help from this thread source:forums.boxee.tv
    request pair code
    {"jsonrpc": "2.0", "method": "Device.PairChallenge", "params": {"deviceid": "############", "applicationid": "testapp", "label": "test", "icon": "http://blah.com/test.jpg", "type": "tablet"}, "id": 1}

    send pair code
    {"jsonrpc": "2.0", "method": "Device.PairResponse", "params":{"deviceid": "############", "code": "####"},"id": 1}
    here is the fuction I'm trying to get working

    connect
    {"jsonrpc": "2.0", "method": "Device.Connect", "params":{"deviceid": "############"}, "id": 1}

    this is the part I can't figure out, I'm good with copy paste not so much with this though
    GUI.NotificationShow
    Show notification dialog for 5 seconds.
    PARAMETER
    msg string message to display in the notification dialog
    source:developer.boxee.tv

    here is what I have guessed/tried
    Code:
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "test"}
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "msg":"test"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":{"test"}, "id": 1}
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "msg":{"test"}, "id": 1}
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "msg":{"test"}}
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "msg":"test", "id": 1}
    {"error":{"code":-32602,"data":{"method":"GUI.NotificationShow","stack":{"message":"Missing parameter","name":"msg","type":"string"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":"test", "id": 1}
    {"error":{"code":-32600,"message":"Invalid request."},"id":1,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":"test"}
    {"error":{"code":-32600,"message":"Invalid request."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "string":test}
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "string":"test"}
    if anyone could help with the notification json line or with implementing it in my script I'd be greatfull, or just help with the script in general I'd be grateful. Sometimes the mgetty script returns null parameters when it has missing caller info and because of this sometimes my script returns the previous caller's info but thats really for another message board3

  2. #2
    Join Date
    Oct 2008
    Posts
    735

    Default

    params should be a json object containing the parameter names and values (the same as you are using for the other methods). So you need something like:
    Code:
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":{"msg" : "test"}, "id": 1}

  3. #3

    Default

    Quote Originally Posted by StevenR View Post
    params
    Code:
    {"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":{"msg" : "test"}, "id": 1}
    yes!
    thank you very much, exactly what I needed

  4. #4

    Default

    figured it out, a one liner bash command to send caller id notifications to my boxee box
    Code:
    echo { \"jsonrpc\": \"2.0\", \"method\": \"Device.Connect\", \"params\":{\"deviceid\": \"############\"}, \"id\": 1}\
    { \"jsonrpc\": \"2.0\", \"method\": \"GUI.NotificationShow\", \"params\":{\"msg\" : \"Phone call from...      $CALLER_NAME      $CALLER_ID\"}, \"id\": 1 } | telnet 192.168.1.6 9090 &> /dev/null

  5. #5
    Join Date
    Feb 2011
    Posts
    146

    Default

    mrplow -> can you help a non programmer do this? I'd love to get my caller ID to show up on my computers and my Boxee too! Not sure how to implement what you outlined here…

    - Jon

  6. #6

    Default

    you need a modem which supports voice in linux, a hardware modem. Almost all modems sold now a days are soft modems, dumb modems which require windows to do most of the heavy lifing, those will not work. I ended up buying an external voice modem. If you'd like I can step you though the rest of the steps to get it working. If you don't have a hardware modem I can help you just getting notifications going through your computer to the boxee box as a test. You running linux or windows?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •