Use websocket for entity registry update (#1261)

* Use websocket for entity registry update

* Lint
This commit is contained in:
Paulus Schoutsen 2018-06-06 22:34:34 -04:00 committed by GitHub
parent bf4d0e6bc9
commit cab53b3324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -141,11 +141,13 @@ class HaMoreInfoDialog extends DialogMixin(PolymerElement) {
if (isComponentLoaded(this.hass, 'config.entity_registry') && if (isComponentLoaded(this.hass, 'config.entity_registry') &&
(!oldVal || oldVal.entity_id !== newVal.entity_id)) { (!oldVal || oldVal.entity_id !== newVal.entity_id)) {
this.hass.callApi('get', `config/entity_registry/${newVal.entity_id}`) this.hass.connection.sendMessagePromise({
.then( type: 'config/entity_registry/get',
(info) => { this._registryInfo = info; }, entity_id: newVal.entity_id,
() => { this._registryInfo = false; } }).then(
); (msg) => { this._registryInfo = msg.result; },
() => { this._registryInfo = false; }
);
} }
requestAnimationFrame(() => requestAnimationFrame(() => { requestAnimationFrame(() => requestAnimationFrame(() => {

View File

@ -93,15 +93,14 @@ class MoreInfoSettings extends EventsMixin(PolymerElement) {
} }
_save() { _save() {
const data = { this.hass.connection.sendMessagePromise({
type: 'config/entity_registry/update',
entity_id: this.stateObj.entity_id,
name: this._name, name: this._name,
}; }).then(
(msg) => { this.registryInfo = msg.result; },
this.hass.callApi('post', `config/entity_registry/${this.stateObj.entity_id}`, data) () => { alert('save failed!'); }
.then( );
(info) => { this.registryInfo = info; },
() => { alert('save failed!'); }
);
} }
} }
customElements.define('more-info-settings', MoreInfoSettings); customElements.define('more-info-settings', MoreInfoSettings);