From f4a5e97d2530451127e20074003cc90db4c55ba2 Mon Sep 17 00:00:00 2001
From: Konstantin Grinkevich <34913257+grinstantin@users.noreply.github.com>
Date: Tue, 13 Apr 2021 16:41:48 +0300
Subject: [PATCH] fix: The websocket command 'camera_thumbnail' has been
deprecated. (#201)
---
src/vacuum-card.js | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/src/vacuum-card.js b/src/vacuum-card.js
index 3c7088cc..4b70e468 100755
--- a/src/vacuum-card.js
+++ b/src/vacuum-card.js
@@ -18,7 +18,6 @@ class VacuumCard extends LitElement {
return {
hass: Object,
config: Object,
- mapUrl: String,
requestInProgress: Boolean,
};
}
@@ -118,25 +117,12 @@ class VacuumCard extends LitElement {
}
}
- updateCameraImage() {
- this.hass
- .callWS({
- type: 'camera_thumbnail',
- entity_id: this.config.map,
- })
- .then((val) => {
- const { content_type: contentType, content } = val;
- this.mapUrl = `data:${contentType};base64, ${content}`;
- this.requestUpdate();
- });
- }
-
connectedCallback() {
super.connectedCallback();
if (!this.compactView && this.map) {
- this.updateCameraImage();
+ this.requestUpdate();
this.thumbUpdater = setInterval(
- () => this.updateCameraImage(),
+ () => this.requestUpdate(),
(this.config.map_refresh || 5) * 1000
);
}
@@ -146,7 +132,6 @@ class VacuumCard extends LitElement {
super.disconnectedCallback();
if (this.map) {
clearInterval(this.thumbUpdater);
- this.map_image = null;
}
}
@@ -250,11 +235,18 @@ class VacuumCard extends LitElement {
}
if (this.map) {
- return html` `;
+ return this.hass.states[this.config.map] &&
+ this.hass.states[this.config.map].attributes.entity_picture
+ ? html``
+ : html``;
}
if (this.image) {
- return html` `;
+ return html``;
}
return html``;