Skip to content

Commit

Permalink
feat(actions): header_actions support for actions in header (RomRid…
Browse files Browse the repository at this point in the history
…er#171)

* feat(actions): Support for actions in header

* feat(actions): Disable all actions

* fix: Broken setConfig

* doc: Update readme for actions

Fix RomRider#61
  • Loading branch information
RomRider committed Jul 4, 2021
1 parent 6d45157 commit bd6a497
Show file tree
Hide file tree
Showing 12 changed files with 979 additions and 19 deletions.
37 changes: 36 additions & 1 deletion .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1020,20 +1020,55 @@ views:
apex_config:
tickAmount: 6
- type: custom:apexcharts-card
show:
last_updated: true
graph_span: 20min
all_series_config:
stroke_width: 2
series:
- entity: sensor.random0_100
header_actions:
tap_action:
action: more-info
confirmation:
text: test
hold_action:
action: more-info
entity: sensor.random_0_1000
- entity: sensor.random0_100
transform: 'return Number(x) + 1230;'
yaxis:
- min: 0
max: ~1200
apex_config:
tickAmount: 4
header:
title: Test Actions
show: true
title: Soft Bounds + fixed bound
show_states: true
colorize_states: true
- type: custom:apexcharts-card
show:
last_updated: true
graph_span: 20min
all_series_config:
stroke_width: 2
series:
- entity: sensor.random0_100
header_actions:
hold_action:
action: more-info
entity: sensor.random_0_1000
- entity: sensor.random0_100
transform: 'return Number(x) + 1230;'
yaxis:
- min: 0
max: ~1200
apex_config:
tickAmount: 4
header:
title: Actions Disabled
show: true
show_states: true
colorize_states: true
disable_actions: true
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ However, some things might be broken :grin:
- [Main Options](#main-options)
- [`series` Options](#series-options)
- [series' `show` Options](#series-show-options)
- [`header_actions` options](#header_actions-options)
- [`*_action` options](#_action-options)
- [`confirmation` options](#confirmation-options)
- [Main `show` Options](#main-show-options)
- [`header` Options](#header-options)
- [`now` Options](#now-options)
Expand Down Expand Up @@ -177,6 +180,7 @@ The card stricly validates all the options available (but not for the `apex_conf
| `color_threshold` | object | | v1.6.0 | See [experimental](#experimental-features) |
| `yaxis_id` | string | | v1.9.0 | The identification name of the y-axis which this serie should be associated to. See [yaxis](#yaxis-options-multi-y-axis) |
| `show` | object | | v1.3.0 | See [serie's show options](#series-show-options) |
| `header_actions` | object | | NEXT_VERSION | See [header_actions](#header_actions-options) |

### series' `show` Options

Expand All @@ -194,6 +198,67 @@ The card stricly validates all the options available (but not for the `apex_conf
| `in_brush` | boolean | `false` | v1.8.0 | See [brush](#brush-experimental-feature) |
| `offset_in_name` | boolean | `true` | v1.8.0 | If `true`, appends the offset information to the name of the serie. If `false`, it doesn't |

### `header_actions` options


| Name | Type | Default | Since | Description |
| ---- | :--: | :-----: | :---: | ----------- |
| `tap_action` | object | | NEXT_VERSION | Action to perform on tap. See [action options](#_action-options) |
| `hold_action` | object | | NEXT_VERSION | Action to perform on hold. See [action options](#_action-options) |
| `double_tap_action` | object | | NEXT_VERSION | Action to perform on double tap. See [action options](#_action-options) |

### `*_action` options

| Name | Type | Default | Since | Description |
| ---- | :--: | :-----: | :---: | ----------- |
| `action` | string | `more-info` | NEXT_VERSION | Action to perform. Valid values are: `more-info`, `toggle`, `call-service`, `none`, `navigate`, `url` |
| `entity` | string | | NEXT_VERSION | Only valid for `more-info`. Overrides the `more-info` target entity. Default is to use the serie's entity |
| `navigation_path` | string | | NEXT_VERSION | Path to navigate to (e.g. `/lovelace/0/`) when action is `navigate` |
| `url_path` | string | | NEXT_VERSION | URL to open on click when action is `url`. The URL will open in a new tab |
| `service` | string | | NEXT_VERSION | Any valid Home-Assistant service |
| `service_data` | object | | NEXT_VERSION | Service data to include (e.g. `entity_id: media_player.bedroom`) when `action` defined as `call-service` |
| `confirmation` | object | | NEXT_VERSION |Display a confirmation popup. See [confirmation](#confirmation-options) |

Example:
```yaml
type: custom:apexcharts-card
series:
- entity: sensor.indoor_temperature
header_actions:
tap_action:
action: call-service
service: climate.turn_on
service_data:
entity_id: climate.heater
```

### `confirmation` options

This will popup a dialog box before running the action.

| Name | Type | Default | Since | Description |
| ---- | :--: | :-----: | :---: | ----------- |
| `text` | string | | NEXT_VERSION | This text will be displayed in the popup |
| `exemptions` | array | | NEXT_VERSION | Any user declared in this list will not see the confirmation dialog. Format `user: USER_ID` |

Example:

```yaml
type: custom:apexcharts-card
series:
- entity: sensor.indoor_temperature
header_actions:
tap_action:
action: call-service
service: script.toggle_climate
service_data:
entity: climate.heater
confirmation:
text: Are you sure?
exemptions:
- user: befc8496799848bda1824f2a8111e30a
```

### Main `show` Options

| Name | Type | Default | Since | Description |
Expand All @@ -210,6 +275,7 @@ The card stricly validates all the options available (but not for the `apex_conf
| `show_states` | boolean | `false` | v1.1.0 | Show or hide the states in the header |
| `colorize_states` | boolean | `false` | v1.1.0 | Colorize the states based on the color of the serie |
| `standard_format` | boolean | `false` | v1.8.0 | Display the title using the standard Home-Assistant card format |
| `disable_actions` | boolean | `false` | NEXT_VERSION | If `true`, disable all header actions |

### `now` Options

Expand Down

0 comments on commit bd6a497

Please sign in to comment.