SmartThings Community

[Release] Kodi/XBMC Callback Endpoint for Light Control

smartapp_av

(Adam E) #45

Yup, that is what I meant. Each install of the application only supports 4 URLs (events) currently.


(The Viking AKA "Holy Crap You're a Giant!") #46

Ok. Some things I am seeing…
When running the URLs directly or within CinemaVision and Callbacks, they work.
They don’t dim the lights gradually. Instead they wait three seconds (the default time) and then just setLevel.

Otherwise, this operates exactly as I was hoping it would, allowing multiple scripted events to occur within CinemaVision by allowing individual light groups within each parent app to react when a URL is triggered.

Is it wrong to say I love you? lol


(Adam E) #47

Noticing the same thing on my real dimmers (why I was worried about testing with virtual dimmers). I think the ramp rate (fade time) is a configuration item in the switch itself. I am going to test that some more, but for now it looks tough to really “fix”.

I am also going to look at adding custom callback commands to the app so you can add a “trailers” setting or whatever you want.

Probably more progress tomorrow. Going to hold off on fully releasing this version until then.


(The Viking AKA "Holy Crap You're a Giant!") #48

I found a pause/resume function buried in CinemaVision…
It looks like I can bypass CallBacks entirely at this point, as CinemaVision will call an “Action” as part of its scripting.

Actions in CinemaVision are text files with the extension “.cvaction” that can do http get/put requests, run commands against other systems in the home or even against Kodi itself.


(Adam E) #49

Awesome! Do CinemaVision events only fire when playing files in CinemaVision “mode”? Will they still trigger for a file played directly?

CV looks good for movie library, but wondering about TV shows. Those seem to be better just played directly without intro…


(The Viking AKA "Holy Crap You're a Giant!") #50

They do not fire in normal playback. Only in CinemaVision modes.

Callback will still be needed for some playback events, though I will likely not do auto-dimming for those in my particular use case.

Having scripts in both Callback and in CV would cause issues, though fixing that would require disabling the Callback addon or some programming in CV and/or Callback to resolve conflicts.

CV is able to run commands as part of its sequence of events, so you could use a command to disable Callback prior to the first playback event, and then re-enable after the sequence has completed.

To check out a VERY rough example of CinemaVision on my home PC, hit this Youtube video.

I had trouble recording on my actual HTPC, and I wanted to put a sample together showing what things looked like, so I did a rough install on my main gaming system and then captured the sequence.
Missing from this are: 10+ minutes of Slideshow (only 60 seconds shown for a brief example), trailers, a couple of short films near the beginning for “Courtesy” and “Snacks”, and then a very bad edit at the end where my PC went back to the main menu for a couple of seconds before loading the film that I had to trim out.

The event sequence file looks like the below, The “Type” in each section describes what the sequence will perform, and in the case of Videos, the “vtype” describes the category of the video being played. A category links to a folder on the HTPC and plays a video from within the linked folder. EG: “Short Film” looks at F:\Cinemavision\Video Bumpers\Short Film

{
“items”: [
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “trivia.intro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “trivia”,
“name”: “”,
“settings”: {
“duration”: 1
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “trivia.outro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “action”,
“name”: “”,
“settings”: {
“file”: “F:\CinemaVision\Actions\Initial Dim.cvaction”
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “courtesy”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “short.film”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “theater.intro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “trailers.intro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “action”,
“name”: “”,
“settings”: {
“file”: “F:\CinemaVision\Actions\Secondary Dim.cvaction”
}
},
{
“enabled”: true,
“type”: “trailer”,
“name”: “”,
“settings”: {
“count”: 1
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “trailers.outro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “action”,
“name”: “”,
“settings”: {
“file”: “F:\CinemaVision\Actions\Final Dim.cvaction”
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “short.film”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “audioformat”,
“name”: “”,
“settings”: {
“volume”: 50,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “countdown”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “feature”,
“name”: “”,
“settings”: {}
},
{
“enabled”: true,
“type”: “action”,
“name”: “”,
“settings”: {
“file”: “F:\CinemaVision\Actions\Stop.cvaction”
}
},
{
“enabled”: false,
“type”: “command”,
“name”: “”,
“settings”: {
“command”: “skip”,
“condition”: “feature.queue=empty”,
“arg”: 6
}
},
{
“enabled”: false,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “intermission”,
“play3D”: true
}
},
{
“enabled”: false,
“type”: “trivia”,
“name”: “”,
“settings”: {}
},
{
“enabled”: false,
“type”: “audioformat”,
“name”: “”,
“settings”: {
“play3D”: true
}
},
{
“enabled”: false,
“type”: “feature”,
“name”: “”,
“settings”: {}
},
{
“enabled”: false,
“type”: “command”,
“name”: “”,
“settings”: {
“command”: “back”,
“condition”: “feature.queue=full”,
“arg”: 4
}
},
{
“enabled”: false,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “feature.outro”,
“play3D”: true
}
},
{
“enabled”: true,
“type”: “video”,
“name”: “”,
“settings”: {
“random”: true,
“count”: 1,
“vtype”: “theater.outro”,
“play3D”: true
}
}
],
“version”: 1
}


(Adam E) #51

New “Beta2” code is now in the original post, see there for details:


(The Viking AKA "Holy Crap You're a Giant!") #52

I have used the new version for the last day or two, testing multiple sequences in CinemaVision, as well as working in Callbacks on a separate MediaPC I put together for the bedroom… The wife absolutely loves it, and I’m getting ready to put together a movie night for friends/family so we can all sit and experience the fun.

Thank you so much @thildemar for your hard work on this.


(Darren) #53

So, tried to set up the beta yesterday. maybe not the best idea with the updates and whatnot pushing out. When I attempt to add lighting groups on Android, the SmartThings app crashes. When I attempt to add on iOS, I get the spinning animation, then nothing happens.

…I also can’t delete the SmartApp in the IDE and attempt to start over (get a 500 error), so would guess that this is more the environment and not the code, but thought I’d mention just in case. Have a ticket in for the 500 error; DB updates happening today, so maybe by this evening…


(Adam E) #54

Make sure you have BOTH apps installed with the new code. The main app needs oauth enabled and published. The 2nd app (LightGroup) just needs added and saved.

What you are describing sounds like the light group code may not have been added properly…

EDIT: On 2nd look I found something on the github code that was out of date. Try adding replacing the code and attempt again. Sorry =/


(Darren) #55

I’ve been doing a lot with Rule Machine, so familiar with parent-child apps and publishing. I’ve nuked the light group code and re-added it, same thing (just tried it again to be sure), crashes when clicking New Lighting Group. The app does appear in my installed SmartApps, but obviously there’s no lighting groups.

EDIT: Saw your comment about the code–NOW it works. :slight_smile: Thanks!


(Adam E) #56

Awesome, let me know how it goes. Hopefully I will be installing all of my theater gear this weekend so I can start testing this code in its “natural habitat” and not just the bedroom instance of Kodi =)


(Darren) #57

…ok new problem. Everything’s set up, oAuth is enabled, but getting “invalid_token” when attempting to trigger the URL. It’s strange, as what’s in the URLs matches the accessToken that I see when I look at the SmartApp in the IDE.


(Adam E) #58

Sigh, SmartThings does not want to make this easy on us. Have you tried removing and re-adding the instance? Hopefully get it to create a new ID and token…


(Darren) #59

Yep, does same thing when I remove the smartapp and try to recreate it. The token listed in the “installed smartapp” doesn’t match the two oAuth values when I go look at the smartapp in my smartapps, though I am not sure that that matters.


(Adam E) #60

Token not matching is expected, IDE/Simulator will use a different one.

I just had some oddity with my install trying to replicate this. I removed everything (even removed apps from IDE) re-added them from the github code and now all is well on mine. Never got the error you are getting, but triggers were not working correctly for a minute. Might need to be re-added in IDE as sometimes oauth is finicky.


(Darren) #61

So, delete the app(s) from IDE, then re-paste the code from github? I’ll give that a shot, though that’s where I was getting 500 errors yesterday…EDIT: but not today.

EDIT 2: OK, working now (mostly). Group 1 turned off. Group 2 did not appear to dim, but I’ll play with that later, as things are a bit slow in general for me.


(Adam E) #62

Yup found another bug, now fixed. IDE seems to have like half saved my code, really strange as much of this was working…

Keep reporting anything you see and I’ll get it tracked down.

Make sure you have v0.022 on both files…


(Adam E) #63

Got CinemaVision Configured. Using it and callbacks so I can play media without all the intro when I want. Used this as a CV action to disable callbacks at start of script and then re-enabled it in the abort action so events don’t trigger twice:

http://127.0.0.1:8082/jsonrpc POST:{"jsonrpc": "2.0", "method": "Addons.SetAddonEnabled", "params": { "addonid": "script.xbmc.callbacks2", "enabled": false }, "id": 1}

Just make sure HTTP control is enabled and not password protected on Kodi and adjust port as needed =)


(Darren) #64

Just tested, working great now. Thanks!