From 72903c1a93981de36467bbb346614715443c150f Mon Sep 17 00:00:00 2001 From: James Hirka Date: Fri, 22 Oct 2021 15:34:29 +1100 Subject: [PATCH] added support for viomi S9 --- xiaomi-vacuum-card.js | 68 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/xiaomi-vacuum-card.js b/xiaomi-vacuum-card.js index b2a49cc..80f1ace 100644 --- a/xiaomi-vacuum-card.js +++ b/xiaomi-vacuum-card.js @@ -87,15 +87,31 @@ xiaomi: {}, xiaomi_mi: { attributes: { - main_brush: {key: 'main_brush_hours'}, - side_brush: {key: 'side_brush_hours'}, - filter: {key: 'hypa_hours'}, + main_brush: { key: 'main_brush_hours' }, + side_brush: { key: 'side_brush_hours' }, + filter: { key: 'hypa_hours' }, sensor: { key: 'mop_hours', label: 'Mop: ', }, }, }, + viomi: { + state: { + status: { + key: 'state', + }, + }, + attributes: { + main_brush: { key: 'viomi_vacuum.main_brush_hours' }, + side_brush: { key: 'viomi_vacuum.side_brush_hours' }, + filter: { key: 'viomi_vacuum.hypa_hours' }, + sensor: { + key: 'viomi_vacuum.mop_hours', + label: 'Mop: ', + }, + }, + }, valetudo: { state: { status: { @@ -103,10 +119,10 @@ }, }, attributes: { - main_brush: {key: 'mainBrush'}, - side_brush: {key: 'sideBrush'}, - filter: {key: 'filter'}, - sensor: {key: 'sensor'}, + main_brush: { key: 'mainBrush' }, + side_brush: { key: 'sideBrush' }, + filter: { key: 'filter' }, + sensor: { key: 'sensor' }, }, }, roomba: { @@ -130,24 +146,24 @@ robovac: { attributes: false, buttons: { - stop: {show: false}, - spot: {show: true}, + stop: { show: false }, + spot: { show: true }, }, }, ecovacs: { attributes: false, buttons: { - start: {service: 'vacuum.turn_on'}, - pause: {service: 'vacuum.stop'}, - stop: {service: 'vacuum.turn_off', show: false}, - spot: {show: true}, + start: { service: 'vacuum.turn_on' }, + pause: { service: 'vacuum.stop' }, + stop: { service: 'vacuum.turn_off', show: false }, + spot: { show: true }, }, }, deebot: { buttons: { - start: {service: 'vacuum.turn_on'}, - pause: {service: 'vacuum.stop'}, - stop: {service: 'vacuum.turn_off'}, + start: { service: 'vacuum.turn_on' }, + pause: { service: 'vacuum.stop' }, + stop: { service: 'vacuum.turn_off' }, }, attributes: { main_brush: { @@ -167,14 +183,14 @@ }, deebot_slim: { buttons: { - start: {service: 'vacuum.turn_on'}, - pause: {service: 'vacuum.stop'}, - stop: {service: 'vacuum.turn_off'}, + start: { service: 'vacuum.turn_on' }, + pause: { service: 'vacuum.stop' }, + stop: { service: 'vacuum.turn_off' }, }, attributes: { main_brush: false, - side_brush: {key: 'component_side_brush'}, - filter: {key: 'component_filter'}, + side_brush: { key: 'component_side_brush' }, + filter: { key: 'component_filter' }, sensor: false, }, }, @@ -256,8 +272,8 @@ return this.stateObj ? html` ${this.config.show.name ? - html`
${this.config.name || this.stateObj.attributes.friendly_name}
` - : null} + html`
${this.config.name || this.stateObj.attributes.friendly_name}
` + : null} ${(this.config.show.state || this.config.show.attributes) ? html`
${this.config.show.state ? html` @@ -372,10 +388,10 @@ handleChange(e, key) { const mode = e.target.getAttribute('value'); - this.callService(`vacuum.set_${key}`, {entity_id: this.stateObj.entity_id, [key]: mode}); + this.callService(`vacuum.set_${key}`, { entity_id: this.stateObj.entity_id, [key]: mode }); } - callService(service, data = {entity_id: this.stateObj.entity_id}) { + callService(service, data = { entity_id: this.stateObj.entity_id }) { const [domain, name] = service.split('.'); this._hass.callService(domain, name, data); } @@ -386,7 +402,7 @@ cancelable: options.cancelable || true, composed: options.composed || true, }); - event.detail = {entityId: this.stateObj.entity_id}; + event.detail = { entityId: this.stateObj.entity_id }; this.dispatchEvent(event); }