Jump to content

Server- Home Automation (HA) Plugin


Xzener

Recommended Posts

Vidman

Yes but then you also need to build an interface to expose that data... I'm no programmer so that might be trival as well... I just thought having a text field to enter the scene number would be allot simpler .. And as the user will need to build a scene for each event they can make a note of the scene number when they make it

Edited by Vidman
Link to comment
Share on other sites

Vicpa

Hi,

 

Here were are designing for Chef :) Awesome progress Chef.!!

I agree with Vidman, first pass keep it simple. I have been looking at the Kodi Eventstate Vera plugin. I like the approach, As I understand  It just reports "player status events". That can be then used in a vera scene.  That keeps all the logic separated Vera stuff on the vera and Chef's work just in effect broadcasting the device and events. Long term it would also make it easier for other HA controllers to leverage.

I haven't written a plugin for Vera yet, Vidman Techywarrior have you guys ? I am willing to take a swing at it.

 

What are your thoughts? Ultimately it is up to Chef, he is doing all the heavy lifting :)

Edited by Vicpa
Link to comment
Share on other sites

techywarrior

Yes but then you also need to build an interface to expose that data... I'm no programmer so that might be trival as well... I just thought having a text field to enter the scene number would be allot simpler .. And as the user will need to build a scene for each event they can make a note of the scene number when they make it

It's really not that difficult.

 

Yea I was going to suggest something like the xbmc plugin... But that would require a media browser plugin for the Vera as well , so yea if that's up your alley.,...

 

You'd have to build two Vera plugins :( since they made changes in UI7 that requires all plugins to be tweaked/rebuilt there would have to be a UI7 plugin as well as a legacy UI4/5/6 plugin (since a LOT of people are still on UI5 because it's still the most stable).

 

Lets see what Chef has and then we can decide if it's worth doing it the other way. I think we may end up having similar problems that Chef ran into with MB not having proper events that can be hooked into. I'd need to talk to him more and see exactly what he was able to find. I don't think Chef's solution is perfect but it's definitely a good start and we can play around with it before making it an official plugin.

Link to comment
Share on other sites

chef

Once my Vera controller arrives on Thursday, I will look at the ui stuff. It probably uses JSON which is perfect since we already have the best serializers built in to MediaBrowser.

 

Once we see the Api for Vera, we can add functionality to the plugin DLL, in the form of drop down lists to select scenes.

 

But I am having some issues with the plugin side of things.

It is a lot of trail and error because the github wiki isn't complete.

 

Maybe after this is will be able to help finish it.

Link to comment
Share on other sites

techywarrior

It probably uses JSON which is perfect since we already have the best serializers built in to MediaBrowser.

 It does use JSON for it's responses, although you could request alternate formats (not that you'd want to)

 

 

But I am having some issues with the plugin side of things.

It is a lot of trail and error because the github wiki isn't complete.

The MB plugin Wiki or the Vera Wiki?

Link to comment
Share on other sites

chef

The mb plugin wiki, I am really terrible at jquery, and I am having issues loading the html.

I am close.

 

EDIT: Finally a Plugin Page! And it is showing a configurable HTML page under settings in the plugin repository.

 

Note for anyone who is building plugins. The HTML page works if it is an embedded Resource.

 

Ohhh, it even has a button on it.

Edited by chef
  • Like 2
Link to comment
Share on other sites

Xzener

Great job Chef. Can't wait to try what you've been working on. I think I'm going to build a Raspberry Pi Zwave controller. My Vera Lite makes my network unstable.

Link to comment
Share on other sites

techywarrior

What UI are you using on the Vera? My zwave network isn't that large but I've never experienced stability issues due to the controller spamming the network or anything like that.

Link to comment
Share on other sites

Xzener

Latest and (not so) greatest. The issue isn't Vera device connectivity, it how other devises behave. For instance, my sons Xbox One was connecting to a rogue default gateway. It has happened to both our Xbones, my wife's laptop, my WP8.1, and the wireless network becomes very slow. As soon as I disconnect the power cord of my Vera, everything works again normally.

Link to comment
Share on other sites

techywarrior

That's pretty weird. After the debacle that was UI6 I am not upgrading from 5 unless they rip it out of my unit :) at least I already know all the quirks and work arounds for it.

Link to comment
Share on other sites

chef

AM am I pissed! Amazon screwed the pooch and didn't send my Vera Unit yesterday.

 

They sent a late email explaining there was a problem with my order and there was an oversight. I had to re-order my unit, and it should show up on March 11th.

 

In the mean time, any html guys who want to layout the Vera plugin dashboard interface can do so.

 

Don't worry about wiring it up with javascript, I got that covered (after a ridiculously long amount of time learning it... half hazard).

 

The page basically needs:

 

- Header ("Vera Smart Home Control") 

- List (just an outline of the list, we can add list items later with Javascript)

- Two Buttons (save/cancel)

- Some kind of image which we use as the plugin/app icon

 

If no one wants to do it, I will get to it soon, but this would move things along.

Link to comment
Share on other sites

techywarrior

Are you auto detecting the Vera? If not you should probably ask for the IP so you can poll the Vera for the devices and scenes. (and save it to talk to it from the other program). I'm not sure how you want to handle the options but scenes and device on/off have different commands so you may want to have a list of scenes and then a separate list of devices with on/off. I think most people will run a scene because they have a bunch of things that want to happen so not a big deal if the first release only has scene support.

 

I can't do graphics but this is basically the HTML you need.

<div class="content-primary">div><h1 class="pageTitle" style="display: inline-block;">Vera Smart Home Control</h1></div>

<form id="vshcConfigurationForm">
<ul class="ulForm ui-listview" data-role="listview">
<li class="ui-li-static ui-body-inherit ui-first-child">
<label for="veraScene">Scene:</label>
<select name="veraScene" id="veraScene">
<option value=""></option>
</select>
</li>
<li class="ui-li-static ui-body-inherit ui-last-child">
<button class=" ui-btn ui-btn-b ui-shadow ui-corner-all" type="submit" data-theme="b">Save</button>
<button class=" ui-btn ui-shadow ui-corner-all" onclick=" history.back(); " type="button">Cancel</button>
</li>
</ul>
</form>

</div>

Sucks that your order got screwed up :(

Link to comment
Share on other sites

chef

TO be honest, I finally got the plugin template working with some help from ebr. I may have to wait to perfect the scene detection when my device shows up.

 

 We now have a working Plugin template which we can create commands for the listener.exe.

 

The next part will be, detecting scenes from vera, and loading the options into the plugin, which will feed the listener.

 

Should be cool.

 

The page looks good, there was one <div> mistake.

 

This will be a good start. I'll add another list, which will give us a list of clients current connected to media browser.

 

Then the second list will be a list of scenes. the save button will put the information into an xml, and the listener will sort out the rest.

Edited by chef
  • Like 1
Link to comment
Share on other sites

chef

Hey Techy and Xzener and pretty much anyone else to maybe able to help,

 

Here is the HTML for the plugin:


<!DOCTYPE html>

<html>
    
    <head>
        <title>Media Browser Vera Smart Home Control</title>     
    </head>
    <body style="height: 379px">




        <div class="content-primary">
            <div>
                <h1 class="pageTitle" style="display: inline-block;">Vera Smart Home Control</h1>
                <form id="vshcConfigurationForm">
                    <ul class="ulForm ui-listview" data-role="listview">
                        <li class="ui-li-static ui-body-inherit ui-first-child">
                            <label for="veraScene">Scene:</label>
                            <select name="veraScene" id="veraScene">
                                <option value=""></option>
                            </select>
                        </li>
                        <li class="ui-li-static ui-body-inherit ui-first-child">
                            <label for="clientName">Client:</label>
                            <select name="clientName" id="clientName">
                                <option value="Media Browser Theatre">Media Browser Theatre</option>
                                <option value="Media Browser Classic">Media Browser Classic</option>
                                <option value="Roku">Roku</option>
                                <option value="Dashboard">Dashboard</option>
                                <option selected></option>
                            </select>
                        </li>

                        <li class="ui-li-static ui-body-inherit ui-first-child">
                            <button class=" ui-btn ui-btn-b ui-shadow ui-corner-all" type="submit" data-theme="b">Add</button>
                            <div style="vertical-align:middle;">
                                <ul data-role="listview" data-inset="true" data-split-icon="delete" id="veraProfiles">
                                    <li><a href="">Represents a saved Profile 1</a><a href="#" data-icon="delete" class="btnDeletePropfile" id="Profile1" onclick="deleteProfile(id)"></a></li>
                                    <li><a href="">Represents a saved Profile 2</a><a href="#" data-icon="delete" class="btnDeletePropfile" id="Profile2"></a></li>
                                    <li><a href="">Represents a saved Profile 3</a><a href="#" data-icon="delete" class="btnDeletePropfile" id="Profile3"></a></li>
                                </ul>
                            </div>
                        </li>

                        <li class="ui-li-static ui-body-inherit ui-last-child">
                            <button class=" ui-btn ui-btn-b ui-shadow ui-corner-all" type="submit" data-theme="b">Save</button>
                            <button class=" ui-btn ui-shadow ui-corner-all" onclick=" history.back(); " type="button">Cancel</button>
                        </li>
                       
                        
                        

                    </ul>
                    
                </form>
            </div>
        </div>
        
        <script>
            
            function deleteProfile(id) {
                var myList = document.getElementById("veraProfiles");
                for (var i = 0; i < myList.length; i++) {
                    if (myList.innerText = id) {
                        alert(id);
                        myList.innerHTML = '';
                        Dashboard.hideLoadingMsg();
                    };
                };

            };

        </script>

    </body>
    
    
   


</html>
It looks like this in the server:

 

pluginTest.png

 

Not bad! but there are some issues. We have to wire up a couple things and i am having issues. You'll have to excuse the "Coffee, Tea, etc. I had to fill the list with something.

 

We also have to hardcore client names into the client drop down postbox, because there is no way to dynamically create properties in a .net class.

I had originally created a dictionary which worked, but the plugin will not serialize the dictionary.

 

perhaps snazy has a second to help?

 

 

1. we need to have the "Delete" button remove items from the list, using javascript.

2. The add button has to take strings from both dropdown-boxes and put the info into the list below

 

If you look at my code... it is just terrible. There is no intellesense to check my work, so I am literally flying by the seat of my pants here.

 

 

The XML that the Listener reader looks like this:

<?xml version="1.0"?>
<PluginConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  <DLNA>
    <PlaybackStarted>Test Play</PlaybackStarted>
    <PlaybackStopped>Test Stopped</PlaybackStopped>
    <PlaybackPaused>Test Paused</PlaybackPaused>
    <PlaybackUnpaused>Test UnPaused</PlaybackUnpaused>
  </DLNA>
  <Dashboard>
    <PlaybackStarted>Test Play</PlaybackStarted>
    <PlaybackStopped>Test Stopped</PlaybackStopped>
    <PlaybackPaused>Test Paused</PlaybackPaused>
    <PlaybackUnpaused>Test UnPaused</PlaybackUnpaused>
  </Dashboard>
</PluginConfiguration>
 
Just thought I have better show some work here.

 

The listener is working nicely, but the plugin stuff is going to be a real headache...

Edited by chef
Link to comment
Share on other sites

techywarrior

You just want the JS to remove the LI? Since the web client is built on jQuery we can use that instead of plain JavaScript. Here is some JS that will make the delete button remove the LI for the button you clicked.

$(document).ready(function(){
   $(".btnDeleteProfile").on("click",function(){
      $(this).parent().remove();
   }
});

With this you can remove the onclick on each of those buttons. The jQuery will attach itself to any button with the class btnDeleteProfile. The first line (the one with document ready) will only run the script to attach the event handler once the DOM is fully loaded and ready.

  • Like 1
Link to comment
Share on other sites

chef

I am getting good now! Techy what is an event to use in html to get the selectedText in a drop down box?

 

I have written the js to figure out the selected text, I just need to attach it to an event for when a client name is selected from the drop down box.

 

Would the "onChange" event work? Or is that to general of an event argument?

 

I have something to show here. It is close now.

 

Edit: I figured it out. You can call small strings of Java code conditions in the event in html.

Edited by chef
Link to comment
Share on other sites

techywarrior

I guess you got it already but you can do something like this:

$("#clientName").on("change",function() {
  var client_name = $(this).val();
});

That would make client_name the value of that select box as an example.

Link to comment
Share on other sites

Xzener

Looking good Chef.

 

Can you add simply "Device" also... I do t have scenes, just devices to turn on/off.

Link to comment
Share on other sites

techywarrior

Looking good Chef.

 

Can you add simply "Device" also... I do t have scenes, just devices to turn on/off.

You may want to just create a scene for now that turns that one device on/off. And then if Chef does add devices you can switch it. I suspect 90%+ of people who would use this have a scene they will need/want to run.

Link to comment
Share on other sites

chef

If you want to check out the first stages of the Plugin interface here it is here:

 

https://dl.dropboxusercontent.com/u/46151346/New%20Test11.rar

 

Place the DLL into your Plugins folder in the server.

 

Don't expect to much, if it weren't for techywarrior and ebr, I think I might have destroyed my computer learning javascript and media browser plugins, and then probably the entire world!.

 

The DLL is only a working UI at the moment. it still has to be wired up in places, and also it has to connect with the "listener".

 

It also is going to make calls to the Vera Api to fill in the scene selection dropdowns on the client configuration pages.

 

Right now only: "MBC", and "Dashboard" actually go anywhere, but you'll be able to see where the plugin is going by this example.

 

Thanks for you help so far techy! you've got a talent for web coding.

Edited by chef
  • Like 1
Link to comment
Share on other sites

wraslor

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.

Link to comment
Share on other sites

Xzener

I guess it depends on your receiver. Is it capable of being controlled via Zwave??

Edited by Xzener
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...