New Homebridge Plug-in via MakerAPI

@dan.t is there any chance of getting buttons to work with this?

Pretty much the only thing I don't have working are these types of devices.

Thanks for all you do!

I have buttons working without the caveat you can’t do long presses.

I have this waiting in a commit, but I haven't submitted a pull request to Dan as people are having the issue with dimmers. I'm not sure it's good to add a new feature when there are unsolved issues.

You can submit the pull request, that shouldn't be an issue.

Done.

Andrew

1 Like

@dan.t Hi, I had another sync issue. The hub seemed to fine as shown on its web interface so I restarted Homebridge with the PM2 restart all command and it's working/syncing again just fine. Not sure what is causing this...trying to get you as many data points to help. The logs are also more populated now:

(node:5544) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:457) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:457) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(node:459) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:459) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(node:429) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:429) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(node:15697) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:15756) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(node:15756) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
[9/21/2019, 7:50:50 PM] [Hubitat hhm:0.2.17] GET ERROR:  { path: '/devices', method: 'GET' } '<!doctype html>\n' +
  '<html lang="en">\n' +
  '\n' +
  '<head>\n' +
  '    <meta charset="utf-8">\n' +
  '    <meta http-equiv="X-UA-Compatible" content="IE=edge">\n' +
  '    <meta name="description" content="">\n' +
  '    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">\n' +
  '    <title>Hubitat Starting Up</title>\n' +
  '    <meta name="mobile-web-app-capable" content="yes">\n' +
  '    <link rel="apple-touch-icon" sizes="180x180" href="/ui2/images/apple-touch-icon.png">\n' +
  '    <link rel="icon" type="image/png" sizes="32x32" href="/ui2/images/favicon-32x32.png">\n' +
  '    <link rel="icon" type="image/png" sizes="16x16" href="/ui2/images/favicon-16x16.png">\n' +
  '    <link rel="icon" sizes="192x192" href="/ui2/images/favicon.ico">\n' +
  '    <link rel="manifest" href="/ui2/images/site.webmanifest">\n' +
  '    <link rel="mask-icon" href="/ui2/images/safari-pinned-tab.svg" color="#5bbad5">\n' +
  '    <link rel="shortcut icon" href="/ui2/images/favicon.ico">\n' +
  '    <meta name="msapplication-TileColor" content="#da532c">\n' +
  '    <meta name="msapplication-config" content="/ui2/images/browserconfig.xml">\n' +
  '    <meta name="theme-color" content="#ffffff">\n' +
  '    <link rel="shortcut icon" href="/ui2/images/favicon.ico">\n' +
  '    <style>\n' +
  '        @font-face {\n' +
  "            font-family: 'Material Icons';\n" +
  '            font-style: normal;\n' +
  '            font-weight: 400;\n' +
  '            src: url(/ui2/css/fonts/MaterialIcons-Regular.eot);\n' +
  '            /* For IE6-8 */\n' +
  "            src: local('Material Icons'), local('MaterialIcons-Regular'), url(/ui2/css/fonts/MaterialIcons-Regular.woff2) format('woff2'), url(/ui2/css/fonts/MaterialIcons-Regular.woff) format('woff'), url(/ui2/css/fonts/MaterialIcons-Regular.ttf) format('truetype');\n" +
  '            font-display:block;\n' +
  '        }\n' +
  '        @font-face {\n' +
  "          font-family: 'hubitat';\n" +
  "          src:  url('/ui2/css/fonts/hubitat.eot?roox2j');\n" +
  "          src:  url('/ui2/css/fonts/hubitat.eot?roox2j#iefix') format('embedded-opentype'),\n" +
  "            url('/ui2/css/fonts/hubitat.woff2?roox2j') format('woff2'),\n" +
  "            url('/ui2/css/fonts/hubitat.ttf?roox2j') format('truetype'),\n" +
  "            url('/ui2/css/fonts/hubitat.woff?roox2j') format('woff'),\n" +
  "            url('/ui2/css/fonts/hubitat.svg?roox2j#hubitat') format('svg');\n" +
  '          font-weight: normal;\n' +
  '          font-style: normal;\n' +
  '          font-display: block;\n' +
  '        }\n' +
  '        html {\n' +
  '            -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape while allowing user zoom */\n' +
  '        }\n' +
  '    </style>\n' +
  '    <link rel="stylesheet" href="/ui2/css/jquery.dataTables.min.css">\n' +
  '    <link rel="stylesheet" href="/ui2/css/material.min.css">\n' +
  '    <link rel="stylesheet" href="/ui2/css/styles.min.css">\n' +
  '    <script src="/ui2/js/jquery-3.4.0.min.js "></script>\n' +
  '    <script type="text/javascript ">\n' +
  `        window.jQuery || document.write("<script src='/ui2/js/jquery-3.4.0.min.js'> <\\ / script > ");\n` +
  '    </script>\n' +
  '    <script src="/ui2/js/jquery.dataTables.min.js "></script>\n' +
  '    <script src="/ui2/js/material.min.js "></script>\n' +
  '    <script src="/ui2/js/hubitat.min.js"></script>\n' +
  '    <script src="/ui2/js/success-compiled.js"></script>\n' +
  '    <link rel="stylesheet" href="/ui2/css/sumoselect.min.css"/>\n' +
  '    <script src="/ui2/js/jquery.sumoselect.min.js"></script>\n' +
  '    <script src="/ui2/js/moment.min.js"></script>\n' +
  '    <script src="/ui2/js/vue.min.js"></script>\n' +
  '    <script src="/ui2/js/webcomponents-bundle.js"></script>\n' +
  '    <script src="/ui2/js/vue-hub.min.js"></script>\n' +
  '    <script>\n' +
  '        var stripHtml = function(html) {\n' +
  '            if(html) {\n' +
  "                return html.replace(/<(?:.|\\n)*?>/gm, '')\n" +
  '            }\n' +
  '        }\n' +
  '        $(document).ready(function() {\n' +
  '            console.log("Jquery Loaded");\n' +
  '        });\n' +
  '    </script>\n' +
  '    <style>\n' +
  '    .mdl-layout__content { opacity:0 }\n' +
  '    .mdl-grid:focus { outline: none; }\n' +
  '    </style>\n' +
  '\n' +
  '    <style>\n' +
  '       .mdl-layout--fixed-drawer>.mdl-layout__content {\n' +
  '        margin-left:0px;\n' +
  '       }\n' +
  '       .mdl-layout--fixed-drawer.is-upgraded:not(.is-small-screen)>.mdl-layout__header {\n' +
  '            margin-left: 0px;\n' +
  '            width: 100%;\n' +
  '        }\n' +
  '    </style>\n' +
  '</head>\n' +
  '\n' +
  '<body>\n' +
  '<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">\n' +
  '    <main class="mdl-layout__content logs-console logs-console-full">\n' +
  '        <div class="mdl-grid" style="outline:none;">\n' +
  '            <div class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--6-col" style="margin:0 auto">\n' +
  '                <div class="mdl-card__title">\n' +
  '                    <h5>Hubitat Elevation<sup>&reg;</sup></h5>\n' +
  '                    <p>Your hub is starting up. Please wait...</p>\n' +
  '                    <img src="/ui2/images/HubitatStartup.gif" style="width:100%;max-width:300px;">\n' +
  '                    <div id="p1" class="mdl-progress mdl-js-progress"></div>\n' +
  '                    <div id="hub-init-div"></div>\n' +
  '                    <p>If you are seeing this screen for an extended period of time, please contact Support.  For assistance, email <a href="mailto:support@hubitat.com">support@hubitat.com</a> or go to <a target="_blank" href="http://community.hubitat.com">community.hubitat.com</a>.</p>\n' +
  '                </div>\n' +
  '            </div>\n' +
  '        </div>\n' +
  '    </main>\n' +
  '    <footer class="mdl-mini-footer ">\n' +
  '    \n' +
  '    <div class="mdl-mini-footer__right-section ">\n' +
  '        <ul class="mdl-mini-footer__link-list ">\n' +
  '            <li><a href="/tos" target="_blank">Terms of Service</a></li>\n' +
  '            <li><a href="https://docs.hubitat.com/index.php?title=" target="_blank">Documentation</a></li>\n' +
  '            <li><a href="https://community.hubitat.com" target="_blank">Community</a></li>\n' +
  '            <li><a href="mailto:support@hubitat.com">Support</a></li>\n' +
  '            <li><a href="https://hubitat.com" target="_blank">Copyright 2019 Hubitat, Inc.</a></li>\n' +
  '        </ul>\n' +
  '    </div>\n' +
  '</footer>\n' +
  '<script>\n' +
  '    window.onload = function(){\n' +
  "        $('.mdl-layout__content').css('opacity', 1)\n" +
  '        $(".mdl-layout__header-row .mdl-spinner").hide()\n' +
  '        document.title = stripHtml(document.title)\n' +
  "        var grid = document.getElementsByClassName('mdl-grid')[0]\n" +
  '        if (grid) {\n' +
  `            grid.setAttribute('tabindex', "-1")\n` +
  '            grid.style.outline = "0px solid tranparent";\n' +
  '            grid.focus()\n' +
  '        }\n' +
  '    };\n' +
  '</script>\n' +
  '\n' +
  '</div>\n' +
  '</body>\n' +
  '<script>\n' +
  '    var checkStartupStatus = function () {\n' +
  '        $.ajax({\n' +
  '            type: "GET",\n' +
  '            url: "/hubStatus",\n' +
  '            success: function (response) {\n' +
  "                $('#hub-init-div').html(response.serverInitPercentage);\n" +
  "                var p1 = document.querySelector('#p1');\n" +
  `                if (p1.MaterialProgress) p1.MaterialProgress.setProgress(parseInt(response.serverInitPercentage.split(': ')[1].replace("%","")));\n` +
  '\n' +
  '                if (response.status == "running") {\n' +
  '                    setTimeout(reloadPage, 500);\n' +
  '                }\n' +
  '                else {\n' +
  '                    setTimeout(checkStartupStatus, 2000);\n' +
  '                }\n' +
  '            },\n' +
  '            error: function () {\n' +
  '                setTimeout(checkStartupStatus, 2000);\n' +
  '            }\n' +
  '        });\n' +
  '    }\n' +
  '\n' +
  '    var reloadPage = function() {\n' +
  '        location.reload();\n' +
  '    }\n' +
  '    $(document).ready( function() {\n' +
  "    var p1 = document.querySelector('#p1');\n" +
  '    if (p1.MaterialProgress) {\n' +
  "    document.querySelector('#p1').addEventListener('mdl-componentupgraded', function() {\n" +
  '                    this.MaterialProgress.setProgress(0);\n' +
  '                });\n' +
  '                }\n' +
  '        checkStartupStatus();\n' +
  '    })\n' +
  '    </script>\n' +
  '</html>\n'
[9/21/2019, 7:50:50 PM] [Hubitat hhm:0.2.17] Received an error trying to get the device summary information from Hubitat. <!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
    <title>Hubitat Starting Up</title>
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="apple-touch-icon" sizes="180x180" href="/ui2/images/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/ui2/images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/ui2/images/favicon-16x16.png">
    <link rel="icon" sizes="192x192" href="/ui2/images/favicon.ico">
    <link rel="manifest" href="/ui2/images/site.webmanifest">
    <link rel="mask-icon" href="/ui2/images/safari-pinned-tab.svg" color="#5bbad5">
    <link rel="shortcut icon" href="/ui2/images/favicon.ico">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="msapplication-config" content="/ui2/images/browserconfig.xml">
    <meta name="theme-color" content="#ffffff">
    <link rel="shortcut icon" href="/ui2/images/favicon.ico">
    <style>
        @font-face {
            font-family: 'Material Icons';
            font-style: normal;
            font-weight: 400;
            src: url(/ui2/css/fonts/MaterialIcons-Regular.eot);
            /* For IE6-8 */
            src: local('Material Icons'), local('MaterialIcons-Regular'), url(/ui2/css/fonts/MaterialIcons-Regular.woff2) format('woff2'), url(/ui2/css/fonts/MaterialIcons-Regular.woff) format('woff'), url(/ui2/css/fonts/MaterialIcons-Regular.ttf) format('truetype');
            font-display:block;
        }
        @font-face {
          font-family: 'hubitat';
          src:  url('/ui2/css/fonts/hubitat.eot?roox2j');
          src:  url('/ui2/css/fonts/hubitat.eot?roox2j#iefix') format('embedded-opentype'),
            url('/ui2/css/fonts/hubitat.woff2?roox2j') format('woff2'),
            url('/ui2/css/fonts/hubitat.ttf?roox2j') format('truetype'),
            url('/ui2/css/fonts/hubitat.woff?roox2j') format('woff'),
            url('/ui2/css/fonts/hubitat.svg?roox2j#hubitat') format('svg');
          font-weight: normal;
          font-style: normal;
          font-display: block;
        }
        html {
            -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape while allowing user zoom */
        }
    </style>
    <link rel="stylesheet" href="/ui2/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="/ui2/css/material.min.css">
    <link rel="stylesheet" href="/ui2/css/styles.min.css">
    <script src="/ui2/js/jquery-3.4.0.min.js "></script>
    <script type="text/javascript ">
        window.jQuery || document.write("<script src='/ui2/js/jquery-3.4.0.min.js'> <\ / script > ");
    </script>
    <script src="/ui2/js/jquery.dataTables.min.js "></script>
    <script src="/ui2/js/material.min.js "></script>
    <script src="/ui2/js/hubitat.min.js"></script>
    <script src="/ui2/js/success-compiled.js"></script>
    <link rel="stylesheet" href="/ui2/css/sumoselect.min.css"/>
    <script src="/ui2/js/jquery.sumoselect.min.js"></script>
    <script src="/ui2/js/moment.min.js"></script>
    <script src="/ui2/js/vue.min.js"></script>
    <script src="/ui2/js/webcomponents-bundle.js"></script>
    <script src="/ui2/js/vue-hub.min.js"></script>
    <script>
        var stripHtml = function(html) {
            if(html) {
                return html.replace(/<(?:.|\n)*?>/gm, '')
            }
        }
        $(document).ready(function() {
            console.log("Jquery Loaded");
        });
    </script>
    <style>
    .mdl-layout__content { opacity:0 }
    .mdl-grid:focus { outline: none; }
    </style>

    <style>
       .mdl-layout--fixed-drawer>.mdl-layout__content {
        margin-left:0px;
       }
       .mdl-layout--fixed-drawer.is-upgraded:not(.is-small-screen)>.mdl-layout__header {
            margin-left: 0px;
            width: 100%;
        }
    </style>
</head>

<body>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
    <main class="mdl-layout__content logs-console logs-console-full">
        <div class="mdl-grid" style="outline:none;">
            <div class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--6-col" style="margin:0 auto">
                <div class="mdl-card__title">
                    <h5>Hubitat Elevation<sup>&reg;</sup></h5>
                    <p>Your hub is starting up. Please wait...</p>
                    <img src="/ui2/images/HubitatStartup.gif" style="width:100%;max-width:300px;">
                    <div id="p1" class="mdl-progress mdl-js-progress"></div>
                    <div id="hub-init-div"></div>
                    <p>If you are seeing this screen for an extended period of time, please contact Support.  For assistance, email <a href="mailto:support@hubitat.com">support@hubitat.com</a> or go to <a target="_blank" href="http://community.hubitat.com">community.hubitat.com</a>.</p>
                </div>
            </div>
        </div>
    </main>
    <footer class="mdl-mini-footer ">
    
    <div class="mdl-mini-footer__right-section ">
        <ul class="mdl-mini-footer__link-list ">
            <li><a href="/tos" target="_blank">Terms of Service</a></li>
            <li><a href="https://docs.hubitat.com/index.php?title=" target="_blank">Documentation</a></li>
            <li><a href="https://community.hubitat.com" target="_blank">Community</a></li>
            <li><a href="mailto:support@hubitat.com">Support</a></li>
            <li><a href="https://hubitat.com" target="_blank">Copyright 2019 Hubitat, Inc.</a></li>
        </ul>
    </div>
</footer>
<script>
    window.onload = function(){
        $('.mdl-layout__content').css('opacity', 1)
        $(".mdl-layout__header-row .mdl-spinner").hide()
        document.title = stripHtml(document.title)
        var grid = document.getElementsByClassName('mdl-grid')[0]
        if (grid) {
            grid.setAttribute('tabindex', "-1")
            grid.style.outline = "0px solid tranparent";
            grid.focus()
        }
    };
</script>

</div>
</body>
<script>
    var checkStartupStatus = function () {
        $.ajax({
            type: "GET",
            url: "/hubStatus",
            success: function (response) {
                $('#hub-init-div').html(response.serverInitPercentage);
                var p1 = document.querySelector('#p1');
                if (p1.MaterialProgress) p1.MaterialProgress.setProgress(parseInt(response.serverInitPercentage.split(': ')[1].replace("%","")));

                if (response.status == "running") {
                    setTimeout(reloadPage, 500);
                }
                else {
                    setTimeout(checkStartupStatus, 2000);
                }
            },
            error: function () {
                setTimeout(checkStartupStatus, 2000);
            }
        });
    }

    var reloadPage = function() {
        location.reload();
    }
    $(document).ready( function() {
    var p1 = document.querySelector('#p1');
    if (p1.MaterialProgress) {
    document.querySelector('#p1').addEventListener('mdl-componentupgraded', function() {
                    this.MaterialProgress.setProgress(0);
                });
                }
        checkStartupStatus();
    })
    </script>
</html>

[9/21/2019, 7:50:50 PM] [Hubitat hhm:0.2.17] I am stopping my reload here and hope eveything fixes themselves (e.g. a firmware update of HE is rebooting the hub
(node:32468) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated

Did you reboot the hub? The log output shows the “Hub Starting Up” html code

I did not ask the hub to reboot...so if it did, it's a surprise to me....or could have been a power issue at the time.

The logs definitely shows a reboot.
I guess I need to order another hub... had to make my development hub into another production hub and I don’t want to reboot that all the time trying to figure out why the plugin goes out of sync when the hub reboots....

Strange how we can consume Hubs so quickly. :smiley: :smiley: I went from one to four very quickly. The fourth is still safe as a Development hub for at least the next week or two. :smiley:

Hi @dan.t, so this morning had another sync issue but am sure that the hub did not reboot. The issue was simply that a light showed on in Home App but was actually off. Selecting off and then on kinda resynced the device. Logs dont show anything...

After the reboot yesterday, did you restart Homebridge?
And did you check what the state in HE in the device details were?

Hi, I did not do a reboot yesterday...I made sure to check the Hub logs to confirm and it shows it has been up ...

Ok, I would reboot Homebridge once, I have a feeling that there might be something with reboots.

In addition, next time this happens, can you PM me the logs and a screenshot of the HE device page before you press anything in HE or the Home app?

@dan.t I've opened a PR that I think fixes the reboot issue. The plugin is going to lose sync with hub accross reboots, or network outages since the websocket doesn't know the socket has been closed. So homebridge sits there's happy as a clam not knowing the hub has gone away and events stop coming in. This is known has a "half-open" socket, since one side knows it's open, and the other thinks it's closed.

WebSocket's have to address this issue, since clients come and go all the time, think a mobile environment. So the protocol has a ping/pong message either side can send to validate the other host is there. These are pretty cheap, so I just default to sending on every 60s with a 5s timeout.

PR is here:

If others want to test it, my fork is here:

3 Likes

Oh and if anyone wants more info about WebSocket ping/pongs:

1 Like

I remember having to set up a ping/pong keepalive for the WebSocket in my Almond platform plugin. It solved all my sync problems, but I had completely forgotten about it.

All, I just uploaded version 0.2.18 with the following changes:

  • Added thermostat fan switch support (thanks @swiss6th )
  • added ping/pong for websockets (thanks @asj ) to fix out of sync issues after a hub reboot
4 Likes

Will the HubConnect version be updated? I have the same issue with Home getting out of sync.

Working on that as I am typing......

2 Likes