Skip to content

Commit

Permalink
Add new option show_locate_button (default true) (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
forast3r authored Apr 12, 2021
1 parent 09fa4cd commit c286292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ min_height: 0
| show_pause_button | boolean | true | Show the pause button for vacuum_entity
| show_stop_button | boolean | true | Show the stop button for vacuum_entity
| show_home_button | boolean | true | Show the home button for vacuum_entity
| show_locate_button | boolean | true | Show the locate button for vacuum_entity
| goto_target_icon | string | mdi:pin | The icon to use for the go to target
| goto_target_color | string | 'blue' | The color to use for the go to target icon
| dock_icon | string | mdi:flash | The icon to use for the charging dock
Expand Down
14 changes: 14 additions & 0 deletions valetudo-map-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ class ValetudoMapCard extends HTMLElement {
if (this._config.show_pause_button === undefined) this._config.show_pause_button = true;
if (this._config.show_stop_button === undefined) this._config.show_stop_button = true;
if (this._config.show_home_button === undefined) this._config.show_home_button = true;
if (this._config.show_locate_button === undefined) this._config.show_locate_button = true;

// Width settings
if (this._config.virtual_wall_width === undefined) this._config.virtual_wall_width = 1;
Expand Down Expand Up @@ -905,6 +906,19 @@ class ValetudoMapCard extends HTMLElement {
this.controlFlexBox.appendChild(homeButton);
}

if (this._config.show_locate_button) {
const locateButton = document.createElement('paper-button');
const locateIcon = document.createElement('ha-icon');
const locateRipple = document.createElement('paper-ripple');
locateIcon.icon = 'hass:map-marker';
locateButton.appendChild(locateIcon);
locateButton.appendChild(locateRipple);
locateButton.addEventListener('click', (event) => {
this._hass.callService('vacuum', 'locate', { entity_id: this._config.vacuum_entity }).then();
});
this.controlFlexBox.appendChild(locateButton);
}

this.customControlFlexBox = document.createElement('div');
this.customControlFlexBox.classList.add('flex-box');

Expand Down

0 comments on commit c286292

Please sign in to comment.