Skip to content

Commit

Permalink
Support for URL in tap_action (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider authored and iantrich committed Apr 19, 2019
1 parent 17c38bc commit d075d7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ Lovelace Button card for your entities.

### Action

| Name | Type | Default | Supported options | Description |
| ----------------- | ------ | -------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `action` | string | `toggle` | `more-info`, `toggle`, `call-service`, `none`, `navigate` | Action to perform |
| `navigation_path` | string | none | Eg: `/lovelace/0/` | Path to navigate to (e.g. `/lovelace/0/`) when action defined as navigate |
| `service` | string | none | Any service | Service to call (e.g. `media_player.media_play_pause`) when `action` defined as `call-service` |
| `service_data` | object | none | Any service data | Service data to include (e.g. `entity_id: media_player.bedroom`) when `action` defined as `call-service` |
| Name | Type | Default | Supported options | Description |
| ----------------- | ------ | -------- | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `action` | string | `toggle` | `more-info`, `toggle`, `call-service`, `none`, `navigate`, `url` | Action to perform |
| `navigation_path` | string | none | Eg: `/lovelace/0/` | Path to navigate to (e.g. `/lovelace/0/`) when action defined as navigate |
| `url` | string | none | Eg: `https://www.google.fr` | URL to open on click when action is `url`. The URL will open in a new tab |
| `service` | string | none | Any service | Service to call (e.g. `media_player.media_play_pause`) when `action` defined as `call-service` |
| `service_data` | object | none | Any service data | Service data to include (e.g. `entity_id: media_player.bedroom`) when `action` defined as `call-service` |

### State

Expand Down
3 changes: 3 additions & 0 deletions button-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ export default function domainIcon(domain, state) {
const [domain, service] = config.tap_action.service.split('.', 2);
this.hass.callService(domain, service, config.tap_action.service_data);
break;
case 'url':
config.tap_action.url && window.open(config.tap_action.url);
break;
case 'toggle':
default:
this.hass.callService('homeassistant', 'toggle', {
Expand Down

0 comments on commit d075d7d

Please sign in to comment.