|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "Counter" |
| 4 | +description: "Instructions how to integrate counters into Home Assistant." |
| 5 | +date: 2017-08-26 06:00 |
| 6 | +sidebar: true |
| 7 | +comments: false |
| 8 | +sharing: true |
| 9 | +footer: true |
| 10 | +logo: home-assistant.png |
| 11 | +ha_category: Automation |
| 12 | +ha_release: 0.53 |
| 13 | +--- |
| 14 | + |
| 15 | +The `counter` component allows one to count occurrences fired by automations. |
| 16 | + |
| 17 | +To add a counter to your installation, add the following to your `configuration.yaml` file: |
| 18 | + |
| 19 | +```yaml |
| 20 | +# Example configuration.yaml entry |
| 21 | +counter: |
| 22 | + counter: |
| 23 | + initial: 30 |
| 24 | + step: 1 |
| 25 | +``` |
| 26 | +
|
| 27 | +Configuration variables: |
| 28 | +
|
| 29 | +- **[alias]** (*Required*): Alias for the slider input. Multiple entries are allowed. |
| 30 | + - **name** (*Optional*): Friendly name of the slider input. |
| 31 | + - **initial** (*Optional*): Initial value when Home Assistant starts. Defaults to 0. |
| 32 | + - **step** (*Optional*): Step value for the slider. Defaults to 1. |
| 33 | + - **icon** (*Optional*): Icon for entry. |
| 34 | +
|
| 35 | +Pick an icon that you can find on [materialdesignicons.com](https://materialdesignicons.com/) to use for your input and prefix the name with `mdi:`. For example `mdi:car`, `mdi:ambulance`, or `mdi:motorbike`. |
| 36 | + |
| 37 | +## {% linkable_title Services %} |
| 38 | + |
| 39 | +### {% linkable_title Media control services %} |
| 40 | +Available services: `increment`, `decrement`, and `reset`. |
| 41 | + |
| 42 | +#### {% linkable_title Service `counter/increment` %} |
| 43 | + |
| 44 | +Increments the counter with 1 or the given value for the steps. |
| 45 | + |
| 46 | +| Service data attribute | Optional | Description | |
| 47 | +| ---------------------- | -------- | ----------- | |
| 48 | +| `entity_id` | no | Name of the entity to take action, e.g., `counter.count0`. | |
| 49 | + |
| 50 | +#### {% linkable_title Service `counter/decrement` %} |
| 51 | + |
| 52 | +Decrements the counter with 1 or the given value for the steps. |
| 53 | + |
| 54 | +| Service data attribute | Optional | Description | |
| 55 | +| ---------------------- | -------- | ----------- | |
| 56 | +| `entity_id` | no | Name of the entity to take action, e.g., `counter.count0`. | |
| 57 | + |
| 58 | +#### {% linkable_title Service `counter/reset` %} |
| 59 | + |
| 60 | +With this service the counter is reset to its initial value. |
| 61 | + |
| 62 | +| Service data attribute | Optional | Description | |
| 63 | +| ---------------------- | -------- | ----------- | |
| 64 | +| `entity_id` | no | Name of the entity to take action, e.g., `counter.count0`. | |
| 65 | + |
| 66 | + |
| 67 | +### {% linkable_title Use the service %} |
| 68 | + |
| 69 | +Select <img src='/images/screenshots/developer-tool-services-icon.png' alt='service developer tool icon' class="no-shadow" height="38" /> **Services** from the **Developer Tools**. Choose **counter** from the list of **Domains**, select the **Service**, enter something like the sample below into the **Service Data** field, and hit **CALL SERVICE**. |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "entitiy": "counter.count0" |
| 74 | +} |
| 75 | +``` |
| 76 | + |
0 commit comments