Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMachowski committed Oct 29, 2019
1 parent 88123cc commit 45d88a7
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 1 deletion.
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Lovelace Local Conditional card

This card can show and hide a specific card on current device while not affecting other windows. It does not require any integration to run.

## Configuration options

| Key | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `string` | `true` | - | Identifier of a card, used in service calls. **Must be unique!** |
| `card` | `card` | `true` | - | Configuration of a nested card |
| `default` | `string` | `false` | `hide` | Default card behaviour. Possible values: [`show`, `hide`]. |

## Services

This card adds 3 new services that can be used **ONLY** from UI:
- `local_conditional_card.show` - shows specified card
- `local_conditional_card.hide` - hides specified card
- `local_conditional_card.toggle` - shows or hides specified card

Each of these services requires a parameter `id` that have to correspond to a existing card.

## Example configuration

![Example](https://github.com/PiotrMachowski/Home-Assistant-Lovelace-Local-Conditional-card/raw/master/s1.gif)

```yaml
views:
- name: Example
cards:
- type: 'custom:local-toggle-card'
default: show
id: sun1
card:
entities:
- sun.sun
title: Sun 1
type: entities
- type: 'custom:local-toggle-card'
id: sun2
card:
entities:
- sun.sun
title: Sun 2
type: entities
- title: Click test
type: entities
entities:
- action_name: Toggle
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.toggle
service_data:
id: sun1
type: call-service
- action_name: Show
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.show
service_data:
id: sun1
type: call-service
- action_name: Hide
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.hide
service_data:
id: sun1
type: call-service
- action_name: Toggle
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.toggle
service_data:
id: sun2
type: call-service
- action_name: Show
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.show
service_data:
id: sun2
type: call-service
- action_name: Hide
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.hide
service_data:
id: sun2
type: call-service
```
## Manual Installation
1. Download [*local-conditional-card.js*](https://github.com/PiotrMachowski/Home-Assistant-Lovelace-Local-Conditional-card/raw/master/dist/local-conditional-card.js) to `/www/custom_lovelace/local_conditional_card` directory:
```bash
mkdir -p www/custom_lovelace/local_conditional_card
cd www/custom_lovelace/local_conditional_card/
wget https://github.com/PiotrMachowski/Home-Assistant-Lovelace-Local-Conditional-card/raw/master/dist/local-conditional-card.js
```
2. Add card to resources in `ui-lovelace.yaml` or in raw editor if you are using frontend UI editor:
```yaml
resources:
- url: /local/custom_lovelace/local_conditional_card/local-conditional-card.js
type: module
```
2 changes: 1 addition & 1 deletion dist/local-conditional-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalConditionalCard extends LitElement {
}

set hass(hass) {
const thisDomain = "local_toggle_card";
const thisDomain = "local_conditional_card";
if (!this._config || !hass) return;
this._hass = hass;
if (this.hassPatched) return;
Expand Down
4 changes: 4 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Local Conditional card",
"filename": "local-conditional-card.js"
}
88 changes: 88 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
This card can show and hide a specific card on current device while not affecting other windows. It does not require any integration to run.

## Configuration options

| Key | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `string` | `true` | - | Identifier of a card, used in service calls. **Must be unique!** |
| `card` | `card` | `true` | - | Configuration of a nested card |
| `default` | `string` | `false` | `hide` | Default card behaviour. Possible values: [`show`, `hide`]. |

## Services

This card adds 3 new services that can be used **ONLY** from UI:
- `local_conditional_card.show` - shows specified card
- `local_conditional_card.hide` - hides specified card
- `local_conditional_card.toggle` - shows or hides specified card

Each of these services requires a parameter `id` that have to correspond to a existing card.

## Example configuration

![Example](https://github.com/PiotrMachowski/Home-Assistant-Lovelace-Local-Conditional-card/raw/master/s1.gif)

```yaml
views:
- name: Example
cards:
- type: 'custom:local-toggle-card'
default: show
id: sun1
card:
entities:
- sun.sun
title: Sun 1
type: entities
- type: 'custom:local-toggle-card'
id: sun2
card:
entities:
- sun.sun
title: Sun 2
type: entities
- title: Click test
type: entities
entities:
- action_name: Toggle
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.toggle
service_data:
id: sun1
type: call-service
- action_name: Show
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.show
service_data:
id: sun1
type: call-service
- action_name: Hide
icon: 'mdi:power'
name: Sun1
service: local_conditional_card.hide
service_data:
id: sun1
type: call-service
- action_name: Toggle
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.toggle
service_data:
id: sun2
type: call-service
- action_name: Show
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.show
service_data:
id: sun2
type: call-service
- action_name: Hide
icon: 'mdi:power'
name: Sun2
service: local_conditional_card.hide
service_data:
id: sun2
type: call-service
```

0 comments on commit 45d88a7

Please sign in to comment.