I have just installed OpenRemote and started to configure my controller to controll XBMC via JSON-RPC. Sending commands via Telnet works great. But if I want to stop playing the current video/song/etc I first need to query XBMC for the ID of the Active Player and then use that ID in the Stop-Player command string. How can I do that in OpenRemote?
Example:
Query for Active Player:
Command: null|{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}
Response: {"id":1,"jsonrpc":"2.0","result":[{"playerid":0,"type":"audio"}]}
Stop Player (PlayerId = 0)
Command: null|{"jsonrpc": "2.0", "method": "Player.Stop", "params": {"playerid": 0}, "id": 1}
Comments (25)
Jan 23
Marcus Redeker says:
The telnet command supports a responseFilter which is a regular expression. You ...The telnet command supports a responseFilter which is a regular expression. You could probably use that to extract the id from one command. Then create a second command and use the rule engine (upcoming 2.0 release) to trigger that command and give the result of the first one. This is just an idea and it might work.
Jan 23
Fredrik Dahlberg says:
That would most definitely solve my problem. Do you know when there will be a de...That would most definitely solve my problem. Do you know when there will be a developer release with this functionality available?
Jan 23
Marcus Redeker says:
You can try this one, which I provided a few days ago: http://www.redeker-consul...You can try this one, which I provided a few days ago: http://www.redeker-consulting.de/openremote/OpenRemote-Controller-2.0.0_SNAPSHOT_20120103.zip
There was also another thread on the forums where a link to some rule engine examples was posted.
Jan 23
yann philippe says:
Fredrik, Would be nice if you could share the results of your XBMC integration ...Fredrik,
Would be nice if you could share the results of your XBMC integration and document it?
Jan 24
Fredrik Dahlberg says:
How do I store the output of the first command? My first thought was to use a se...How do I store the output of the first command? My first thought was to use a sensor. But it seems that they have to be defined in the UI to work and I don't want to display the current player-id.
Jan 24
Marcus Redeker says:
Yes, you need a sensor to store the value. And yes again, in the moment you need...Yes, you need a sensor to store the value.
And yes again, in the moment you need to put the sensor on a page for it to be available.
This will change with the next release of the designer.
Here you can see a video on how it works: http://www.redeker-consulting.de/openremote/russound_wizard_rules.mov
This video was created with the upcoming version.
Jan 24
Marcus Redeker says:
So, you need 2 commands and one sensor. The first command returns the id. Then y...So, you need 2 commands and one sensor.
The first command returns the id. Then you create a sensor "readId" which holds the id.
The second command sends the id. The id has to be replaced with "${param}" which later is replaced with the real id.
Now you create a rule like this:
rule "Execute command with ID from sensor"
when
$evt : Event (source == "readId")
then
execute.command("doSomethingWithID", $evt.getValue());
That should work
Jan 25
Fredrik Dahlberg says:
I have a problem with my sensor. If XBMC are playing something when I start OR e...I have a problem with my sensor. If XBMC are playing something when I start OR everything works ok and my Panel Label displays the correct Active Player ID. But if I stop the active player OR throws an error and never starts polling again. The reason being that XBMC doesn't reply with a Player ID when not playing anything. Am I doing something wrong or shouldn't OR continue to try to poll?
Response from query of Player ID when not playing anything:
{"id":1,"jsonrpc":"2.0","result":[]}Error:
Jan 25
Marcus Redeker says:
You have to define a "statusDefault" attribute for the command. Then that will b...You have to define a "statusDefault" attribute for the command. Then that will be used if regex does not find a match.
Jan 25
Fredrik Dahlberg says:
It was my own fault, I didn't realize I should have used the "Default Read Respo...It was my own fault, I didn't realize I should have used the "Default Read Response" in the telnet command.
Edit:
Damn your fast Marcus! Don't you ever sleep?
Jan 25
Fredrik Dahlberg says:
Thinking about it there is a flaw in our reasoning, or at least in mine. Creati...Thinking about it there is a flaw in our reasoning, or at least in mine.
Creating a command that returns the id and a sensor that holds it works fine. But if I use the rule engine to trigger a second command to turn off the player as soon as I get an event from the sensor means that as soon as I turn on a player it will be turned off again. Is it possible for the rule engine to recognize a button press from a button without a command and then let that rule execute a command to turn off the active player? Or is there another/better way to do it?
Jan 25
Marcus Redeker says:
Having a button to trigger a rule is high on the list , but unfortunately not av...Having a button to trigger a rule is high on the list
, but unfortunately not available in the moment 
You could try the "In-memory virtual command".
Create a command using that protocol with address "dummy" and command "on"
Create a command using that protocol with address "dummy" and command "off"
Create a command using that protocol with address "dummy" and command "status"
Create a switch sensor with the virtual status command.
Create a switch with that sensor and the on and off commands.
Now you can use the rule engine to use that status sensor.
Jan 26
Fredrik Dahlberg says:
Marcus : Do you have any idea when having a button to trigger a rule will be imp...Marcus : Do you have any idea when having a button to trigger a rule will be implemented or is it just on the wish list?
Jan 26
Marcus Redeker says:
Hopefully not too far in the future. But I cannot give any date or something. Do...Hopefully not too far in the future. But I cannot give any date or something.
Does the workaround with the virtual command help?
Jan 26
Fredrik Dahlberg says:
I haven't tried the virtual command yet, but I will probably experiment with it ...I haven't tried the virtual command yet, but I will probably experiment with it this weekend just for fun. I will however wait with my XBMC implementation until you guys have time to implement the functionality I need. But I do like what I have seen so far about OpenRemote. Keep up the good work, it's really appreciated.
Jan 30
Fredrik Dahlberg says:
Marcus: Do you have any plans for implementing a per device configuration settin...Marcus: Do you have any plans for implementing a per device configuration setting for device common settings like ip-adress? With regards to XBMC and JSON-RPC there are about 150 different commands to configure and every line I don't need to fill in saves time and work? It would also be much easier to share my configuration with other people if they just have to change the ip-adress in one place.
Jan 30
Marcus Redeker says:
Plans like this are there For Russound for example there is a wizard that creat...Plans like this are there
For Russound for example there is a wizard that creates all neccessary commands, sensor, etc.
Just needs one configuration for an ip address and you are ready to go.
If this makes sense for other frequent used devices, why not.
Jan 31
yann philippe says:
+1 for XBMC+1 for XBMC
Jan 31
Marcus Redeker says:
I just did a little research on the XBMC JSON-RPC stuff and it would probably ma...I just did a little research on the XBMC JSON-RPC stuff and it would probably make sense to create a OpenRemote protocol for it, instead the HTTP and rules. That would make things much easier.
Jan 31
Fredrik Dahlberg says:
That would be great!!! I'm not a programmer so I can't contribute when it comes...That would be great!!!
I'm not a programmer so I can't contribute when it comes to developing a new protocol. But if you need any help with testing I'm more than willing to do my part. I guess you know that both the XBMC JSON-RPC API v2 and the HTTP API in the current version of XBMC are deprecated and that it is XBMC JSON-RPC API v3 that will be used in the upcoming version of XBMC.
Jan 31
Marcus Redeker says:
Yes, I read about on the xbmc wiki. I will put this on my list but it will proba...Yes, I read about on the xbmc wiki.
I will put this on my list but it will probably be more towards the end
Jan 31
Fredrik Dahlberg says:
That's fine with me as long as you put it in your short list. But seriously spe...That's fine with me as long as you put it in your short list.
But seriously speaking... I'm fine with using telnet within the foreseeable future. But I would really appreciate if you post a note on the forum when you have extended the functionality of the rule engine. Talking about lists... I understand it's hard for you to publish a real roadmap with dates since you guys don't do this for a living. But I think it would be really informative for a lot of people if you could post a simplified roadmap on the OR site that just shows what new features you are planning to implement and in what order they will be implemented. Last but not least, thanks again for putting in all this hard work and sharing it with "needy" people like me. 
Mar 18
Don Schmeling says:
This was a few months ago but I have been playing with this as well, I used a ba...This was a few months ago but I have been playing with this as well, I used a batch command to send the player command to both players at the same time. Works great!
Apr 13
Marcus Redeker says:
No complete XBMC protocol yet, but I improved the HTTP protocol to support HTTP ...No complete XBMC protocol yet, but I improved the HTTP protocol to support HTTP Post and JSON.
More infos here: http://www.openremote.org/display/forums/IP+device+with+JSON+interface
With some dummy commands and rule support we might be able to integrate XBMC this way already.
Apr 24
Marcus Redeker says:
Based on the latest HTTP protocol (see my other post in this thread from April 1...Based on the latest HTTP protocol (see my other post in this thread from April 13th), I played a little bit with rules and virtual commands and was able to realize the function the original post was about
I have attached the configuration to this answer.
openremote.zip