[OBSOLETE] Kodi/XBMC Callback Endpoint for Light Control

…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.

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…

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.

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.

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.

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…

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 =)

Just tested, working great now. Thanks!

Very cool idea! Once I finish setting up my studio I will give it a try.

I also just swapped over to the newer addon “Kodi Callbacks” as it seems to be a continuation of callbacks 2 that is actively under development. With that I am now using modified python scripts to only trigger light changes for movies or TV shows (to prevent odd behavior with TVTunes or music files). I am pointing Kodi Callbacks with %mt as a parameter to a python file that looks like this:

import sys
import requests

if sys.argv[1] == 'movie' or sys.argv[1] == 'tv':
	requests.get('https://graph.api.smartthings.com/api/token/XXX/smartapps/installations/XXX/play')

I’m in the process of writing a “HowTo” to tie CinemaVision and SmartThings together using this SmartApp…

Their guide section on the site is not visible at the moment to the public, but once I get done it will have everything needed to link lighting control into the Home Theater…

How would this work with rooms that have lighting automated base on say motion sensors?

can this be used with rule builder?

For motion automation: I assume you would want to disable the motion automation when playing movies. This app will not do that on its own, but you could make that happen with RuleMachine pretty easily. See next answer…

Rule Machine: You can integrate this with rule machine pretty easily using a virtual switch. Basically create a virtual switch (lets call it movie_playing). Have this app turn on that switch on playback, then have rule machine do whatever you want from the event triggers of that virtual switch (like: “when movie_playing turned on disable motion”)

UPDATE: Merged the parent/child app into main, it is now the only version. Also modified the code a bit to send straight “on” command to dimmers when a setlevel command would set them to exactly their previous state. This allows the native “fade up” on some dimmer switches to work correctly on a restore command. Still no know workaround for fading between levels =(. Updated the main post with new instructions as well.

In short: Grab new version if you have GE or similar dimmer switches and use the “restore last level” command.

1 Like

Could you do a youtube video guide doing the all process from smartthing to cv.
Thanks

When you will have the guide for cinema vision and smartthings. Im interested on it.

Hi. This SmartApp has changed since I started the guide, so I will need to revise the guide first.

I plan on providing a link to the guide once it is complete and the CinemaVision.tv site has made the guides public.

That shouldn’t be too long.

Thanks @Synthesis, You have worked more with CinemaVision than I have. I also am headed out of town and wont be able to make a guide for awhile.

@sraptor - In the mean time you should be able to piece together the basics of calling a URL in CV from their documentation: http://forum.kodi.tv/showthread.php?tid=231881&pid=2050438#pid2050438
Just use the http:// command in a cvaction file to call the URLs provided by this app.

This is the guide as I have posted it. I lost all of the formatting in the copy and paste, but it isn’t 100% complete either.
It will get you where you want to go, and eventually I’ll have images embedded in it.

Let me know if you have any questions. :slightly_smiling:

Basic Control Instructions

1. Install the Kodi/XBMC Callback Endpoint for Light Control SmartApp within the SmartThings IDE.

a. Visit the GitHub repository, located here.    
i. The KodiPlaybackControls SmartApp is the Parent application, and needs to be installed within the SmartThings IDE as a new SmartApp. This SmartApp must be saved and published.
ii. KodiPlaybackControlsLightGroup SmartApp is the Child application. This SmartApp needs to be installed within the SmartThings IDE as a new SmartApp. Do NOT publish this app.     
b. Open the SmartThings IDE in a new browser window or tab, and sign in with your SmartThings account.
c. Click My SmartApps at the top.
d. On the right side of the IDE, click the green +New SmartApp button
e. In the New SmartApp window, click From Code at the top, and paste the code from KodiPlaybackControls.groovy into this window.
f. Click Save at the top, and then click Publish and select For me from the dropdown.
g. Repeat steps c through f using the KodiPlaybackControlsLightGroup.groovy, but do NOT Publish this SmartApp.
h. For support and discussion of this SmartApp, you can visit the SmartThings Community page here. 

2.  On your iDevice or Android phone or tablet, open the SmartThings application.

a. Under the application menu, choose Connect New Device
b. Select SmartApps from the Marketplace
c. Scroll down and select + My Apps
d. Find the KODI Callback Endpoint SmartApp and select it
e. Set a Label for this Instance
f.  To make the app only run in a specific mode, you can set the Only run or the Never run functions to limit the function of the app. 
g. Select New Light Control Group, and on the new page, create a new Label for this Group (example: Theater Room Lamps)
h. Under Lights to Control, tap on the Which Switches section and select the switches that you want this light group to control. Once you have selected all of the switches you want in this group, click Done.
i.  In the Level to set Lights to section, set your light levels for the various functions.
     i. Please note that the SmartThings system does not easily provide a “Dim down” or “Dim up” to level. Light levels will set instantly on most Z-Wave or Zigbee hardware.
     ii. For lights that do not dim, any number lower than 100 will equate to “Off” for the device. Setting the number to 101 will attempt to restore the lights to their last reported level when that SmartApp function URL is called.
j.  If you have any custom functions within Kodi or CinemaVision that you would like implement for controlling this light group, you can set the level for the Custom Event 1 or 2
k. Click Done.

3. In the SmartApp that you have installed and set, you can view the URL for each action event (playback, pause, resume, stop, custom) by tapping on the View URLs section at the bottom. To use these URLs within CinemaVision, you will need to copy them from within SmartThings and paste them into .cvaction files in the Actions folder within the CinemaVision directory structure. I find that copying and pasting them into an email to myself is the simplest way to get the URL. 

4. Open your favorite text editor and create a new text file.

a. Paste the URL into this new text file.
b. Save the file to your CinemaVision Actions folder with the file extension cvaction and a descriptive name explaining what it does. (Example: lights-dim-on-playback.cvaction)

5. Open Kodi and launch the CinemaVision addon from the Programs menu (The Settings -> Addons menu will work as well, if you do not have a Programs option available)

a. When the CinemaVision Sequence Editor has opened, use the left or right arrow keys to move to the position you want to dim or turn off the lights, and select Add:Actions from the menu by using the up or down arrow keys and pressing enter on the selection.
b. Arrow up to the Edit button on your newly created Action item and press enter
c. Select the Action file path, and browse to your Actions folder.
d. Find and select the action file you want to embed here. (Example: lights-dim-on-playback.cvaction)
e. Press the Test button to confirm your URL works (the light group you have programmed into the SmartApp will change to the setting you have specified when you do this), and then hit the backspace key one time to return to the main sequence editor. 
f. Select the Rename button for the Action item, and set a name (Example: Dim lights before movie)
g, Repeat Step 5, sections a through f to set the Stop Action item at the end of the CinemaVision Sequence, being sure to select your stop.cvaction

To set Pause and Resume functions within CinemaVision, go to the Add-ons menu under Settings in Kodi and locate the CinemaVision add-on. Click Configure, and browse to the Actions menu. Configure the file paths to the Pause.cvaction and Resume.cvaction for each respective menu item. You can also configure a specific action for when the Sequence is aborted.

Is everyone working with the "Samsung SmartThings Hub’? Are there other hubs such as the Vera or Leviton Vizia RF that this app could work with?