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') &&
(!oldVal || oldVal.entity_id !== newVal.entity_id)) {
this.hass.callApi('get', `config/entity_registry/${newVal.entity_id}`)
.then(
(info) => { this._registryInfo = info; },
() => { this._registryInfo = false; }
);
this.hass.connection.sendMessagePromise({
type: 'config/entity_registry/get',
entity_id: newVal.entity_id,
}).then(
(msg) => { this._registryInfo = msg.result; },
() => { this._registryInfo = false; }
);
}
requestAnimationFrame(() => requestAnimationFrame(() => {

View File

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