New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit for NAD D 7050 component #6882
Conversation
@mwsluis, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @robbiet480 to be potential reviewers. |
So this is my first contribution to home assistant and Git in general. For reviewers: I'm not so familiar with socket handling and catching all possible exceptions. Please have a look at the code in the send method. Also I have not been able run tox successfully on my machine. |
It's OK to use travis to run tox, especially for your first PRs. It can sometimes be tricky to set up. All of the low-level protocol info (example) will need to be moved to an external library. You might want to reach out to @joopert to see if this can be included in the existing nad_receiver library. Supporting both transports via the same library would be the best solution. |
@armills Thanks for your input. I moved the low level stuff to the nad_receiver library as suggested, and added to my component as dependency. |
It seems there is another NAD product that uses tcp for remote control. I need to do some research to see if I can directly support it. I think I should therefor rename this component. edit: Thinking about naming it "NAD IP" |
A more generic rename would be good, and even better if it's possible would be to integrate the TCP receiver protocol into the existing nad platform, so that users configure either a serial port or host/port. Here's one example of such a platform. The hope would be that some of the extra functionality could be shared, such as the volume helpers. Also want to take a minute to say that this is really coming together well. Appreciate the work! |
To elaborate, it would be nice if here, we could create a generic |
@property | ||
def source_list(self): | ||
"""List of available input sources.""" | ||
return self.d7050.available_sources() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do that make IO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the device? No.
* Switch russound to pypi * Switch pymysensors to pypi * Switch pocketcasts to pypi
* Generate requirements file for tests * Update tox * Update validate * Lint * Tweak order in travis.yml to run longest job first
* Update to pyunifi 2.12 * Update requirements_all.txt
* Fix plant MIN_TEMPERATURE, MAX_TEMPERATURE validation small_float only allows values from 0 to 1 so we should use float instead * Do not use vol.All for a single validation
* Added effects to Yeelight bulbs * Fix Typo and Use randint instead of randrange * Added Effects * updated requirements_all.txt * fix empty line * minor fixes * fix passing effects as parameter
* Support for renaming ZWave values * Improve test
This makes LIFX Gen3 lights work with the current firmware.
* Change to pypi * add requirements
* Added a Taps Aff binary sensor * PR Review updates * Added a Taps Aff binary sensor * PR Review updates * Improved error handling * Cosmetic changes (ordering, docstings, etc.)
Initial commit for NAD D 7050 component
…-7050-component # Conflicts: # homeassistant/components/media_player/nad7050.py
@@ -1 +1 @@ | |||
!(function(){"use strict";function e(e,r){var t=arguments;if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=t[o];if(void 0!==i&&null!==i)for(var l=Object.keys(Object(i)),a=0,c=l.length;a<c;a++){var b=l[a],f=Object.getOwnPropertyDescriptor(i,b);void 0!==f&&f.enumerable&&(n[b]=i[b])}}return n}function r(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:e})}var t={assign:e,polyfill:r};t.polyfill()})(); | |||
!function(){"use strict";function e(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var r=Object(e),n=1;n<arguments.length;n++){var o=arguments[n];if(void 0!==o&&null!==o)for(var i=Object.keys(Object(o)),l=0,c=i.length;l<c;l++){var a=i[l],b=Object.getOwnPropertyDescriptor(o,a);void 0!==b&&b.enumerable&&(r[a]=o[a])}}return r}function t(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:e})}({assign:e,polyfill:t}).polyfill()}(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Missing semicolon.
Function declarations are not invocable. Wrap the whole function invocation in parens.
@@ -1 +1 @@ | |||
!(function(){"use strict";function e(e){return{type:"auth",api_password:e}}function t(){return{type:"get_states"}}function n(){return{type:"get_config"}}function r(){return{type:"get_services"}}function i(){return{type:"get_panels"}}function s(e,t,n){var r={type:"call_service",domain:e,service:t};return n&&(r.service_data=n),r}function o(e){var t={type:"subscribe_events"};return e&&(t.event_type=e),t}function c(e){return{type:"unsubscribe_events",subscription:e}}function u(){return{type:"ping"}}function a(e,t){return{type:"result",success:!1,error:{code:e,message:t}}}function f(t,n){function r(i,s,o){var c=new WebSocket(t),u=!1,a=function(){if(u)return void o(C);if(0===i)return void o(O);var e=i===-1?-1:i-1;setTimeout((function(){return r(e,s,o)}),1e3)},f=function(t){var r=JSON.parse(t.data);switch(r.type){case"auth_required":"authToken"in n?c.send(JSON.stringify(e(n.authToken))):(u=!0,c.close());break;case"auth_invalid":u=!0,c.close();break;case"auth_ok":c.removeEventListener("message",f),c.removeEventListener("close",a),s(c)}};c.addEventListener("message",f),c.addEventListener("close",a)}return new Promise(function(e,t){return r(n.setupRetry||0,e,t)})}function d(e){return e.result}function v(e,t){return void 0===t&&(t={}),f(e,t).then((function(n){var r=new L(e,t);return r.setSocket(n),r}))}function h(e,t){return e._subscribeConfig?e._subscribeConfig(t):new Promise(function(n,r){var i=null,s=null,o=[],c=null;t&&o.push(t);var u=function(e){i=Object.assign({},i,e);for(var t=0;t<o.length;t++)o[t](i)},a=function(e,t){return u({services:Object.assign({},i.services,(n={},n[e]=t,n))});var n},f=function(e){if(null!==i){var t=Object.assign({},i.core,{components:i.core.components.concat(e.data.component)});u({core:t})}},d=function(e){if(null!==i){var t,n=e.data,r=n.domain,s=n.service,o=Object.assign({},i.services[r]||{},(t={},t[s]={description:"",fields:{}},t));a(r,o)}},v=function(e){if(null!==i){var t=e.data,n=t.domain,r=t.service,s=i.services[n];if(s&&r in s){var o={};Object.keys(s).forEach((function(e){e!==r&&(o[e]=s[e])})),a(n,o)}}},h=function(){return Promise.all([e.getConfig(),e.getPanels(),e.getServices()]).then((function(e){var t=e[0],n=e[1],r=e[2];u({core:t,panels:n,services:r})}))},l=function(e){e&&o.splice(o.indexOf(e),1),0===o.length&&s()};e._subscribeConfig=function(e){return e&&(o.push(e),null!==i&&e(i)),c.then((function(){return function(){return l(e)}}))},c=Promise.all([e.subscribeEvents(f,"component_loaded"),e.subscribeEvents(d,"service_registered"),e.subscribeEvents(v,"service_removed"),h()]),c.then((function(r){var i=r[0],o=r[1],c=r[2];s=function(){removeEventListener("ready",h),i(),o(),c()},e.addEventListener("ready",h),n((function(){return l(t)}))}),(function(){return r()}))})}function l(e){for(var t={},n=0;n<e.length;n++){var r=e[n];t[r.entity_id]=r}return t}function p(e,t){var n=Object.assign({},e);return n[t.entity_id]=t,n}function b(e,t){var n=Object.assign({},e);return delete n[t],n}function g(e,t){return e._subscribeEntities?e._subscribeEntities(t):new Promise(function(n,r){function i(e){if(null!==c){var t=e.data,n=t.entity_id,r=t.new_state;c=r?p(c,r):b(c,n);for(var i=0;i<a.length;i++)a[i](c)}}function s(){return e.getStates().then((function(e){c=l(e);for(var t=0;t<a.length;t++)a[t](c)}))}function o(t){t&&a.splice(a.indexOf(t),1),0===a.length&&(u(),e.removeEventListener("ready",s),e._subscribeEntities=null)}var c=null,u=null,a=[],f=null;t&&a.push(t),e._subscribeEntities=function(e){return e&&(a.push(e),null!==c&&e(c)),f.then((function(){return function(){return o(e)}}))},f=Promise.all([e.subscribeEvents(i,"state_changed"),s()]),f.then((function(r){var i=r[0];u=i,e.addEventListener("ready",s),n((function(){return o(t)}))}),(function(){return r()}))})}function m(e){return e.substr(0,e.indexOf("."))}function y(e){return e.substr(e.indexOf(".")+1)}function _(e,t){var n={};return t.attributes.entity_id.forEach((function(t){var r=e[t];r&&(n[r.entity_id]=r)})),n}function E(e){var t=[],n={};return Object.keys(e).forEach((function(r){var i=e[r];"group"===m(r)?t.push(i):n[r]=i})),t.sort((function(e,t){return e.attributes.order-t.attributes.order})),t.forEach((function(e){return e.attributes.entity_id.forEach((function(e){delete n[e]}))})),{groups:t,ungrouped:n}}function w(e,t){var n={};return t.attributes.entity_id.forEach((function(t){var r=e[t];if(r&&!r.attributes.hidden&&(n[r.entity_id]=r,"group"===m(r.entity_id))){var i=_(e,r);Object.keys(i).forEach((function(e){var t=i[e];t.attributes.hidden||(n[e]=t)}))}})),n}function k(e){var t=[];return Object.keys(e).forEach((function(n){var r=e[n];r.attributes.view&&t.push(r)})),t.sort((function(e,t){return e.entity_id===P?-1:t.entity_id===P?1:e.attributes.order-t.attributes.order})),t}var O=1,C=2,j=3,L=function(e,t){this.url=e,this.options=t||{},this.commandId=1,this.commands={},this.eventListeners={},this.closeRequested=!1,this._handleMessage=this._handleMessage.bind(this),this._handleClose=this._handleClose.bind(this)};L.prototype.setSocket=function(e){var t=this,n=this.socket;if(this.socket=e,e.addEventListener("message",this._handleMessage),e.addEventListener("close",this._handleClose),n){var r=this.commands;this.commandId=1,this.commands={},Object.keys(r).forEach((function(e){var n=r[e];n.eventType&&t.subscribeEvents(n.eventCallback,n.eventType).then((function(e){n.unsubscribe=e}))})),this.fireEvent("ready")}},L.prototype.addEventListener=function(e,t){var n=this.eventListeners[e];n||(n=this.eventListeners[e]=[]),n.push(t)},L.prototype.removeEventListener=function(e,t){var n=this.eventListeners[e];if(n){var r=n.indexOf(t);r!==-1&&n.splice(r,1)}},L.prototype.fireEvent=function(e){var t=this;(this.eventListeners[e]||[]).forEach((function(e){return e(t)}))},L.prototype.close=function(){this.closeRequested=!0,this.socket.close()},L.prototype.getStates=function(){return this.sendMessagePromise(t()).then(d)},L.prototype.getServices=function(){return this.sendMessagePromise(r()).then(d)},L.prototype.getPanels=function(){return this.sendMessagePromise(i()).then(d)},L.prototype.getConfig=function(){return this.sendMessagePromise(n()).then(d)},L.prototype.callService=function(e,t,n){return this.sendMessagePromise(s(e,t,n))},L.prototype.subscribeEvents=function(e,t){var n=this;return this.sendMessagePromise(o(t)).then((function(r){var i={eventCallback:e,eventType:t,unsubscribe:function(){return n.sendMessagePromise(c(r.id)).then((function(){delete n.commands[r.id]}))}};return n.commands[r.id]=i,function(){return i.unsubscribe()}}))},L.prototype.ping=function(){return this.sendMessagePromise(u())},L.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},L.prototype.sendMessagePromise=function(e){var t=this;return new Promise(function(n,r){t.commandId+=1;var i=t.commandId;e.id=i,t.commands[i]={resolve:n,reject:r},t.sendMessage(e)})},L.prototype._handleMessage=function(e){var t=JSON.parse(e.data);switch(t.type){case"event":this.commands[t.id].eventCallback(t.event);break;case"result":t.success?this.commands[t.id].resolve(t):this.commands[t.id].reject(t.error),delete this.commands[t.id];break;case"pong":}},L.prototype._handleClose=function(){var e=this;if(Object.keys(this.commands).forEach((function(t){var n=e.commands[t],r=n.reject;r&&r(a(j,"Connection lost"))})),!this.closeRequested){this.fireEvent("disconnected");var t=Object.assign({},this.options,{setupRetry:0}),n=function(r){setTimeout((function(){f(e.url,t).then((function(t){return e.setSocket(t)}),(function(){return n(r+1)}))}),1e3*Math.min(r,5))};n(0)}};var P="group.default_view",S=Object.freeze({ERR_CANNOT_CONNECT:O,ERR_INVALID_AUTH:C,createConnection:v,subscribeConfig:h,subscribeEntities:g,getGroupEntities:_,splitByGroups:E,getViewEntities:w,extractViews:k,extractDomain:m,extractObjectId:y});window.HAWS=S,window.HASS_DEMO=!1;var M=window.createHassConnection=function(e){var t="https:"===window.location.protocol?"wss":"ws",n=t+"://"+window.location.host+"/api/websocket",r={setupRetry:10};return void 0!==e&&(r.authToken=e),v(n,r).then((function(e){return g(e),h(e),e}))};window.noAuth?window.hassConnection=M():window.localStorage.authToken?window.hassConnection=M(window.localStorage.authToken):window.hassConnection=null,"serviceWorker"in navigator&&window.addEventListener("load",(function(){navigator.serviceWorker.register("/service_worker.js")}))})(); | |||
!function(){"use strict";function e(e){return{type:"auth",api_password:e}}function t(){return{type:"get_states"}}function n(){return{type:"get_config"}}function i(){return{type:"get_services"}}function r(){return{type:"get_panels"}}function s(e,t,n){var i={type:"call_service",domain:e,service:t};return n&&(i.service_data=n),i}function o(e){var t={type:"subscribe_events"};return e&&(t.event_type=e),t}function c(e){return{type:"unsubscribe_events",subscription:e}}function u(){return{type:"ping"}}function a(e,t){return{type:"result",success:!1,error:{code:e,message:t}}}function d(t,n){function i(r,s,o){var c=new WebSocket(t),u=!1,a=function(){if(u)return void o(C);if(0===r)return void o(O);var e=-1===r?-1:r-1;setTimeout(function(){return i(e,s,o)},1e3)},d=function t(i){switch(JSON.parse(i.data).type){case"auth_required":"authToken"in n?c.send(JSON.stringify(e(n.authToken))):(u=!0,c.close());break;case"auth_invalid":u=!0,c.close();break;case"auth_ok":c.removeEventListener("message",t),c.removeEventListener("close",a),s(c)}};c.addEventListener("message",d),c.addEventListener("close",a)}return new Promise(function(e,t){return i(n.setupRetry||0,e,t)})}function f(e){return e.result}function v(e,t){return void 0===t&&(t={}),d(e,t).then(function(n){var i=new S(e,t);return i.setSocket(n),i})}function h(e,t){return e._subscribeConfig?e._subscribeConfig(t):new Promise(function(n,i){var r=null,s=null,o=[],c=null;t&&o.push(t);var u=function(e){r=Object.assign({},r,e);for(var t=0;t<o.length;t++)o[t](r)},a=function(e,t){return u({services:Object.assign({},r.services,(n={},n[e]=t,n))});var n},d=function(e){if(null!==r){var t=Object.assign({},r.core,{components:r.core.components.concat(e.data.component)});u({core:t})}},f=function(e){if(null!==r){var t,n=e.data,i=n.domain,s=n.service,o=Object.assign({},r.services[i]||{},(t={},t[s]={description:"",fields:{}},t));a(i,o)}},v=function(e){if(null!==r){var t=e.data,n=t.domain,i=t.service,s=r.services[n];if(s&&i in s){var o={};Object.keys(s).forEach(function(e){e!==i&&(o[e]=s[e])}),a(n,o)}}},h=function(){return Promise.all([e.getConfig(),e.getPanels(),e.getServices()]).then(function(e){var t=e[0],n=e[1],i=e[2];u({core:t,panels:n,services:i})})},l=function(e){e&&o.splice(o.indexOf(e),1),0===o.length&&s()};e._subscribeConfig=function(e){return e&&(o.push(e),null!==r&&e(r)),c.then(function(){return function(){return l(e)}})},c=Promise.all([e.subscribeEvents(d,"component_loaded"),e.subscribeEvents(f,"service_registered"),e.subscribeEvents(v,"service_removed"),h()]),c.then(function(i){var r=i[0],o=i[1],c=i[2];s=function(){removeEventListener("ready",h),r(),o(),c()},e.addEventListener("ready",h),n(function(){return l(t)})},function(){return i()})})}function l(e){for(var t={},n=0;n<e.length;n++){var i=e[n];t[i.entity_id]=i}return t}function p(e,t){var n=Object.assign({},e);return n[t.entity_id]=t,n}function b(e,t){var n=Object.assign({},e);return delete n[t],n}function g(e,t){return e._subscribeEntities?e._subscribeEntities(t):new Promise(function(n,i){function r(e){if(null!==c){var t=e.data,n=t.entity_id,i=t.new_state;c=i?p(c,i):b(c,n);for(var r=0;r<a.length;r++)a[r](c)}}function s(){return e.getStates().then(function(e){c=l(e);for(var t=0;t<a.length;t++)a[t](c)})}function o(t){t&&a.splice(a.indexOf(t),1),0===a.length&&(u(),e.removeEventListener("ready",s),e._subscribeEntities=null)}var c=null,u=null,a=[],d=null;t&&a.push(t),e._subscribeEntities=function(e){return e&&(a.push(e),null!==c&&e(c)),d.then(function(){return function(){return o(e)}})},d=Promise.all([e.subscribeEvents(r,"state_changed"),s()]),d.then(function(i){var r=i[0];u=r,e.addEventListener("ready",s),n(function(){return o(t)})},function(){return i()})})}function m(e){return e.substr(0,e.indexOf("."))}function y(e){return e.substr(e.indexOf(".")+1)}function _(e,t){var n={};return t.attributes.entity_id.forEach(function(t){var i=e[t];i&&(n[i.entity_id]=i)}),n}function E(e){var t=[],n={};return Object.keys(e).forEach(function(i){var r=e[i];"group"===m(i)?t.push(r):n[i]=r}),t.sort(function(e,t){return e.attributes.order-t.attributes.order}),t.forEach(function(e){return e.attributes.entity_id.forEach(function(e){delete n[e]})}),{groups:t,ungrouped:n}}function w(e,t){var n={};return t.attributes.entity_id.forEach(function(t){var i=e[t];if(i&&!i.attributes.hidden&&(n[i.entity_id]=i,"group"===m(i.entity_id))){var r=_(e,i);Object.keys(r).forEach(function(e){var t=r[e];t.attributes.hidden||(n[e]=t)})}}),n}function k(e){var t=[];return Object.keys(e).forEach(function(n){var i=e[n];i.attributes.view&&t.push(i)}),t.sort(function(e,t){return e.entity_id===j?-1:t.entity_id===j?1:e.attributes.order-t.attributes.order}),t}var O=1,C=2,S=function(e,t){this.url=e,this.options=t||{},this.commandId=1,this.commands={},this.eventListeners={},this.closeRequested=!1,this._handleMessage=this._handleMessage.bind(this),this._handleClose=this._handleClose.bind(this)};S.prototype.setSocket=function(e){var t=this,n=this.socket;if(this.socket=e,e.addEventListener("message",this._handleMessage),e.addEventListener("close",this._handleClose),n){var i=this.commands;this.commandId=1,this.commands={},Object.keys(i).forEach(function(e){var n=i[e];n.eventType&&t.subscribeEvents(n.eventCallback,n.eventType).then(function(e){n.unsubscribe=e})}),this.fireEvent("ready")}},S.prototype.addEventListener=function(e,t){var n=this.eventListeners[e];n||(n=this.eventListeners[e]=[]),n.push(t)},S.prototype.removeEventListener=function(e,t){var n=this.eventListeners[e];if(n){var i=n.indexOf(t);-1!==i&&n.splice(i,1)}},S.prototype.fireEvent=function(e){var t=this;(this.eventListeners[e]||[]).forEach(function(e){return e(t)})},S.prototype.close=function(){this.closeRequested=!0,this.socket.close()},S.prototype.getStates=function(){return this.sendMessagePromise(t()).then(f)},S.prototype.getServices=function(){return this.sendMessagePromise(i()).then(f)},S.prototype.getPanels=function(){return this.sendMessagePromise(r()).then(f)},S.prototype.getConfig=function(){return this.sendMessagePromise(n()).then(f)},S.prototype.callService=function(e,t,n){return this.sendMessagePromise(s(e,t,n))},S.prototype.subscribeEvents=function(e,t){var n=this;return this.sendMessagePromise(o(t)).then(function(i){var r={eventCallback:e,eventType:t,unsubscribe:function(){return n.sendMessagePromise(c(i.id)).then(function(){delete n.commands[i.id]})}};return n.commands[i.id]=r,function(){return r.unsubscribe()}})},S.prototype.ping=function(){return this.sendMessagePromise(u())},S.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},S.prototype.sendMessagePromise=function(e){var t=this;return new Promise(function(n,i){t.commandId+=1;var r=t.commandId;e.id=r,t.commands[r]={resolve:n,reject:i},t.sendMessage(e)})},S.prototype._handleMessage=function(e){var t=JSON.parse(e.data);switch(t.type){case"event":this.commands[t.id].eventCallback(t.event);break;case"result":t.success?this.commands[t.id].resolve(t):this.commands[t.id].reject(t.error),delete this.commands[t.id]}},S.prototype._handleClose=function(){var e=this;if(Object.keys(this.commands).forEach(function(t){var n=e.commands[t],i=n.reject;i&&i(a(3,"Connection lost"))}),!this.closeRequested){this.fireEvent("disconnected");var t=Object.assign({},this.options,{setupRetry:0});!function n(i){setTimeout(function(){d(e.url,t).then(function(t){return e.setSocket(t)},function(){return n(i+1)})},1e3*Math.min(i,5))}(0)}};var j="group.default_view",L=Object.freeze({ERR_CANNOT_CONNECT:O,ERR_INVALID_AUTH:C,createConnection:v,subscribeConfig:h,subscribeEntities:g,getGroupEntities:_,splitByGroups:E,getViewEntities:w,extractViews:k,extractDomain:m,extractObjectId:y});window.HAWS=L,window.HASS_DEMO=!1,window.HASS_DEV=!1;var P=window.createHassConnection=function(e){var t="https:"===window.location.protocol?"wss":"ws",n=t+"://"+window.location.host+"/api/websocket",i={setupRetry:10};return void 0!==e&&(i.authToken=e),v(n,i).then(function(e){return g(e),h(e),e})};window.noAuth?window.hassConnection=P():window.localStorage.authToken?window.hassConnection=P(window.localStorage.authToken):window.hassConnection=null,"serviceWorker"in navigator&&window.addEventListener("load",function(){navigator.serviceWorker.register("/service_worker.js")})}(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
Expected an assignment or function call and instead saw an expression.
Unreachable 'var' after 'return'.
Too many errors. (50% scanned).
@@ -1 +1 @@ | |||
!(function(){"use strict";function e(e,r){var t=arguments;if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=t[o];if(void 0!==i&&null!==i)for(var l=Object.keys(Object(i)),a=0,c=l.length;a<c;a++){var b=l[a],f=Object.getOwnPropertyDescriptor(i,b);void 0!==f&&f.enumerable&&(n[b]=i[b])}}return n}function r(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:e})}var t={assign:e,polyfill:r};t.polyfill()})(); | |||
!function(){"use strict";function e(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var r=Object(e),n=1;n<arguments.length;n++){var o=arguments[n];if(void 0!==o&&null!==o)for(var i=Object.keys(Object(o)),l=0,c=i.length;l<c;l++){var a=i[l],b=Object.getOwnPropertyDescriptor(o,a);void 0!==b&&b.enumerable&&(r[a]=o[a])}}return r}function t(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:e})}({assign:e,polyfill:t}).polyfill()}(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Missing semicolon.
Function declarations are not invocable. Wrap the whole function invocation in parens.
@@ -1 +1 @@ | |||
!(function(){"use strict";function e(e){return{type:"auth",api_password:e}}function t(){return{type:"get_states"}}function n(){return{type:"get_config"}}function r(){return{type:"get_services"}}function i(){return{type:"get_panels"}}function s(e,t,n){var r={type:"call_service",domain:e,service:t};return n&&(r.service_data=n),r}function o(e){var t={type:"subscribe_events"};return e&&(t.event_type=e),t}function c(e){return{type:"unsubscribe_events",subscription:e}}function u(){return{type:"ping"}}function a(e,t){return{type:"result",success:!1,error:{code:e,message:t}}}function f(t,n){function r(i,s,o){var c=new WebSocket(t),u=!1,a=function(){if(u)return void o(C);if(0===i)return void o(O);var e=i===-1?-1:i-1;setTimeout((function(){return r(e,s,o)}),1e3)},f=function(t){var r=JSON.parse(t.data);switch(r.type){case"auth_required":"authToken"in n?c.send(JSON.stringify(e(n.authToken))):(u=!0,c.close());break;case"auth_invalid":u=!0,c.close();break;case"auth_ok":c.removeEventListener("message",f),c.removeEventListener("close",a),s(c)}};c.addEventListener("message",f),c.addEventListener("close",a)}return new Promise(function(e,t){return r(n.setupRetry||0,e,t)})}function d(e){return e.result}function v(e,t){return void 0===t&&(t={}),f(e,t).then((function(n){var r=new L(e,t);return r.setSocket(n),r}))}function h(e,t){return e._subscribeConfig?e._subscribeConfig(t):new Promise(function(n,r){var i=null,s=null,o=[],c=null;t&&o.push(t);var u=function(e){i=Object.assign({},i,e);for(var t=0;t<o.length;t++)o[t](i)},a=function(e,t){return u({services:Object.assign({},i.services,(n={},n[e]=t,n))});var n},f=function(e){if(null!==i){var t=Object.assign({},i.core,{components:i.core.components.concat(e.data.component)});u({core:t})}},d=function(e){if(null!==i){var t,n=e.data,r=n.domain,s=n.service,o=Object.assign({},i.services[r]||{},(t={},t[s]={description:"",fields:{}},t));a(r,o)}},v=function(e){if(null!==i){var t=e.data,n=t.domain,r=t.service,s=i.services[n];if(s&&r in s){var o={};Object.keys(s).forEach((function(e){e!==r&&(o[e]=s[e])})),a(n,o)}}},h=function(){return Promise.all([e.getConfig(),e.getPanels(),e.getServices()]).then((function(e){var t=e[0],n=e[1],r=e[2];u({core:t,panels:n,services:r})}))},l=function(e){e&&o.splice(o.indexOf(e),1),0===o.length&&s()};e._subscribeConfig=function(e){return e&&(o.push(e),null!==i&&e(i)),c.then((function(){return function(){return l(e)}}))},c=Promise.all([e.subscribeEvents(f,"component_loaded"),e.subscribeEvents(d,"service_registered"),e.subscribeEvents(v,"service_removed"),h()]),c.then((function(r){var i=r[0],o=r[1],c=r[2];s=function(){removeEventListener("ready",h),i(),o(),c()},e.addEventListener("ready",h),n((function(){return l(t)}))}),(function(){return r()}))})}function l(e){for(var t={},n=0;n<e.length;n++){var r=e[n];t[r.entity_id]=r}return t}function p(e,t){var n=Object.assign({},e);return n[t.entity_id]=t,n}function b(e,t){var n=Object.assign({},e);return delete n[t],n}function g(e,t){return e._subscribeEntities?e._subscribeEntities(t):new Promise(function(n,r){function i(e){if(null!==c){var t=e.data,n=t.entity_id,r=t.new_state;c=r?p(c,r):b(c,n);for(var i=0;i<a.length;i++)a[i](c)}}function s(){return e.getStates().then((function(e){c=l(e);for(var t=0;t<a.length;t++)a[t](c)}))}function o(t){t&&a.splice(a.indexOf(t),1),0===a.length&&(u(),e.removeEventListener("ready",s),e._subscribeEntities=null)}var c=null,u=null,a=[],f=null;t&&a.push(t),e._subscribeEntities=function(e){return e&&(a.push(e),null!==c&&e(c)),f.then((function(){return function(){return o(e)}}))},f=Promise.all([e.subscribeEvents(i,"state_changed"),s()]),f.then((function(r){var i=r[0];u=i,e.addEventListener("ready",s),n((function(){return o(t)}))}),(function(){return r()}))})}function m(e){return e.substr(0,e.indexOf("."))}function y(e){return e.substr(e.indexOf(".")+1)}function _(e,t){var n={};return t.attributes.entity_id.forEach((function(t){var r=e[t];r&&(n[r.entity_id]=r)})),n}function E(e){var t=[],n={};return Object.keys(e).forEach((function(r){var i=e[r];"group"===m(r)?t.push(i):n[r]=i})),t.sort((function(e,t){return e.attributes.order-t.attributes.order})),t.forEach((function(e){return e.attributes.entity_id.forEach((function(e){delete n[e]}))})),{groups:t,ungrouped:n}}function w(e,t){var n={};return t.attributes.entity_id.forEach((function(t){var r=e[t];if(r&&!r.attributes.hidden&&(n[r.entity_id]=r,"group"===m(r.entity_id))){var i=_(e,r);Object.keys(i).forEach((function(e){var t=i[e];t.attributes.hidden||(n[e]=t)}))}})),n}function k(e){var t=[];return Object.keys(e).forEach((function(n){var r=e[n];r.attributes.view&&t.push(r)})),t.sort((function(e,t){return e.entity_id===P?-1:t.entity_id===P?1:e.attributes.order-t.attributes.order})),t}var O=1,C=2,j=3,L=function(e,t){this.url=e,this.options=t||{},this.commandId=1,this.commands={},this.eventListeners={},this.closeRequested=!1,this._handleMessage=this._handleMessage.bind(this),this._handleClose=this._handleClose.bind(this)};L.prototype.setSocket=function(e){var t=this,n=this.socket;if(this.socket=e,e.addEventListener("message",this._handleMessage),e.addEventListener("close",this._handleClose),n){var r=this.commands;this.commandId=1,this.commands={},Object.keys(r).forEach((function(e){var n=r[e];n.eventType&&t.subscribeEvents(n.eventCallback,n.eventType).then((function(e){n.unsubscribe=e}))})),this.fireEvent("ready")}},L.prototype.addEventListener=function(e,t){var n=this.eventListeners[e];n||(n=this.eventListeners[e]=[]),n.push(t)},L.prototype.removeEventListener=function(e,t){var n=this.eventListeners[e];if(n){var r=n.indexOf(t);r!==-1&&n.splice(r,1)}},L.prototype.fireEvent=function(e){var t=this;(this.eventListeners[e]||[]).forEach((function(e){return e(t)}))},L.prototype.close=function(){this.closeRequested=!0,this.socket.close()},L.prototype.getStates=function(){return this.sendMessagePromise(t()).then(d)},L.prototype.getServices=function(){return this.sendMessagePromise(r()).then(d)},L.prototype.getPanels=function(){return this.sendMessagePromise(i()).then(d)},L.prototype.getConfig=function(){return this.sendMessagePromise(n()).then(d)},L.prototype.callService=function(e,t,n){return this.sendMessagePromise(s(e,t,n))},L.prototype.subscribeEvents=function(e,t){var n=this;return this.sendMessagePromise(o(t)).then((function(r){var i={eventCallback:e,eventType:t,unsubscribe:function(){return n.sendMessagePromise(c(r.id)).then((function(){delete n.commands[r.id]}))}};return n.commands[r.id]=i,function(){return i.unsubscribe()}}))},L.prototype.ping=function(){return this.sendMessagePromise(u())},L.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},L.prototype.sendMessagePromise=function(e){var t=this;return new Promise(function(n,r){t.commandId+=1;var i=t.commandId;e.id=i,t.commands[i]={resolve:n,reject:r},t.sendMessage(e)})},L.prototype._handleMessage=function(e){var t=JSON.parse(e.data);switch(t.type){case"event":this.commands[t.id].eventCallback(t.event);break;case"result":t.success?this.commands[t.id].resolve(t):this.commands[t.id].reject(t.error),delete this.commands[t.id];break;case"pong":}},L.prototype._handleClose=function(){var e=this;if(Object.keys(this.commands).forEach((function(t){var n=e.commands[t],r=n.reject;r&&r(a(j,"Connection lost"))})),!this.closeRequested){this.fireEvent("disconnected");var t=Object.assign({},this.options,{setupRetry:0}),n=function(r){setTimeout((function(){f(e.url,t).then((function(t){return e.setSocket(t)}),(function(){return n(r+1)}))}),1e3*Math.min(r,5))};n(0)}};var P="group.default_view",S=Object.freeze({ERR_CANNOT_CONNECT:O,ERR_INVALID_AUTH:C,createConnection:v,subscribeConfig:h,subscribeEntities:g,getGroupEntities:_,splitByGroups:E,getViewEntities:w,extractViews:k,extractDomain:m,extractObjectId:y});window.HAWS=S,window.HASS_DEMO=!1;var M=window.createHassConnection=function(e){var t="https:"===window.location.protocol?"wss":"ws",n=t+"://"+window.location.host+"/api/websocket",r={setupRetry:10};return void 0!==e&&(r.authToken=e),v(n,r).then((function(e){return g(e),h(e),e}))};window.noAuth?window.hassConnection=M():window.localStorage.authToken?window.hassConnection=M(window.localStorage.authToken):window.hassConnection=null,"serviceWorker"in navigator&&window.addEventListener("load",(function(){navigator.serviceWorker.register("/service_worker.js")}))})(); | |||
!function(){"use strict";function e(e){return{type:"auth",api_password:e}}function t(){return{type:"get_states"}}function n(){return{type:"get_config"}}function i(){return{type:"get_services"}}function r(){return{type:"get_panels"}}function s(e,t,n){var i={type:"call_service",domain:e,service:t};return n&&(i.service_data=n),i}function o(e){var t={type:"subscribe_events"};return e&&(t.event_type=e),t}function c(e){return{type:"unsubscribe_events",subscription:e}}function u(){return{type:"ping"}}function a(e,t){return{type:"result",success:!1,error:{code:e,message:t}}}function d(t,n){function i(r,s,o){var c=new WebSocket(t),u=!1,a=function(){if(u)return void o(C);if(0===r)return void o(O);var e=-1===r?-1:r-1;setTimeout(function(){return i(e,s,o)},1e3)},d=function t(i){switch(JSON.parse(i.data).type){case"auth_required":"authToken"in n?c.send(JSON.stringify(e(n.authToken))):(u=!0,c.close());break;case"auth_invalid":u=!0,c.close();break;case"auth_ok":c.removeEventListener("message",t),c.removeEventListener("close",a),s(c)}};c.addEventListener("message",d),c.addEventListener("close",a)}return new Promise(function(e,t){return i(n.setupRetry||0,e,t)})}function f(e){return e.result}function v(e,t){return void 0===t&&(t={}),d(e,t).then(function(n){var i=new S(e,t);return i.setSocket(n),i})}function h(e,t){return e._subscribeConfig?e._subscribeConfig(t):new Promise(function(n,i){var r=null,s=null,o=[],c=null;t&&o.push(t);var u=function(e){r=Object.assign({},r,e);for(var t=0;t<o.length;t++)o[t](r)},a=function(e,t){return u({services:Object.assign({},r.services,(n={},n[e]=t,n))});var n},d=function(e){if(null!==r){var t=Object.assign({},r.core,{components:r.core.components.concat(e.data.component)});u({core:t})}},f=function(e){if(null!==r){var t,n=e.data,i=n.domain,s=n.service,o=Object.assign({},r.services[i]||{},(t={},t[s]={description:"",fields:{}},t));a(i,o)}},v=function(e){if(null!==r){var t=e.data,n=t.domain,i=t.service,s=r.services[n];if(s&&i in s){var o={};Object.keys(s).forEach(function(e){e!==i&&(o[e]=s[e])}),a(n,o)}}},h=function(){return Promise.all([e.getConfig(),e.getPanels(),e.getServices()]).then(function(e){var t=e[0],n=e[1],i=e[2];u({core:t,panels:n,services:i})})},l=function(e){e&&o.splice(o.indexOf(e),1),0===o.length&&s()};e._subscribeConfig=function(e){return e&&(o.push(e),null!==r&&e(r)),c.then(function(){return function(){return l(e)}})},c=Promise.all([e.subscribeEvents(d,"component_loaded"),e.subscribeEvents(f,"service_registered"),e.subscribeEvents(v,"service_removed"),h()]),c.then(function(i){var r=i[0],o=i[1],c=i[2];s=function(){removeEventListener("ready",h),r(),o(),c()},e.addEventListener("ready",h),n(function(){return l(t)})},function(){return i()})})}function l(e){for(var t={},n=0;n<e.length;n++){var i=e[n];t[i.entity_id]=i}return t}function p(e,t){var n=Object.assign({},e);return n[t.entity_id]=t,n}function b(e,t){var n=Object.assign({},e);return delete n[t],n}function g(e,t){return e._subscribeEntities?e._subscribeEntities(t):new Promise(function(n,i){function r(e){if(null!==c){var t=e.data,n=t.entity_id,i=t.new_state;c=i?p(c,i):b(c,n);for(var r=0;r<a.length;r++)a[r](c)}}function s(){return e.getStates().then(function(e){c=l(e);for(var t=0;t<a.length;t++)a[t](c)})}function o(t){t&&a.splice(a.indexOf(t),1),0===a.length&&(u(),e.removeEventListener("ready",s),e._subscribeEntities=null)}var c=null,u=null,a=[],d=null;t&&a.push(t),e._subscribeEntities=function(e){return e&&(a.push(e),null!==c&&e(c)),d.then(function(){return function(){return o(e)}})},d=Promise.all([e.subscribeEvents(r,"state_changed"),s()]),d.then(function(i){var r=i[0];u=r,e.addEventListener("ready",s),n(function(){return o(t)})},function(){return i()})})}function m(e){return e.substr(0,e.indexOf("."))}function y(e){return e.substr(e.indexOf(".")+1)}function _(e,t){var n={};return t.attributes.entity_id.forEach(function(t){var i=e[t];i&&(n[i.entity_id]=i)}),n}function E(e){var t=[],n={};return Object.keys(e).forEach(function(i){var r=e[i];"group"===m(i)?t.push(r):n[i]=r}),t.sort(function(e,t){return e.attributes.order-t.attributes.order}),t.forEach(function(e){return e.attributes.entity_id.forEach(function(e){delete n[e]})}),{groups:t,ungrouped:n}}function w(e,t){var n={};return t.attributes.entity_id.forEach(function(t){var i=e[t];if(i&&!i.attributes.hidden&&(n[i.entity_id]=i,"group"===m(i.entity_id))){var r=_(e,i);Object.keys(r).forEach(function(e){var t=r[e];t.attributes.hidden||(n[e]=t)})}}),n}function k(e){var t=[];return Object.keys(e).forEach(function(n){var i=e[n];i.attributes.view&&t.push(i)}),t.sort(function(e,t){return e.entity_id===j?-1:t.entity_id===j?1:e.attributes.order-t.attributes.order}),t}var O=1,C=2,S=function(e,t){this.url=e,this.options=t||{},this.commandId=1,this.commands={},this.eventListeners={},this.closeRequested=!1,this._handleMessage=this._handleMessage.bind(this),this._handleClose=this._handleClose.bind(this)};S.prototype.setSocket=function(e){var t=this,n=this.socket;if(this.socket=e,e.addEventListener("message",this._handleMessage),e.addEventListener("close",this._handleClose),n){var i=this.commands;this.commandId=1,this.commands={},Object.keys(i).forEach(function(e){var n=i[e];n.eventType&&t.subscribeEvents(n.eventCallback,n.eventType).then(function(e){n.unsubscribe=e})}),this.fireEvent("ready")}},S.prototype.addEventListener=function(e,t){var n=this.eventListeners[e];n||(n=this.eventListeners[e]=[]),n.push(t)},S.prototype.removeEventListener=function(e,t){var n=this.eventListeners[e];if(n){var i=n.indexOf(t);-1!==i&&n.splice(i,1)}},S.prototype.fireEvent=function(e){var t=this;(this.eventListeners[e]||[]).forEach(function(e){return e(t)})},S.prototype.close=function(){this.closeRequested=!0,this.socket.close()},S.prototype.getStates=function(){return this.sendMessagePromise(t()).then(f)},S.prototype.getServices=function(){return this.sendMessagePromise(i()).then(f)},S.prototype.getPanels=function(){return this.sendMessagePromise(r()).then(f)},S.prototype.getConfig=function(){return this.sendMessagePromise(n()).then(f)},S.prototype.callService=function(e,t,n){return this.sendMessagePromise(s(e,t,n))},S.prototype.subscribeEvents=function(e,t){var n=this;return this.sendMessagePromise(o(t)).then(function(i){var r={eventCallback:e,eventType:t,unsubscribe:function(){return n.sendMessagePromise(c(i.id)).then(function(){delete n.commands[i.id]})}};return n.commands[i.id]=r,function(){return r.unsubscribe()}})},S.prototype.ping=function(){return this.sendMessagePromise(u())},S.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},S.prototype.sendMessagePromise=function(e){var t=this;return new Promise(function(n,i){t.commandId+=1;var r=t.commandId;e.id=r,t.commands[r]={resolve:n,reject:i},t.sendMessage(e)})},S.prototype._handleMessage=function(e){var t=JSON.parse(e.data);switch(t.type){case"event":this.commands[t.id].eventCallback(t.event);break;case"result":t.success?this.commands[t.id].resolve(t):this.commands[t.id].reject(t.error),delete this.commands[t.id]}},S.prototype._handleClose=function(){var e=this;if(Object.keys(this.commands).forEach(function(t){var n=e.commands[t],i=n.reject;i&&i(a(3,"Connection lost"))}),!this.closeRequested){this.fireEvent("disconnected");var t=Object.assign({},this.options,{setupRetry:0});!function n(i){setTimeout(function(){d(e.url,t).then(function(t){return e.setSocket(t)},function(){return n(i+1)})},1e3*Math.min(i,5))}(0)}};var j="group.default_view",L=Object.freeze({ERR_CANNOT_CONNECT:O,ERR_INVALID_AUTH:C,createConnection:v,subscribeConfig:h,subscribeEntities:g,getGroupEntities:_,splitByGroups:E,getViewEntities:w,extractViews:k,extractDomain:m,extractObjectId:y});window.HAWS=L,window.HASS_DEMO=!1,window.HASS_DEV=!1;var P=window.createHassConnection=function(e){var t="https:"===window.location.protocol?"wss":"ws",n=t+"://"+window.location.host+"/api/websocket",i={setupRetry:10};return void 0!==e&&(i.authToken=e),v(n,i).then(function(e){return g(e),h(e),e})};window.noAuth?window.hassConnection=P():window.localStorage.authToken?window.hassConnection=P(window.localStorage.authToken):window.hassConnection=null,"serviceWorker"in navigator&&window.addEventListener("load",function(){navigator.serviceWorker.register("/service_worker.js")})}(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
Expected an assignment or function call and instead saw an expression.
Unreachable 'var' after 'return'.
Too many errors. (50% scanned).
250+ commits? I think I borked up somewhere. |
Easiest fix is to just copy out your files, create a new branch from dev, and paste them in. Also, as mentioned above, if you can give it a more generic name like nad-ip or nad-tcp that would be good. |
Created PR #7955 to replace this one. |
Closed for #7955 |
Initial commit for NAD D 7050 media player component. For homeassistant.io documentation see doc-nad7050 pull request