Skip to content

Commit

Permalink
Merge pull request #8 from sbryfcz/feature-3-button-customization
Browse files Browse the repository at this point in the history
Feature 3 button customization
  • Loading branch information
sbryfcz authored Feb 3, 2020
2 parents afe6767 + 544cae2 commit 57a5875
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 56 deletions.
136 changes: 135 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Hey there! Hope you are enjoying my work. Help me out for a couple of :beers: or
| volume_device | string | **Optional** | Harmony device name to control volume | |
| activites | Activity| **Required** | List of Activities (see below) | |
| scale | number | **Optional** | A multiplier to scale the icons by | 1 |
| buttons | Button Dictionary | **Optional** | A dictionary/object of button config to override defaults | |
| tap_action | object | **Optional** | Action to take on tap | `action: more-info` |
| hold_action | object | **Optional** | Action to take on hold | `none` |
| double_tap_action | object | **Optional** | Action to take on hold | `none` |
Expand All @@ -40,7 +41,7 @@ Hey there! Hope you are enjoying my work. Help me out for a couple of :beers: or
| device | string | **Required** | The name of the harmony device as named in the harmony config to use for sending commands | |
| volume_entity | string | **Optional** | Home Assistant entity ID of volume control media_player| |
| volume_device | string | **Optional** | Harmony device name to control volume | |

| buttons | Button Dictionary | **Optional** | A dictionary/object of button config to override defaults | |
## Action Options

| Name | Type | Requirement | Description | Default |
Expand All @@ -52,6 +53,110 @@ Hey there! Hope you are enjoying my work. Help me out for a couple of :beers: or
| service_data | object | **Optional** | Service data to include (e.g. entity_id: media_player.bedroom) when action defined as call-service | `none` |
| haptic | string | **Optional** | Haptic feedback for the [Beta IOS App](http://home-assistant.io/ios/beta) _success, warning, failure, light, medium, heavy, selection_ | `none` |
| repeat | number | **Optional** | How often to repeat the `hold_action` in milliseconds. | `non` |
## Button Options
These options let you override the default icon, commands, devices, and visibility.

| Name | Type | Requirement | Description | Default |
| ----------------- | ------- | ------------ | ------------------------------------------- | ------------------- |
| command | string | **Optional** | The device command to use | See below |
| device | string | **Optional** | The harmony device name to send the command to | See below |
| icon | string | **Optional** | The icon to display for the button | See below |
| hide | string | **Optional** | Should this button be hidden | false |

Buttons Available to Configure with Defaults:
```json
'volume_down': {
command: 'VolumeDown',
icon: 'mdi:volume-medium',
hide: false
},
'volume_up': {
command: 'VolumeUp',
icon: 'mdi:volume-high',
hide: false
},
'volume_mute': {
command: 'Mute',
icon: 'mdi:volume-off',
hide: false
},
'skip_back': {
command: 'SkipBack',
icon: 'mdi:skip-previous',
hide: false
},
'play': {
command: 'Play',
icon: 'mdi:play',
hide: false
},
'pause': {
command: 'Pause',
icon: 'mdi:pause',
hide: false
},
'skip_forward': {
command: 'SkipForward',
icon: 'mdi:skip-next',
hide: false
},
'dpad_up': {
command: 'DirectionUp',
icon: 'mdi:chevron-up-circle',
hide: false
},
'dpad_down': {
command: 'DirectionDown',
icon: 'mdi:chevron-down-circle',
hide: false
},
'dpad_left': {
command: 'DirectionLeft',
icon: 'mdi:chevron-left-circle',
hide: false
},
'dpad_right': {
command: 'DirectionRight',
icon: 'mdi:chevron-right-circle',
hide: false
},
'dpad_center': {
command: 'OK',
icon: 'mdi:checkbox-blank-circle',
hide: false
},
'xbox': {
command: 'Xbox',
icon: 'mdi:xbox',
hide: false
},
'back': {
command: 'Back',
icon: 'mdi:undo-variant',
hide: false
},
'a': {
command: 'A',
icon: 'mdi:alpha-a-circle',
hide: false
},
'b': {
command: 'B',
icon: 'mdi:alpha-b-circle',
hide: false
},
'x': {
command: 'X',
icon: 'mdi:alpha-x-circle',
hide: false
},
'y': {
command: 'Y',
icon: 'mdi:alpha-y-circle',
hide: false
}
```

### Configuration Order of Precedence
In general the configuration for the card will be determined from more specific configuration to less specific configuration. By this, I mean that if there is both global card configuration and activity configuration, this plugin will use the activity level configuration.

Expand All @@ -70,12 +175,20 @@ Ex.
In this case, the card will issue commands via `media_player.alexa` if the current activity is 'Play Xbox One'. Otherwise, it will use `media_player.living_room`.

#### Volume
Furthermore, volume controls try to use specified media players (if configured) since those offer most robust functionality (ie. the volume slider). So the order of precedence for volume controls are:
1. Activity Level volume_entity
2. Activity Level volume_device
3. Card Level volume_entity
4. Card Level volume_device

#### Devices
Devices to be used for buttons follow the following order of precedence:
1. Activity-button level device
2. Card-button level device
3. Activity level device
4. Card level device

## Example Configuration
### Resources
```yaml
Expand All @@ -97,6 +210,27 @@ resources:
device: Onkyo AV Receiver
```

### Card with Custom Button Config
```yaml
- type: 'custom:harmony-card'
entity: remote.living_room_hub
volume_entity: media_player.living_room
scale: 1.25
activities:
- name: Play Xbox One
device: Microsoft Xbox One
- name: Listen to Music
device: Onkyo AV Receiver
buttons:
a:
icon: 'mdi:chevron-up'
device: Onkyo AV Receiver
command: VolumeUp
b:
icon: 'mdi:chevron-down'
device: Onkyo AV Receiver
command: VolumeDown
```
## Development

### Step 1
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harmony-card",
"version": "0.8.0",
"version": "0.9.0",
"description": "Lovelace harmony-card",
"keywords": [
"home-assistant",
Expand All @@ -20,6 +20,7 @@
"@polymer/paper-button": "^3.0.1",
"@polymer/paper-icon-button": "^3.0.2",
"custom-card-helpers": "^1.3.9",
"deepmerge": "^4.2.2",
"fa-icons": "^0.1.9",
"home-assistant-js-websocket": "^4.4.0",
"lit-element": "^2.2.1",
Expand Down
97 changes: 96 additions & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
export const CARD_VERSION = '0.8.0';
import { HarmonyButtonConfig } from "./types";

export const CARD_VERSION = '0.9.0';

export const DEFAULT_BUTTONS: { [key: string]: HarmonyButtonConfig } = {
'volume_down': {
command: 'VolumeDown',
icon: 'mdi:volume-medium',
hide: false
},
'volume_up': {
command: 'VolumeUp',
icon: 'mdi:volume-high',
hide: false
},
'volume_mute': {
command: 'Mute',
icon: 'mdi:volume-off',
hide: false
},
'skip_back': {
command: 'SkipBack',
icon: 'mdi:skip-previous',
hide: false
},
'play': {
command: 'Play',
icon: 'mdi:play',
hide: false
},
'pause': {
command: 'Pause',
icon: 'mdi:pause',
hide: false
},
'skip_forward': {
command: 'SkipForward',
icon: 'mdi:skip-next',
hide: false
},
'dpad_up': {
command: 'DirectionUp',
icon: 'mdi:chevron-up-circle',
hide: false
},
'dpad_down': {
command: 'DirectionDown',
icon: 'mdi:chevron-down-circle',
hide: false
},
'dpad_left': {
command: 'DirectionLeft',
icon: 'mdi:chevron-left-circle',
hide: false
},
'dpad_right': {
command: 'DirectionRight',
icon: 'mdi:chevron-right-circle',
hide: false
},
'dpad_center': {
command: 'OK',
icon: 'mdi:checkbox-blank-circle',
hide: false
},
'xbox': {
command: 'Xbox',
icon: 'mdi:xbox',
hide: false
},
'back': {
command: 'Back',
icon: 'mdi:undo-variant',
hide: false
},
'a': {
command: 'A',
icon: 'mdi:alpha-a-circle',
hide: false
},
'b': {
command: 'B',
icon: 'mdi:alpha-b-circle',
hide: false
},
'x': {
command: 'X',
icon: 'mdi:alpha-x-circle',
hide: false
},
'y': {
command: 'Y',
icon: 'mdi:alpha-y-circle',
hide: false
}
};
Loading

0 comments on commit 57a5875

Please sign in to comment.