Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update services.md: tweak YAML to enable copy/paste #586

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 78 additions & 69 deletions _docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,29 @@ input_text:
Then an automation might look like the following

```yaml
automations:
- alias: Update target rate config
trigger:
- platform: state
entity_id:
mode: single
alias: Update target rate config
trigger:
- platform: state
entity_id:
- input_number.octopus_energy_target_hours
- input_text.octopus_energy_target_from
- input_text.octopus_energy_target_to
- input_text.octopus_energy_target_offset
condition: []
action:
- service: octopus_energy.update_target_config
data:
target_hours: >
"{{ states('input_number.octopus_energy_target_hours') | string }}"
target_start_time: >
{{ states('input_text.octopus_energy_target_from') }}
target_end_time: >
{{ states('input_text.octopus_energy_target_to') }}
target_offset: >
{{ states('input_text.octopus_energy_target_offset') }}
target:
entity_id: binary_sensor.octopus_energy_target_example
condition: []
action:
- service: octopus_energy.update_target_config
data:
target_hours: >
"{{ states('input_number.octopus_energy_target_hours') | string }}"
target_start_time: >
{{ states('input_text.octopus_energy_target_from') }}
target_end_time: >
{{ states('input_text.octopus_energy_target_to') }}
target_offset: >
{{ states('input_text.octopus_energy_target_offset') }}
target:
entity_id: binary_sensor.octopus_energy_target_example
```

## join_octoplus_saving_session_event
Expand All @@ -105,19 +105,22 @@ Service for joining a new saving session event. When used, it may take a couple
Using the [new saving session event](./events.md#new-saving-session), we can join new saving session events automatically in the following way

```yaml
- trigger:
alias: Octopus Saving Session joiner
description: Automatically join Octopus Saving Session Events
mode: single
trigger:
- platform: event
event_type: octopus_energy_new_octoplus_saving_session
condition: []
action:
condition: []
action:
- service: octopus_energy.join_octoplus_saving_session_event
data:
event_code: '{{ trigger.event.data["event_code"] }}'
target:
entity_id: event.octopus_energy_{{ACCOUNT_ID}}_octoplus_saving_session_events
- service: persistent_notification.create
data:
title: "Saving Sessions Updated"
title: "Octopus Saving Sessions Updated"
message: >
Joined new Octopus Energy saving session. It starts at {{ trigger.event.data["event_start"].strftime('%H:%M') }} on {{ trigger.event.data["event_start"].day }}/{{ trigger.event.data["event_start"].month }}
```
Expand All @@ -131,59 +134,65 @@ This service allows the user to perform a spin on the [wheel of fortune](./entit
We can use the following automation to automatically spin the wheel of fortune

```yaml
- mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
above: 0
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
above: 0
condition: []
action:
- repeat:
count: '{{ states(trigger.entity_id) | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: '{{ trigger.entity_id }}'
alias: Octopus Wheel of Fortune spinner
description: Spin the Octopus Wheel of Fortune automatically every month
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
above: 0
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
above: 0
condition: []
action:
- repeat:
count: '{{ states(trigger.entity_id) | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: '{{ trigger.entity_id }}'
```

or you can split it up into two separate automations

```yaml
- mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
above: 0
condition: []
action:
- repeat:
count: '{{ states('sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity') | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
alias: Octopus Wheel of Fortune Electricity spinner
description: Spin the Octopus Wheel of Fortune for Electricity account automatically monthly
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
above: 0
condition: []
action:
- repeat:
count: '{{ states('sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity') | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_electricity
```

and

```yaml
- mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
above: 0
condition: []
action:
- repeat:
count: '{{ states('sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas') | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
```
alias: Octopus Wheel of Fortune Gas spinner
description: Spin the Octopus Wheel of Fortune for Gas account automatically monthly
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
above: 0
condition: []
action:
- repeat:
count: '{{ states('sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas') | int }}'
sequence:
- service: octopus_energy.spin_wheel_of_fortune
data: {}
target:
entity_id: sensor.octopus_energy_{{ACCOUNT_ID}}_wheel_of_fortune_spins_gas
```
Loading