I just got into using openHAB, and after getting the onkyo addon to work, mqtt, and some other small things, I wanted to try XBMC, so I could set up some rules.
First thing I did was to use an example someone else already had made (sorry closed the page and now I cant find it again)
Items
String XbmcLiving_State "Living State [%s]" { xbmc="<[#bedroom|Player.State]" }
String XbmcLiving_Title "Living Title [%s]" { xbmc="<[#bedroom|Player.Title]" }
String XbmcLiving_ShowTitle "Living Show [%s]" { xbmc="<[#bedroom|Player.ShowTitle]" }
Switch XbmcLiving_PlayPause "Living Play/Pause" { xbmc=">[#bedroom|Player.PlayPause]", autoupdate="false" }
Switch XbmcLiving_Stop "Living Stop" { xbmc=">[#bedroom|Player.Stop]", autoupdate="false" }
String XbmcLiving_Notify "Living Notify [%s]" { xbmc="<[#bedroom|GUI.ShowNotification]", autoupdate="false" }
Rules
rule "Adjust living room lighting when XBMC starts/stops"
when
Item XbmcLiving_State changed
then
var String state = XbmcLiving_State.state.toString()
switch (state.lowerCase) {
case "play" : Scene_Living.sendCommand(5)
case "pause" : Scene_Living.sendCommand(1)
case "stop" : Scene_Living.sendCommand(1)
}
end
Sitemap
sitemap dolphin label="Main Menu"
{
Frame label="XBMC"
{
Text item=XbmcLiving_State label="State [%s]"
Text item=XbmcLiving_Title label="Title [%s]" visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
Text item=XbmcLiving_ShowTitle label="Show [%s]" visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
Switch item=XbmcLiving_PlayPause label="Play" icon="play" mappings=[ON="Play"] visibility=[XbmcLiving_State==Pause]
Switch item=XbmcLiving_PlayPause label="Pause" icon="pause" mappings=[ON="Pause"] visibility=[XbmcLiving_State==Play]
Switch item=XbmcLiving_Stop label="Stop" mappings=[ON="Stop"] visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
}
}
It works for a short moment when I start the player, or put it to pause, and back to playing again, and in the log I found this.
2015-10-21 22:35:08 - XbmcLiving_State state updated to Play
2015-10-21 22:36:52 - XbmcLiving_State state updated to Stop
2015-10-21 22:36:52 - XbmcLiving_Title state updated to
2015-10-21 22:36:52 - XbmcLiving_ShowTitle state updated to
It never detect the title or show, and the player is still playing, but somehow it got detected as having stopped.
Anyone able to see if there is an error in the code I used? I guess the config for the player is correct, since it does notice the state change.