Skip to content

Commit

Permalink
Support action url config on tap action (closes #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
benct committed Mar 7, 2020
1 parent 36bf456 commit 00021a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ If `toggle` is set to `true` the default action is `toggle`, otherwise it is `mo

| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| action | string | **Required** | Action to perform (`more-info`, `toggle`, `call-service`, `none`)
| action | string | **Required** | Action to perform (`more-info`, `toggle`, `call-service`, `url`, `none`)
| service | string | | Service to call (e.g. `light.turn_on`) when `action` is `call-service`
| service_data | object | | Optional data to include when `action` is `call-service`
| url_path | string | | URL to open when `action` is `url`
| confirmation | bool/string | `false` | Enable/set text to present in a confirmation dialog

## Examples
Expand Down
6 changes: 6 additions & 0 deletions multiple-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@
this._hass.callService('homeassistant', 'toggle', {entity_id: entityId});
}
}
if (config.action === 'url') {
return () => {
if (!confirmation || confirm(confirmation))
window.open(config.url_path, '_blank')?.focus();
}
}
}
return () => this.fireEvent('hass-more-info', entityId);
}
Expand Down

0 comments on commit 00021a2

Please sign in to comment.