Jump to content

Server- Home Automation (HA) Plugin


Recommended Posts

You going to ask for the login info and poll the MiOS server for the internal and external IP? Or did they tell you how to use UDP to find the controller?

They actually gave me a direct link to the locator function they are using in the detect_device.php.

 

I request that they might want to think about handling device detection internally UDP, instead of pinging an external site. I explained how MediaBrowser uses the phrase: "who is the Media Browser Server" to locate the machine with UDP broadcast.

 

Perhaps they might use something in the future, but I think they keep things externally because they want their users to have quick access to their Vera devices remotely. That is the system they came up with.

 

Good thing is that the new request for JSON returns way more information about the device.

Link to post
Share on other sites
techywarrior

Nice. And now that you have some sort of rapport with them you may be able to get more detailed help in the future. Their online help/wiki is pretty minimal.  

Link to post
Share on other sites

Nice. And now that you have some sort of rapport with them you may be able to get more detailed help in the future. Their online help/wiki is pretty minimal.

I am still having some issues with embedding pages with iframe.

 

I think it has to do with using the IP address variable in the middle of the http string.

 

Should be straight forward but my iframe is empty.

Link to post
Share on other sites

Each Plugin page looks starts out relativity the same. 

<!DOCTYPE html>

<html>
<head>
    <title>VeraDashboard</title>
</head>
<body>
    <div data-role="page" class="page type-interior pluginConfigurationPage VeraDashboardPage">
        <div class="content-primary">

            <h1 class="pageTitle" style="display: inline-block;">Vera Dashboard</h1>
            <form id="vshcVeraDashboardConfigurationForm">
                <ul class="ulForm ui-listview" data-role="listview">
                    <li>
                        <div id="dash">
                            <!--Not sure if it okay to have a div in a list item?? This is where the Vera dash board will show -->
                        </div>
                    </li>
                </ul>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        (function () {
            var pluginId = "5a7bb1a0-15d6-4af4-9b22-866cddf39547",
                tempConfig;

            function loadConfig(page) {
                ApiClient.getPluginConfiguration(pluginId).done(function (config) {

                    loadPageData(page, config);
                    tempConfig = config;
                    Dashboard.hideLoadingMsg;

                });
            };

            function loadPageData(page, config) {
                alert(config.InternalIP);
                // Here is the iframe to attach to the div named: "dash", what is the difference between ".dash" and "#dash"? 
                $("#dash").html('<iframe src="http://' + config.InternalIP + '/cmh/#Dashboard"></iframe>');
               
            };

            $('.VeraDeviceDashboard').on('pageinit', function (event) {
               
            }).on('pageshow', function (event) {
                var page = this;
                loadConfig(page);

            });

        });
    </script>
</body>
</html>

Not sure if I have to use .('refresh') after "$("#dash").html('<iframe src="http://' + config.InternalIP + '/cmh/#Dashboard"></iframe>')"? or if the "div" element can be refreshed.

Edited by chef
Link to post
Share on other sites
techywarrior

.dash means select elements with the class of "dash"

#dash means select elements with the id of "dash"

 

It's fine to have a DIV inside a LI. Is there a reason that you aren't just putting iframe there and then updating it's src attribute?

<div id="dash">
<iframe src="" />
</div>


<script>
function loadPageData(page, config) {
 $("#dash iframe").attr("src","http://"+config.InternalIP+"/cmh/#Dashboard">
}
</script>

But, your should have worked. Is the iframe even being added? You said you thought it was the variable that was causing the issue. I don't see anything by looking at it. But if you suspect that just remove the variable and see what is added.







Edited by techywarrior
Link to post
Share on other sites

And... I see the problem. I changed the page name, but didn't change the page name in the jquery event which initialize the page. Duh!

Link to post
Share on other sites

Hmmm. still broken. I wonder if it has to be an async call to load it. I think I have some reading to do.

Link to post
Share on other sites
techywarrior

Is your function being called on page load? Is the config.InternalIP value valid? Is the iframe being added to the DOM and just not seeing anything or is it not even being added?

Link to post
Share on other sites

it is being added to DOM because I used your example of added the attribute to the iframe instead of the entire line of html.

 

I have added the api call to load the plugin configuration for this page so the InteralIP var should be loaded, but for some reason "pageinit" event isn't being raised to trigger the code.

Link to post
Share on other sites
techywarrior

Instead of

$('.VeraDeviceDashboard').on('pageinit', function (event) {
               
            }).on('pageshow', function (event) {
                var page = this;
                loadConfig(page);

            });

        });

Can you try

$(document).on('pageshow', ".VeraDashboardPage", function () { 
    var page = this;
    loadConfig(page);
}); 

 Doesn't really make sense to load a function on init that just loads a function to run on pageshow.

  • Like 1
Link to post
Share on other sites
techywarrior

Yea, so that's the other problem. It doesn't look like the Vera UI handles being in a small window very well. Perhaps it would be better to just have a link that opens in a new window and have some text to tell people to click the link if they need to configure their Vera?

Link to post
Share on other sites
techywarrior

you have 463 important messages to read

lol, I was going to say the same thing.

 

Chef, aren't you glad Luke showed up to give you some important feedback/help on your plugin? :P

 

j/k Luke

  • Like 1
Link to post
Share on other sites

you have 463 important messages to read

 

Yeah, the auto organize doesn't like movies being in the monitored folder, so it throws exceptions. I made a crappy little mover program that just grabs all the media from my DL folder and movies it to auto-organize.

 

I gotta fix that sometime....

Link to post
Share on other sites

Yea, so that's the other problem. It doesn't look like the Vera UI handles being in a small window very well. Perhaps it would be better to just have a link that opens in a new window and have some text to tell people to click the link if they need to configure their Vera?

 

It's okay, there is a mobile version which it switches to when the screen shrinks. I think we can utilize that version of the page. Treat it like a mobile phone instead of a full web page.

Link to post
Share on other sites

The mobile version of the dash, a little better, but I think that sizing needs to be worked on definitely.

 

Untitled2.png

Link to post
Share on other sites

As you can see here, we are able to choose active clients to set Events to. Once you set the scene in Vera, with a particular client name, we just send HTTP Post commmands to the Vera Device, and the scene is triggered.

 

Untitled3.png

Link to post
Share on other sites
techywarrior

Cool. So, when you say "active clients", the client we want to use as the trigger must be active when we configure the plugin? It's going to save the client right? Wouldn't do a lot of good if we had to reconfigure it every time the client got disconnected from the server :)

 

Will need to see the rest of the plugin, but I am guessing that after you click "add" you can select a scene to trigger and other options?

 

Looks like it's getting close Chef. Nice work.

  • Like 1
Link to post
Share on other sites

Yes the client will have to be on. it saves the clients to the config xml (so far), it is set up to save all the scene http requests with the saved client name, so once you configure it it will be forever.

 

we're going to have to remember to code the ability to remove/reset options too.

 

When you add a client to the listview, that button takes you to another page which has several  dropdown list named after the media browser events. The drop down list will be populated with all the scenes you have created.

 

you'll just have to scroll the list untill you find the scene you want.

Edited by chef
Link to post
Share on other sites

this is interesting - i have the opposite of this.. i'm using my Vera to control my Harmony home hub. Never thought of it going the other way.

  • Like 1
Link to post
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...