Jump to content

Server- Home Automation (HA) Plugin


Xzener

Recommended Posts

Vidman

Are you able to monitor volume changes? What I am trying to find a way to do is when I adjust the volume of MB for it to pass that to the audio receiver and adjust the volume on there.

What client are you using
Link to comment
Share on other sites

Vidman

yea it works well for me....I can just use my TV remote to operate my tv , navigate kodi and control volume on my yamaha receiver all as if they are one device...so yea really well actually. I believe there maybe some support for WMC but not for MDT unfortunately

Link to comment
Share on other sites

chef

The configuration as a MediaBrowser plugin was really hard. But thanks to some great, and patient community members, I was able to finish the set up.

 

I learned quite a bit about web doing thanks!

 

The configuration is done and we can start working on incorporating the veralite API.

 

Which I am going to do over the next couple days.

 

By this time next week the home automation control should be working.

  • Like 1
Link to comment
Share on other sites

chef

Hey techs, I have a rather interesting question:

 

Have you ever started a process from a web based application before?

 

In vbscript, back in the day, you could use wscript shell, but I am a fried the old days are gone.

 

It seems like the server restarts itself, so I imagine it is possible.

 

I am going to set up the listener.exe with arguments to tell it to restart itself, and thus releasing the xml commands. I think that that is the best way to go about it.

Link to comment
Share on other sites

techywarrior

There are restrictions as to what you can do from the web client. JS can't really run a system command. That's what ActiveX was for and Flash really (among lots else obviously).

 

I'd recommend that you pass an API command to the server and have that do it.

Link to comment
Share on other sites

chef

Agreed. When a property change happens in the configuration, the plugin now raises it's own event, and handles the restart.

 

Cool.

Link to comment
Share on other sites

chef

Okay lets talk Vera for a moment. After setting it up for the first time about twenty minutes ago, I know something.

 

We should definitely build our HTTP strings based on Scenes, rather then specific devices.

 

There just isn't enough time to build an MB Plugin which creates scenes by device.

 

(and to be honest writing HTML5/Javascript is tricky for me coming from Visual Basic and not C#, and jQuery.mobile is beautiful but finicky, and making it work is like pulling each individual hair outta my head one at a time... yeah... like, did you know there are specific ways to load a secondary webpage with javascript embedded on it if you are using jQuery.Mobile... yeah... specific... :huh: 

 

So, build your scenes in the Vera Dashboard, and we'll import them to the Media Browser Dashboard Plugin configuration list-boxes to choose from (using the Vera API).

 

The HTTP request strings posted earlier in this thread, and also the links will make it much easier to get things rolling.

 

But, as it stands right now, (and this will need to change in the future), I can only code for one Media Browser Client at a time.

 

What does this mean?  

 

Currently if you Choose: Media Browser Classic in the configuration, then each Device running Media Browser Classic will trigger the specific scenes.

 

There is a way to fix this. We request Device information from the MediaBrowserApi to fill in the initial list to choose from (Argh...more javascript....).

 

We then make our list based on device IDs rather then client Names.

 

But, initially in order release something use-able, we'll have to make do.

 

That sound okay with you guys?

Edited by chef
Link to comment
Share on other sites

techywarrior

Sounds fine to me. On the device/scene item tho. I don't think anyone was suggesting that the plugin creates scenes itself. It was just an option for those who only wanted to turn on/off one light or something. I think it's much more likely people will run a scene (and if they don't then they can create a scene for that one device).

Link to comment
Share on other sites

Xzener

Will it be possible to differentiate which room the specific client is being used in?

Link to comment
Share on other sites

chef

Will it be possible to differentiate which room the specific client is being used in?

 

Yes, the device list will be create based on each device Id, which mean that you'll be able to match the scene you created for the room, and the cosponsoring devices events.

 

ie.: "{xzeners theater htpc}" :  "{playbackstarted}" : "{theatre light dim scene}"

Link to comment
Share on other sites

chef

@@techywarrior and @@Xzener

 

Guess what! I finally was able to build all the Event Listeners into the plugin!!

 

No need for external applications.  You guys are going to be very, very happy when you see the end product!

 

One DLL download, and Vera Home automations is completely it's own Media Browser Plugin! 

  • Like 3
Link to comment
Share on other sites

Xzener

Brilliant!! I was hoping you could integrate the listener into the plugin. Well done Chef, keep up the great work.

Link to comment
Share on other sites

chef

So if anyone ever read this far in this thread, you have to create a  a class in your plugin project which implements the IServerEntryPoint to attach Server Event Arguments.

 

Build a constructor, and pass it any of the interfaces you want to use (basically sessioninfos, usersinfos etc.).

 

One of the things that is missing from the Github explainations, but found only in plugin examples, is the fact that you have to pass an instance of the plugin in each class:

 

example:

   Public Shared Property Instance() As Plugin
        Get
            Return _mInstance
        End Get
        Private Set(value As Plugin)
            _mInstance = value
        End Set
    End Property

    Private Shared _mInstance As Plugin


And in the constructor you set the instance to "Me" (this is Visual Basic.Net):

 

In this example of the constructor I am settings the ISessionManager, which allows me to add Handlers to sessions events form the Server.

   Public Sub New(sM As ISessionManager)
        Instance = Me

        sessionManager = sM

        AddHandler sessionManager.PlaybackStart, AddressOf PlaybackStarted
        AddHandler sessionManager.PlaybackStopped, AddressOf PlaybackStopped
        AddHandler sessionManager.SessionStarted, AddressOf SessionHasStarted
        AddHandler sessionManager.SessionEnded, AddressOf SessionHasEnded
        AddHandler sessionManager.PlaybackProgress, AddressOf CurrentPlaybackProgress
    End Sub
Edited by chef
  • Like 1
Link to comment
Share on other sites

techywarrior

This is excellent news Chef. I am sure there are going to be a lot of happy Vera owners. And this could be one of those "cool" things to show off/talk about to get new users.

Link to comment
Share on other sites

chef

I was just wondering if someone could look at the MAC address for their Vera lite device.

 

It is really hard to locate it I. The network programatically because the device doesn't have a Host Name.

 

Apparently manufacturers use the same four digits in their MAC addresses for all their devices.

 

If this is true then your device should have the digits: "944A", and then we can locate the IP for the device from the MAC address.

Link to comment
Share on other sites

chef

In order to locate the Vera device on the net work, you have to use a web request to get acces to the Vera configuration file in the device.

 

That sound easy enough, except that without the IP address you don't know where it is.

 

So, I built an async out function to search the home network for IP address and request the config file from each address. The functikn returns 0 if the address is wrong, and returns a string.length is it is right. Then we have the IP address.

 

Only thing is that the async search still takes almost a minute to find the device, that is along time. We only have to search for it once and the. Save the address to our own config file, but still a minute is a minute.

 

The other option is to have the user input the IP address into a text box.

Link to comment
Share on other sites

techywarrior

At least initially I think having someone put in the IP address one time is not a big deal. The only problem is that I would imagine it is very possible that people would have their Vera using a dynamic IP address.

 

A minute seems like a very long time to find the IP though. How does MBC and other apps find the server IP so fast? Surely the same principle could be used to find the Vera?

Link to comment
Share on other sites

We use a UDP discovery mechanism.  I'm sure the Vera has one as well.  You just need to find out what it is.

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