Jump to content

Vera Home Automation Plugin (Emby Vera)


chef

Recommended Posts

chef

@@Xzener !!

 

I am using Xbox One so it doesn't have video backdrops or intros, and I can't test this. But, I believe that this will stop both of the mentioned plugins from triggering scenes :)

 

https://dl.dropboxusercontent.com/u/46151346/SampleProject/SampleProject/bin/Debug/Vera%20Smart%20Home%20Automation.zip

  • Like 1
Link to comment
Share on other sites

Xzener

I'm not there yet... Although, functionality like that sounds amazing.

 

What I am referring too is the issue where you browse to a movie with a video backdrop. When I press play, the "Off" command is not sent. I have to close and restart the client to get the plugin functionality back.

Link to comment
Share on other sites

Xzener

@@Xzener !!

 

I am using Xbox One so it doesn't have video backdrops or intros, and I can't test this. But, I believe that this will stop both of the mentioned plugins from triggering scenes :)

 

That fixed it. Nice work Chef!

Link to comment
Share on other sites

Xzener

Chef,

 

Is there an event for Emby clients starting?? For example... I walk into the room, manually turn on the lights. I start Emby Classic (or was it Emby for WMC). The lights dim from full to half because Emby started.

 

Is that possible??

Link to comment
Share on other sites

Xzener

That fixed it. Nice work Chef!

I spoke too soon. Initially, the commands are sent correctly. I can browse, start a movie, stop it, all the while, the lights are responding correctly. But, if I browse to another movie, start it, the commands are not being sent. Again I have to restart the client.

 

Functionality only works for the first two commands, off then on. After that, Vera isn't sending commands.

Edited by Xzener
Link to comment
Share on other sites

chef

I spoke too soon. Initially, the commands are sent correctly. I can browse, start a movie, stop it, all the while, the lights are responding correctly. But, if I browse to another movie, start it, the commands are not being sent. Again I have to restart the client.

 

Functionality only works for the first two commands, off then on. After that, Vera isn't sending commands.

Okay, I will see what is up.

 

Right! I see, we have to set the tick monitor back to zero.

 

One second.

Edited by chef
Link to comment
Share on other sites

chef

Xzener,

 

  I was checking to see if the scene ran or not, and wasn't updating the JSON from Vera when I was checking. Sorry about that. It's fixed.

 

 

https://dl.dropboxusercontent.com/u/46151346/SampleProject/SampleProject/bin/Debug/Vera%20Smart%20Home%20Automation.zip

 

 

 

Chef,

Is there an event for Emby clients starting?? For example... I walk into the room, manually turn on the lights. I start Emby Classic (or was it Emby for WMC). The lights dim from full to half because Emby started.

Is that possible??

 

 

I believe that is what AgileHumor was asking about. Although this would mean looking at the other end of things. From the Vera Unit.

 

It is possible. I just learned how to write JQuery.

So, I could learn luua code next.

I could technically write three languages then. of coarse sometimes it's half hazard... lol :)

Edited by chef
Link to comment
Share on other sites

Xzener

Oops. This one is broken... Nothing is working.

 

Restarted Emby Server... Still only the first two commands working.

Edited by Xzener
Link to comment
Share on other sites

Vidman

Chef,

 

Is there an event for Emby clients starting?? For example... I walk into the room, manually turn on the lights. I start Emby Classic (or was it Emby for WMC). The lights dim from full to half because Emby started.

 

Is that possible??

Again I think all that is really needed here is to run a scene when a user has logged into the client, right? As emby server cannot tell when a client has started, but it does know when someone logs into it Edited by Vidman
Link to comment
Share on other sites

chef

Again I think all that is really needed here is to run a scene when a user has logged into the client, right? As emby server cannot tell when a client has started, but it does know when someone logs into it

 

Actually @@Vidman there is a way. It is how I am populating the Device lists in the plugin; with Session Started and Session Ended.

 

Also, User Authenticated is also an event we can take advantage of.

 

If you would like to have scenes attached to these events, I can do that.

 

I think we can tap even into scheduled tasks.

 

 

Yes, but in a specific room/client.

 

 

The best thing to do is look at each room as a Emby Device. So even if you use MBTheater one day in your Theater, or MBC the next, that computer will always trigger events the same.

 

We connect Vera Room/Scenes to emby Devices. 

 

At least that is how it is set up right now.

 

 

I will put the other events mentioned above into the Scene editing page for you guys.

Edited by chef
Link to comment
Share on other sites

techywarrior

No, it wouldn't need a Vera plugin at all (and absolutely no need to confine this to the Vera)...instead, open it to any HA (hundreds) software that can send a HTTP request (again, without authentication).  All that is needed is an UNAUTHENTICATED HTTP listener to trigger defined macros on MB.  It shouldn't be a security concern as the macros would be user defined.

 

Anyway, don't want to take away for what seems like a nice plugin.   The only scenario I see it working is those with a dedicated Theater room scenario...so not your typical mass market HA appeal.  

 

However, I would have suggested you provide just generic user customizable http commands to run against the Vera (no need to limit to just Vera HA) using this format:

http://<vera_ip_address>:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=<SceneNum>

For those looking for having Vera (or any HA) control MB, I suggest you look at VoxCommando which can "bridge" the two systems together by using VoxCommando's TCP event engine (can trigger from Vera). I have about 200 devices controlled by two Vera's and it's working well.

After all the work that the devs have done to add security to the server it would be terrible design decision to create a plugin that opens an unauthenticated HTTP listener.

 

On your other point. Creating a plugin that would require users to enter long commands strings isn't very user friendly. Perhaps that could be added as some sort of advanced option in the future. But if you look at other plugins as an example, none of them require you to manually type in commands or anything like that. :)

 

What Chef has created is a plugin that (once working 100%) is something that is simple to use and probably covers 99% of the usecases. Anyone can have their theater/living room automatically run scenes thru the Vera from Emby with little knowledge of the workings of either. Think about if a company setup your Vera/HA, or perhaps in this forum it would be more likely that someone setup a system for their parents/friends, but now that person could have Emby control something simply. (I don't think a lot of users would know how to create the command strings for generic HTTP requests for their HA systems)

Link to comment
Share on other sites

Vidman

Actually @@Vidman there is a way. It is how I am populating the Device lists in the plugin; with Session Started and Session Ended.

 

Also, User Authenticated is also an event we can take advantage of.

 

If you would like to have scenes attached to these events, I can do that.

 

I think we can tap even into scheduled tasks.

 

 

 

The best thing to do is look at each room as a Emby Device. So even if you use MBTheater one day in your Theater, or MBC the next, that computer will always trigger events the same.

 

We connect Vera Room/Scenes to emby Devices.

 

At least that is how it is set up right now.

 

 

I will put the other events mentioned above into the Scene editing page for you guys.

OK I stand corrected :) great work BTW chef!
Link to comment
Share on other sites

chef

I have added all three events to the client config page.

 

User authenticated

Session started

Session ended

 

I have read beginners lua code, and also the how to write a Vera plugin. So maybe... You'll be able to flick a light switch and enable your entire room.

  • Like 1
Link to comment
Share on other sites

techywarrior

Yes, Vera, and other HA controllers aren't using authentication that much but Emby is. Just because you "should" only send specific commands to the Emby plugin doesn't mean that it's ok to leave it unprotected.

 

To make a "universal" HA plugin you are passing a lot of complexity over to the user but you should never assume that the user knows what they are doing.

 

With the work Chef has done it wouldn't be that hard to create other HA plugins for other controllers. That's the path that should be followed. This would allow future updates to include tighter integration with the controller or other specific functionality that certain controllers have over others.

Link to comment
Share on other sites

Xzener

Xzener,

 

This seems to be working for me, when selecting movies in succession.

 

https://dl.dropboxusercontent.com/u/46151346/SampleProject/SampleProject/bin/Debug/Vera%20Smart%20Home%20Automation.zip

 

I like the "Refresh" button... I was going to mention I needed to refresh the browser to get the clients to show.

 

Unfortunately, your plugin is failing to see active clients and therefore broken. 

 

Just upgraded my Emby server to v3.0.5557.40000 just to let you know.

 

EDIT: Looking at the configuration file, its saving the active clients to the XML file. There also seems to be some residual functionality left over (I deleted the old config file). But its not working correctly, only giving random play/stop commands.

Edited by Xzener
Link to comment
Share on other sites

chef

Xzener,

 

I will post some here after my kids go to bed, but if you are experiencing that begaviour it is because the "currentAliveNetworkDevices" (or the emby device) are not full populated in the configuration before you attempt to attach scenes.

 

This is a problem with the event engine trying to keep updating the config xml file in real time.

 

If that even makes anything sense...

 

It isn't pretty at the moment, but try refreshing the web page until the device list is completely populated.

Link to comment
Share on other sites

Xzener

The "client" is not populating. The XML is magically listing them... But I never see, nor can I configure any clients. The plugin main menu is blank. Also, the Vera dashboard will not load.

Link to comment
Share on other sites

chef

@@Xzener

 

I am not sure exactly why, but when I add a new plugin version to the server, and then navigate to the configuration settings page, it never loads the Device Lists until I refresh either....

 

I know with jQuery you can implement different page loading events. Current we use "pagebeforeshow" to try and load all the device names into the config.

 

The thing is, that if you navigate to the config settings page and then refresh the browser - for the entire lifetime of the plugin, it will work exactly as expected.

 

We'll just have to do that for now.

 

1. Copy the DLL into plugins

2.Restart the server

3.Navigate to the plugin config page

4. Refresh the Browser

 

From that moment on, you'll be able to utilize the "Refresh" Button to refresh the list of Devices and not have to Refresh the whole browser page, until you update the plugin.

 

https://dl.dropboxusercontent.com/u/46151346/SampleProject/SampleProject/bin/Debug/Vera%20Smart%20Home%20Automation.zip

 

My apologies about the extra steps.

 

I try to write the Device Names to the XML auto-magically, but the page load is just not quite right in the config.

Edited by chef
Link to comment
Share on other sites

chef

 

Thank you for the links AgileHumor, they have already deemed quite useful.

Link to comment
Share on other sites

Xzener

Chef,

 

With the build posted... I still have to manually refresh the browser. Your button is not working (IE). Although, after refreshing, I configured the plugin. I can confirm  session start/stop, play and stop commands are working. This is the best build yet. Well done as always. I will test more before work tonight and report back.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...