UNPKG

@homebridge-plugins/homebridge-meross

Version:

Homebridge plugin to integrate Meross devices into HomeKit.

357 lines (351 loc) 13 kB
<style> .dark-mode { background-color: #242424; color: lightgrey; .form-control { background-color: #333333 !important; border: none !important; color: #eeeeee !important; } thead, tbody, tr { border-style: hidden; } th { color: #eeeeee !important; font-weight: 500 !important; } } select { background-image: linear-gradient(45deg, transparent 50%, gray 50%), linear-gradient(135deg, gray 50%, transparent 50%), linear-gradient(to right, #ccc, #ccc); background-position: calc(100% - 20px) calc(1em + 2px), calc(100% - 15px) calc(1em + 2px), calc(100% - 2.5em) 0.5em; background-size: 5px 5px, 5px 5px, 1px 1.5em; background-repeat: no-repeat; } </style> <p class="text-center"> <img src="https://user-images.githubusercontent.com/43026681/127397024-8b15fc07-f31b-44bd-89e3-51d738d2609a.png" alt="homebridge-meross logo" style="width: 60%;" /> </p> <div id="pageIntro" class="text-center" style="display: none;"> <p class="lead">Thank you for installing <strong>homebridge-meross</strong></p> <p> You can enter your Meross username and password on the next page </p> <button type="button" class="btn btn-primary" id="introContinue"> Continue &rarr; </button> </div> <div id="menuWrapper" class="btn-group w-100 mb-0" role="group" aria-label="UI Menu" style="display: none;" > <button type="button" class="btn btn-primary ml-0" id="menuSettings"> Settings </button> <button type="button" class="btn btn-primary" id="menuDevices"> My Devices </button> <button type="button" class="btn btn-primary mr-0" id="menuHome"> Support </button> </div> <div id="pageDevices" class="mt-4" style="display: none;"> <div id="deviceInfo"> <form> <div class="form-group"> <select class="form-control" id="deviceSelect"></select> </div> </form> <table class="table w-100 mt-3" id="deviceTable" style="display: none;"> <thead> <tr class="table-active"> <th scope="col" style="width: 40%;">Device Name</th> <th scope="col" style="width: 60%;" id="displayName"></th> </tr> </thead> <tbody> <tr> <th scope="row">Status</th> <td id="status"></td> </tr> <tr> <th scope="row">Connection Type</th> <td id="connection_type"></td> </tr> <tr> <th scope="row">Device UUID</th> <td id="serial_number"></td> </tr> <tr> <th scope="row">Model</th> <td id="model"></td> </tr> <tr> <th scope="row">IP Address</th> <td id="ip_address"></td> </tr> <tr> <th scope="row">MAC Address</th> <td id="mac_address"></td> </tr> <tr> <th scope="row">Hardware Version</th> <td id="hardware"></td> </tr> <tr> <th scope="row">Firmware Version</th> <td id="firmware"></td> </tr> </tbody> </table> </div> </div> <div id="pageSupport" class="mt-4" style="display: none;"> <p class="text-center lead">Thank you for using <strong>homebridge-meross</strong></p> <p class="text-center">The links below will take you to our GitHub wiki</p> <h4>Setup</h4> <ul> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Installation" target="_blank" >Installation</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Configuration" target="_blank" >Configuration</a > </li> <li> <a href="https://github.com/homebridge/homebridge/wiki/How-to-Install-Alternate-Plugin-Versions" target="_blank" >Beta Version</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Node-Version" target="_blank" >Node Version</a > </li> </ul> <h4>Features</h4> <ul> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Supported-Devices" target="_blank" >Supported Devices</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Cloud-Control" target="_blank" >Cloud Control</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Local-Control" target="_blank" >Local Control</a > </li> </ul> <h4>Help/About</h4> <ul> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/wiki/Common-Errors" target="_blank" >Common Errors</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/issues/new/choose" target="_blank" >Support Request</a > </li> <li> <a href="https://github.com/homebridge-plugins/homebridge-meross/blob/latest/CHANGELOG.md" target="_blank" >Changelog</a > </li> <li> <a href="https://github.com/sponsors/bwp91" target="_blank">About Me</a> </li> </ul> <h4>Credits</h4> <ul> <li> This is a fork of the work originally done by <a href="https://github.com/Robdel12" target="_blank">@Robdel12</a> and <a href="https://github.com/dylanfrankcom" target="_blank">@dylanfrankcom</a>. </li> <li> To <a href="https://github.com/donavanbecker" target="_blank">@donavanbecker</a> the previous maintainer of this plugin. </li> <li> To <a href="https://github.com/Apollon77" target="_blank">@Apollon77</a> and <a href="https://github.com/colthreepv" target="_blank">@colthreepv</a> for the <a href="https://github.com/Apollon77/meross-cloud" target="_blank">meross-cloud</a> library (contained in this plugin). </li> <li> To the creator of the awesome plugin header logo: <a href="https://www.instagram.com/keryan.me" target="_blank">Keryan Belahcene</a>. </li> <li> To the creators/contributors of <a href="https://github.com/simont77/fakegato-history" target="_blank">Fakegato</a>: <a href="https://github.com/simont77" target="_blank">@simont77</a> and <a href="https://github.com/NorthernMan54" target="_blank">@NorthernMan54</a>. </li> <li> To the creators/contributors of <a href="https://homebridge.io" target="_blank">Homebridge</a> who make this plugin possible. </li> </ul> <h4>Disclaimer</h4> <ul> <li> I am in no way affiliated with Meross and this plugin is a personal project that I maintain in my free time. </li> <li> Use this plugin entirely at your own risk - please see licence for more information. </li> </ul> </div> <script> ;(async () => { try { const currentConfig = await homebridge.getPluginConfig() showIntro = () => { homebridge.disableSaveButton?.() const introContinue = document.getElementById('introContinue') introContinue.addEventListener('click', () => { homebridge.showSpinner() document.getElementById('pageIntro').style.display = 'none' document.getElementById('menuWrapper').style.display = 'inline-flex' showSettings() homebridge.hideSpinner() }) document.getElementById('pageIntro').style.display = 'block' } showDevices = async () => { homebridge.showSpinner() homebridge.disableSaveButton?.() homebridge.hideSchemaForm() document.getElementById('menuHome').classList.remove('btn-elegant') document.getElementById('menuHome').classList.add('btn-primary') document.getElementById('menuDevices').classList.add('btn-elegant') document.getElementById('menuDevices').classList.remove('btn-primary') document.getElementById('menuSettings').classList.remove('btn-elegant') document.getElementById('menuSettings').classList.add('btn-primary') document.getElementById('pageSupport').style.display = 'none' document.getElementById('pageDevices').style.display = 'block' const cachedAccessories = typeof homebridge.getCachedAccessories === 'function' ? await homebridge.getCachedAccessories() : await homebridge.request('/getCachedAccessories') if (cachedAccessories.length > 0) { cachedAccessories.sort((a, b) => { return a.displayName.toLowerCase() > b.displayName.toLowerCase() ? 1 : b.displayName.toLowerCase() > a.displayName.toLowerCase() ? -1 : 0 }) } const deviceSelect = document.getElementById('deviceSelect') deviceSelect.innerHTML = '' cachedAccessories.forEach(a => { const option = document.createElement('option') option.text = a.displayName option.value = a.UUID deviceSelect.add(option) }) showDeviceInfo = async UUID => { homebridge.showSpinner() const thisAcc = cachedAccessories.find(x => x.UUID === UUID) const context = thisAcc.context document.getElementById('displayName').innerHTML = thisAcc.displayName document.getElementById('serial_number').innerHTML = context.subSerialNumber || context.serialNumber document.getElementById('connection_type').innerHTML = context.connection[0].toUpperCase() + context.connection.slice(1) document.getElementById('status').innerHTML = context.isOnline ? '<i class="fas fa-circle mr-1 green-text"></i> Online' : '<i class="fas fa-circle mr-1 red-text"></i> Offline' document.getElementById('model').innerHTML = context.model document.getElementById('ip_address').innerHTML = context.ipAddress || 'N/A' document.getElementById('mac_address').innerHTML = context.macAddress || 'N/A' document.getElementById('hardware').innerHTML = context.hardware || 'N/A' document.getElementById('firmware').innerHTML = context.firmware || 'N/A' document.getElementById('deviceTable').style.display = 'inline-table' homebridge.hideSpinner() } deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value)) if (cachedAccessories.length > 0) { showDeviceInfo(cachedAccessories[0].UUID) } else { const option = document.createElement('option') option.text = 'No Devices' deviceSelect.add(option) deviceSelect.disabled = true } homebridge.hideSpinner() } showSupport = () => { homebridge.showSpinner() homebridge.disableSaveButton?.() homebridge.hideSchemaForm() document.getElementById('menuHome').classList.add('btn-elegant') document.getElementById('menuHome').classList.remove('btn-primary') document.getElementById('menuDevices').classList.remove('btn-elegant') document.getElementById('menuDevices').classList.add('btn-primary') document.getElementById('menuSettings').classList.remove('btn-elegant') document.getElementById('menuSettings').classList.add('btn-primary') document.getElementById('pageSupport').style.display = 'block' document.getElementById('pageDevices').style.display = 'none' homebridge.hideSpinner() } showSettings = () => { homebridge.showSpinner() homebridge.enableSaveButton?.() document.getElementById('menuHome').classList.remove('btn-elegant') document.getElementById('menuHome').classList.add('btn-primary') document.getElementById('menuDevices').classList.remove('btn-elegant') document.getElementById('menuDevices').classList.add('btn-primary') document.getElementById('menuSettings').classList.add('btn-elegant') document.getElementById('menuSettings').classList.remove('btn-primary') document.getElementById('pageSupport').style.display = 'none' document.getElementById('pageDevices').style.display = 'none' homebridge.showSchemaForm() homebridge.hideSpinner() } menuHome.addEventListener('click', () => showSupport()) menuDevices.addEventListener('click', () => showDevices()) menuSettings.addEventListener('click', () => showSettings()) if (currentConfig.length) { document.getElementById('menuWrapper').style.display = 'inline-flex' showSettings() } else { currentConfig.push({ name: 'Meross' }) await homebridge.updatePluginConfig(currentConfig) showIntro() } } catch (err) { homebridge.toast.error(err.message, 'Error') } finally { homebridge.hideSpinner() } })() </script>